Skip to content

Commit

Permalink
update FhirPatient unit tests for most fields (#301)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Kulatunga <jason@thesparktree.com>
  • Loading branch information
akash-pandey1729 and AnalogJ authored Nov 13, 2023
1 parent a71c690 commit 7c8a118
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
42 changes: 41 additions & 1 deletion backend/pkg/models/database/fhir_patient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,46 @@ func TestFhirPatient_ExtractSearchParameters(t *testing.T) {
},
}, testIdentifier)

var testGender []interface{}
err = json.Unmarshal(json.RawMessage(patientModel.Gender), &testGender)
require.NoError(t, err)
require.Equal(t, []interface{}{
map[string]interface{}{"code": "male"},
}, testGender)

// TODO: Fix the Goja query issues for handling the deceasedBoolean field and them uncomment this unit test
// var testDeceased []interface{}
// err = json.Unmarshal(json.RawMessage(patientModel.Deceased), &testDeceased)
// require.NoError(t, err)
// require.Equal(t, []interface{}{
// map[string]interface{}{"code": true},
// }, testDeceased)

var testfamily []string
err = json.Unmarshal(json.RawMessage(patientModel.Family), &testfamily)
require.NoError(t, err)
require.Equal(t, []string{
"Chalmers", "Windsor",
}, testfamily)

var testPhonetic []string
err = json.Unmarshal(json.RawMessage(patientModel.Phonetic), &testPhonetic)
require.NoError(t, err)
require.Equal(t, []string{
"Peter James Chalmers","Jim", "Peter James Windsor",
}, testPhonetic)

var testOrganisation []interface{}
err = json.Unmarshal(json.RawMessage(patientModel.Organization), &testOrganisation)
require.NoError(t, err)
require.Equal(t, []interface{}{
map[string]interface{}{
"reference": "Organization/1",
"__path__": "Patient.managingOrganization",
},
}, testOrganisation)


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

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
]
},
"deceasedBoolean": false,
"deceasedBoolean": true,
"address": [
{
"use": "home",
Expand Down

0 comments on commit 7c8a118

Please # to comment.