Skip to content

Commit

Permalink
Merge pull request #100 from mcode/689-etasu-call
Browse files Browse the repository at this point in the history
689 etasu call
  • Loading branch information
plarocque4 authored Jun 13, 2024
2 parents 3c29e8e + bba15e8 commit de26f86
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/views/Patient/MedReqDropDown/MedReqDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -231,10 +232,39 @@ function MedReqDropDown({
);
};

const createMedicationFromMedicationRequest = (medicationRequest: MedicationRequest) => {
interface Medication {
resourceType: string;
id: string;
code: CodeableConcept | undefined;
}
const 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 = {
resourceType: 'Parameters',
parameter: [
{
Expand All @@ -243,7 +273,7 @@ function MedReqDropDown({
},
{
name: 'medication',
resource: selectedMedicationCard
resource: updatedMedication
}
]
};
Expand Down

0 comments on commit de26f86

Please sign in to comment.