use of org.hl7.fhir.r4.model.Medication in project gpconnect-demonstrator by nhsconnect.
the class MedicationDispenseResourceProvider method getMedicationDispensesForPatientId.
@Search
public List<MedicationDispense> getMedicationDispensesForPatientId(@RequiredParam(name = "patient") String patientId) {
ArrayList<MedicationDispense> medicationDispenses = new ArrayList<>();
List<MedicationDispenseDetail> medicationDispenseDetailList = medicationDispenseSearch.findMedicationDispenseForPatient(Long.parseLong(patientId));
if (medicationDispenseDetailList != null && !medicationDispenseDetailList.isEmpty()) {
for (MedicationDispenseDetail medicationDispenseDetail : medicationDispenseDetailList) {
MedicationDispense medicationDispense = new MedicationDispense();
medicationDispense.setId(String.valueOf(medicationDispenseDetail.getId()));
medicationDispense.getMeta().setLastUpdated(medicationDispenseDetail.getLastUpdated());
medicationDispense.getMeta().setVersionId(String.valueOf(medicationDispenseDetail.getLastUpdated().getTime()));
switch(medicationDispenseDetail.getStatus().toLowerCase(Locale.UK)) {
case "completed":
medicationDispense.setStatus(MedicationDispenseStatus.COMPLETED);
break;
case "entered_in_error":
medicationDispense.setStatus(MedicationDispenseStatus.ENTEREDINERROR);
break;
case "in_progress":
medicationDispense.setStatus(MedicationDispenseStatus.INPROGRESS);
break;
case "on_hold":
medicationDispense.setStatus(MedicationDispenseStatus.ONHOLD);
break;
case "stopped":
medicationDispense.setStatus(MedicationDispenseStatus.STOPPED);
break;
}
medicationDispense.setSubject(new Reference("Patient/" + patientId));
medicationDispense.setAuthorizingPrescription(Collections.singletonList(new Reference("MedicationOrder/" + medicationDispenseDetail.getMedicationOrderId())));
Medication medication = new Medication();
Coding coding = new Coding();
coding.setCode(String.valueOf(medicationDispenseDetail.getMedicationId()));
coding.setDisplay(medicationDispenseDetail.getMedicationName());
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.setCoding(Collections.singletonList(coding));
medication.setCode(codeableConcept);
medicationDispense.addDosageInstruction().setText(medicationDispenseDetail.getDosageText());
medicationDispenses.add(medicationDispense);
}
}
return medicationDispenses;
}
use of org.hl7.fhir.r4.model.Medication in project bunsen by cerner.
the class SparkRowConverterTest method testContainedResources.
@Test
public void testContainedResources() throws FHIRException {
Medication testMedicationOne = (Medication) testMedicationRequest.getContained().get(0);
String testMedicationOneId = testMedicationOne.getId();
CodeableConcept testMedicationIngredientItem = testMedicationOne.getIngredientFirstRep().getItemCodeableConcept();
Medication decodedMedicationOne = (Medication) testMedicationRequestDecoded.getContained().get(0);
String decodedMedicationOneId = decodedMedicationOne.getId();
CodeableConcept decodedMedicationOneIngredientItem = decodedMedicationOne.getIngredientFirstRep().getItemCodeableConcept();
Assert.assertEquals(testMedicationOneId, decodedMedicationOneId);
Assert.assertTrue(decodedMedicationOneIngredientItem.equalsDeep(testMedicationIngredientItem));
Provenance testProvenance = (Provenance) testMedicationRequest.getContained().get(1);
String testProvenanceId = testProvenance.getId();
Provenance decodedProvenance = (Provenance) testMedicationRequestDecoded.getContained().get(1);
String decodedProvenanceId = decodedProvenance.getId();
Assert.assertEquals(testProvenanceId, decodedProvenanceId);
Medication testMedicationTwo = (Medication) testMedicationRequest.getContained().get(2);
String testMedicationTwoId = testMedicationTwo.getId();
Medication decodedMedicationTwo = (Medication) testMedicationRequestDecoded.getContained().get(2);
String decodedMedicationTwoId = decodedMedicationTwo.getId();
Assert.assertEquals(testMedicationTwoId, decodedMedicationTwoId);
}
use of org.hl7.fhir.r4.model.Medication in project bunsen by cerner.
the class TestData method newMedRequest.
/**
* Returns a FHIR medication request for testing purposes.
*/
public static MedicationRequest newMedRequest() {
MedicationRequest medReq = new MedicationRequest();
medReq.setId("test-med");
// Medication code
CodeableConcept med = new CodeableConcept();
med.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("582620").setDisplay("Nizatidine 15 MG/ML Oral Solution [Axid]");
med.setText("Nizatidine 15 MG/ML Oral Solution [Axid]");
medReq.setMedication(med);
Annotation annotation = new Annotation();
annotation.setText("Test medication note.");
annotation.setAuthor(new Reference("Provider/example").setDisplay("Example provider."));
medReq.addNote(annotation);
return medReq;
}
use of org.hl7.fhir.r4.model.Medication in project bunsen by cerner.
the class TestData method newMedRequest.
/**
* Returns a FHIR medication request for testing purposes.
*/
public static MedicationRequest newMedRequest() {
MedicationRequest medReq = new MedicationRequest();
medReq.setId("test-med");
// Medication code
CodeableConcept med = new CodeableConcept();
med.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("582620").setDisplay("Nizatidine 15 MG/ML Oral Solution [Axid]");
med.setText("Nizatidine 15 MG/ML Oral Solution [Axid]");
medReq.setMedication(med);
Annotation annotation = new Annotation();
annotation.setText("Test medication note.");
annotation.setAuthor(new Reference("Provider/example").setDisplay("Example provider."));
medReq.addNote(annotation);
return medReq;
}
use of org.hl7.fhir.r4.model.Medication in project bunsen by cerner.
the class TestData method newMedication.
/**
* Returns a new Medication for testing.
*
* @return a FHIR Medication for testing.
*/
public static Medication newMedication(String id) {
Medication medication = new Medication();
medication.setId(id);
CodeableConcept itemCodeableConcept = new CodeableConcept();
itemCodeableConcept.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("103109").setDisplay("Vitamin E 3 MG Oral Tablet [Ephynal]").setUserSelected(true);
MedicationIngredientComponent ingredientComponent = new MedicationIngredientComponent();
ingredientComponent.setItem(itemCodeableConcept);
medication.addIngredient(ingredientComponent);
Reference itemReference = new Reference("test-item-reference");
MedicationPackageContentComponent medicationPackageContentComponent = new MedicationPackageContentComponent();
medicationPackageContentComponent.setItem(itemReference);
MedicationPackageComponent medicationPackageComponent = new MedicationPackageComponent();
medicationPackageComponent.addContent(medicationPackageContentComponent);
medication.setPackage(medicationPackageComponent);
return medication;
}
Aggregations