From d0c1e1789692c400452ef7b4f108acf61542e01b Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 16 Jan 2023 12:42:31 -0800 Subject: [PATCH] fixing fhir-resource tests. --- ...ort-medical-history-condition.component.ts | 2 +- .../models/resources/care-team-model.spec.ts | 19 +++++++++++++++++-- .../lib/models/resources/care-team-model.ts | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts b/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts index 29519185..000ada84 100644 --- a/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts +++ b/frontend/src/app/components/report-medical-history-condition/report-medical-history-condition.component.ts @@ -78,7 +78,7 @@ export class ReportMedicalHistoryConditionComponent implements OnInit { switch(resource.source_resource_type){ case ResourceType.CareTeam: for(let participant of (resource as CareTeamModel).participants){ - let id = participant.reference || participant.display + let id = participant.reference.reference || participant.display involvedInCareMap[id] = _.mergeWith( {}, involvedInCareMap[id], diff --git a/frontend/src/lib/models/resources/care-team-model.spec.ts b/frontend/src/lib/models/resources/care-team-model.spec.ts index 7309d857..e18b30c6 100644 --- a/frontend/src/lib/models/resources/care-team-model.spec.ts +++ b/frontend/src/lib/models/resources/care-team-model.spec.ts @@ -34,8 +34,23 @@ describe('CareTeamModel', () => { } expected.managing_organization = { reference: 'Organization/f001' } expected.participants = [ - { display: 'Peter James Chalmers', role: undefined, periodStart: undefined, periodEnd: undefined }, - { display: 'Dorothy Dietition', role: undefined, periodStart: undefined, periodEnd: '2013-01-01' } + { + display: 'Peter James Chalmers', + role: "responsiblePerson", + periodStart: undefined, + periodEnd: undefined, + reference: {reference: 'Patient/example', display: 'Peter James Chalmers' } + }, + { + display: 'Dorothy Dietition', + role: 'adviser', + periodStart: undefined, + periodEnd: '2013-01-01', + reference: { + "reference": "#pr1", + "display": "Dorothy Dietition" + } + } ] expect(new CareTeamModel(fixture)).toEqual(expected); diff --git a/frontend/src/lib/models/resources/care-team-model.ts b/frontend/src/lib/models/resources/care-team-model.ts index 0d7c0ca8..590faf79 100644 --- a/frontend/src/lib/models/resources/care-team-model.ts +++ b/frontend/src/lib/models/resources/care-team-model.ts @@ -12,7 +12,7 @@ export class CareTeamModel extends FastenDisplayModel { period_start: string | undefined period_end: string | undefined participants: { - reference?: string, + reference?: ReferenceModel, display?:string, role?:string, periodStart?: string, @@ -42,7 +42,7 @@ export class CareTeamModel extends FastenDisplayModel { _.get(fhirResource, 'managingOrganization'); this.participants = _.get(fhirResource, 'participant', []).map((item: any) => { - const reference = _.get(item, 'member.reference'); + const reference = _.get(item, 'member') as ReferenceModel; const display = _.get(item, 'member.display'); const role = _.get(item, 'role.text') || _.get(item, 'role[0].text') || _.get(item, 'role.coding.0.display'); const periodStart = _.get(item, 'period.start');