Search in sources :

Example 96 with Medication

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;
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) MedicationDispense(org.hl7.fhir.dstu3.model.MedicationDispense) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Medication(org.hl7.fhir.dstu3.model.Medication) MedicationDispenseDetail(uk.gov.hscic.model.medication.MedicationDispenseDetail) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) MedicationDispenseSearch(uk.gov.hscic.medication.dispense.MedicationDispenseSearch) Search(ca.uhn.fhir.rest.annotation.Search)

Example 97 with Medication

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);
}
Also used : Provenance(org.hl7.fhir.dstu3.model.Provenance) Medication(org.hl7.fhir.dstu3.model.Medication) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Test(org.junit.Test)

Example 98 with Medication

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;
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Reference(org.hl7.fhir.r4.model.Reference) Annotation(org.hl7.fhir.r4.model.Annotation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 99 with Medication

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;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Reference(org.hl7.fhir.dstu3.model.Reference) Annotation(org.hl7.fhir.dstu3.model.Annotation) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 100 with Medication

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;
}
Also used : MedicationIngredientComponent(org.hl7.fhir.dstu3.model.Medication.MedicationIngredientComponent) MedicationPackageContentComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageContentComponent) Reference(org.hl7.fhir.dstu3.model.Reference) MedicationPackageComponent(org.hl7.fhir.dstu3.model.Medication.MedicationPackageComponent) Medication(org.hl7.fhir.dstu3.model.Medication) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

Test (org.junit.Test)112 Medication (org.hl7.fhir.r4.model.Medication)62 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)43 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)34 Medication (org.hl7.fhir.dstu3.model.Medication)33 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)30 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)24 TokenParam (ca.uhn.fhir.rest.param.TokenParam)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)20 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)19 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)18 InputStream (java.io.InputStream)17 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)14 Coding (org.hl7.fhir.r4.model.Coding)14 Date (java.util.Date)13 ArrayList (java.util.ArrayList)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)11