From 71c5504cf8684acff07680f901ef8ae225f5589c Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Wed, 12 Jun 2024 15:12:00 -0400 Subject: [PATCH 1/3] Update etasu to work with medication reference --- .../Patient/MedReqDropDown/MedReqDropDown.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx index e21dd99..14df352 100644 --- a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx +++ b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx @@ -231,10 +231,35 @@ function MedReqDropDown({ ); }; + const createMedicationFromMedicationRequest = (medicationRequest: MedicationRequest) => { + interface Medication { + resourceType: string, + id: string, + code: any + } + let medication: Medication = { resourceType: 'Medication', id: medicationRequest?.id + '-med', code: {}}; + if (medicationRequest.medicationCodeableConcept) { + medication.code = medicationRequest.medicationCodeableConcept; + } else if (medicationRequest.medicationReference) { + const reference = medicationRequest?.medicationReference; + medicationRequest?.contained?.every(e => { + if (e.resourceType + '/' + e.id === reference.reference) { + if (e.resourceType === 'Medication') { + console.log('Get Medication code from contained resource'); + medication.code = e.code; + } + } + }); + } + return medication; + } + const refreshEtasuBundle = () => { if (patient && selectedMedicationCard) { + const updatedMedication = createMedicationFromMedicationRequest(selectedMedicationCard); + setCheckedEtasuTime(Date.now()); - const params: Parameters = { + const params: any = { resourceType: 'Parameters', parameter: [ { @@ -243,7 +268,7 @@ function MedReqDropDown({ }, { name: 'medication', - resource: selectedMedicationCard + resource: updatedMedication } ] }; From 0961fe20313bbaa91afa7cc933ad06d7868acf2b Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Wed, 12 Jun 2024 15:20:07 -0400 Subject: [PATCH 2/3] Fix lint errors --- src/views/Patient/MedReqDropDown/MedReqDropDown.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx index 14df352..101fef5 100644 --- a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx +++ b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx @@ -23,7 +23,8 @@ import { Resource, MedicationDispense, Parameters, - GuidanceResponse + GuidanceResponse, + CodeableConcept } from 'fhir/r4'; import Client from 'fhirclient/lib/Client'; import { ReactElement, useEffect, useState } from 'react'; @@ -235,9 +236,9 @@ function MedReqDropDown({ interface Medication { resourceType: string, id: string, - code: any + code: CodeableConcept | undefined } - let medication: Medication = { resourceType: 'Medication', id: medicationRequest?.id + '-med', code: {}}; + const medication: Medication = { resourceType: 'Medication', id: medicationRequest?.id + '-med', code: {}}; if (medicationRequest.medicationCodeableConcept) { medication.code = medicationRequest.medicationCodeableConcept; } else if (medicationRequest.medicationReference) { @@ -259,7 +260,7 @@ function MedReqDropDown({ const updatedMedication = createMedicationFromMedicationRequest(selectedMedicationCard); setCheckedEtasuTime(Date.now()); - const params: any = { + const params = { resourceType: 'Parameters', parameter: [ { From bba15e8369b5ae3ebf23a3a5f82003acda943def Mon Sep 17 00:00:00 2001 From: Ariel Virgulto Date: Wed, 12 Jun 2024 15:22:16 -0400 Subject: [PATCH 3/3] Update prettier --- .../Patient/MedReqDropDown/MedReqDropDown.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx index 101fef5..2527312 100644 --- a/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx +++ b/src/views/Patient/MedReqDropDown/MedReqDropDown.tsx @@ -232,16 +232,20 @@ function MedReqDropDown({ ); }; - const createMedicationFromMedicationRequest = (medicationRequest: MedicationRequest) => { + const createMedicationFromMedicationRequest = (medicationRequest: MedicationRequest) => { interface Medication { - resourceType: string, - id: string, - code: CodeableConcept | undefined + resourceType: string; + id: string; + code: CodeableConcept | undefined; } - const medication: Medication = { resourceType: 'Medication', id: medicationRequest?.id + '-med', code: {}}; + const medication: Medication = { + resourceType: 'Medication', + id: medicationRequest?.id + '-med', + code: {} + }; if (medicationRequest.medicationCodeableConcept) { medication.code = medicationRequest.medicationCodeableConcept; - } else if (medicationRequest.medicationReference) { + } else if (medicationRequest.medicationReference) { const reference = medicationRequest?.medicationReference; medicationRequest?.contained?.every(e => { if (e.resourceType + '/' + e.id === reference.reference) { @@ -253,7 +257,7 @@ function MedReqDropDown({ }); } return medication; - } + }; const refreshEtasuBundle = () => { if (patient && selectedMedicationCard) {