Skip to content

Commit

Permalink
unit test for identifier and telecom for example1
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-pandey1729 committed Oct 21, 2023
1 parent 6f4067d commit 79a5c20
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions backend/pkg/models/database/fhir_patient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package database

import (
"encoding/json"
"github.com/stretchr/testify/require"
"os"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestFhirPatient_ExtractSearchParameters(t *testing.T) {
Expand Down Expand Up @@ -50,6 +51,37 @@ func TestFhirPatient_ExtractSearchParameters(t *testing.T) {
"534 Erewhon St PleasantVille Vic 3999",
}, testAddress)

var testTelecom []interface{}
err = json.Unmarshal(json.RawMessage(patientModel.Telecom), &testTelecom)
require.NoError(t, err)
telecom_1 := map[string]interface{}{
"code": "(03) 5555 6473",
"system": "phone",
}
telecom_2 := map[string]interface{}{
"code": "(03) 3410 5613",
"system": "phone",
}
telecom_3 := map[string]interface{}{
"code":"(03) 5555 8834",
"system": "phone",
}
require.Equal(t, []interface{}{
telecom_1,
telecom_2,
telecom_3,
}, testTelecom)

var testIdentifier []interface{}
err = json.Unmarshal(json.RawMessage(patientModel.Identifier), &testIdentifier)
require.NoError(t, err)
require.Equal(t, []interface{}{
map[string]interface{}{
"code": "12345",
"system": "urn:oid:1.2.36.146.595.217.0.1",
},
}, testIdentifier)

require.Equal(t, time.Date(1974, 12, 25, 0, 0, 0, 0, time.UTC), *patientModel.Birthdate)

}
}

0 comments on commit 79a5c20

Please sign in to comment.