Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bradsawadye committed May 8, 2024
1 parent 95e3ef8 commit 74dfb6f
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/unit/matchPatientSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ describe('Match Patient Synchronously', (): void => {
},
},
restoredPatient: {
id: 'testPatient',
id: '12333',
resourceType: 'Patient',
},
},
Expand Down
108 changes: 108 additions & 0 deletions tests/unit/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
createHandlerResponseObject,
mergeBundles,
transformPatientResourceForMPI,
patientProjector,
} from '../../src/utils/utils';
import {
MpiMediatorResponseObject,
Expand Down Expand Up @@ -592,6 +593,113 @@ describe('Utils', (): void => {
});
});

describe('*patientProjector', (): void => {
it('should project patient', (): void => {
const patient: Patient = {
resourceType: 'Patient',
id: '642b83d3-a43c-41ef-a578-2b730f276bfb',
extension: [
{
url: 'http://hl7.org/fhir/StructureDefinition/patient-religion',
valueCodeableConcept: {
coding: [
{
system: 'http://terminology.hl7.org/ValueSet/v3-ReligiousAffiliation',
code: '1036',
display: 'Orthodox',
},
],
},
},
{
url: 'http://hl7.org/fhir/StructureDefinition/patient-relatedPerson',
valueReference: {
reference: 'RelatedPerson/f8b7dccb-f1ef-4365-9323-29303479d02bRelatedPerson481',
},
},
{
url: 'http://cdr.aacahb.gov.et/EducationalLevel',
valueCodeableConcept: {
coding: [
{
system: 'http://terminology.hl7.org/CodeSystem/v3-EducationLevel',
code: 'ELEM',
display: 'Elementary School',
},
],
},
},
{
url: 'http://cdr.aacahb.gov.et/Occupation',
valueString: 'Foreman',
},
],
identifier: [
{
system: 'http://cdr.aacahb.gov.et/SmartCareID',
value: '642b83d3-a43c-41ef-a578-2b730f276bfb',
},
{
system: 'http://cdr.aacahb.gov.et/NationalID',
value: 'MRN-642b83d3-a43c-41ef-a578-2b730f476bf9',
},
{
system: 'http://cdr.aacahb.gov.et/UAN',
value: 'UAN-642b83d3-a43c-41ef-a578-2b730f276bfb',
},
],
name: [
{
use: 'official',
family: 'Rodrigues',
given: ['Liniee'],
},
],
telecom: [
{
system: 'phone',
value: '+2519000000',
use: 'home',
},
],
gender: 'female',
birthDate: '1999-06-19',
address: [
{
type: 'physical',
text: 'Urban',
state: 'Addis Ababa',
city: 'Cherkos sub city',
district: '10',
line: ['17', '927/5'],
},
],
maritalStatus: {
coding: [
{
system: 'http://terminology.hl7.org/CodeSystem/v3-MaritalStatus',
code: 'M',
display: 'Married',
},
],
},
managingOrganization: {
reference: 'Organization/009a6a861c1b45778c0cbedadefe52a4',
},
};

const result: Patient = patientProjector(patient);

expect(result).to.haveOwnProperty('birthDate');
expect(result).to.haveOwnProperty('id');
expect(result).to.haveOwnProperty('name');
expect(result).to.haveOwnProperty('resourceType');
expect(result).to.haveOwnProperty('gender');
expect(result).to.haveOwnProperty('identifier');
expect(result).to.not.haveOwnProperty('address')
});
});

describe('*mergeBundles', (): void => {
it('should merge bundles', async (): Promise<void> => {
const clientRegistryPatientRef: string = 'http://client-registry:8080/fhir/Patient/1455';
Expand Down

0 comments on commit 74dfb6f

Please sign in to comment.