From 79a5c20d06174e164c3d33b99a63a98512ea9fce Mon Sep 17 00:00:00 2001 From: Akash Date: Sat, 21 Oct 2023 02:14:24 -0500 Subject: [PATCH] unit test for identifier and telecom for example1 --- .../pkg/models/database/fhir_patient_test.go | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/backend/pkg/models/database/fhir_patient_test.go b/backend/pkg/models/database/fhir_patient_test.go index 5bbcec2c..0b6a22db 100644 --- a/backend/pkg/models/database/fhir_patient_test.go +++ b/backend/pkg/models/database/fhir_patient_test.go @@ -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) { @@ -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) -} +} \ No newline at end of file