Search in sources :

Example 6 with MedicationOrder

use of org.hl7.fhir.dstu2.model.MedicationOrder 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 7 with MedicationOrder

use of org.hl7.fhir.dstu2.model.MedicationOrder in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeMedicationOrderMedicationOrderSubstitutionComponent.

protected void composeMedicationOrderMedicationOrderSubstitutionComponent(Complex parent, String parentType, String name, MedicationOrder.MedicationOrderSubstitutionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "substitution", name, element, index);
    if (element.hasType())
        composeCodeableConcept(t, "MedicationOrder", "type", element.getType(), -1);
    if (element.hasReason())
        composeCodeableConcept(t, "MedicationOrder", "reason", element.getReason(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 Search (ca.uhn.fhir.rest.annotation.Search)2 ArrayList (java.util.ArrayList)2 Reference (org.hl7.fhir.dstu3.model.Reference)2 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)1 StringDt (ca.uhn.fhir.model.primitive.StringDt)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 DateType (org.hl7.fhir.dstu3.model.DateType)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Medication (org.hl7.fhir.dstu3.model.Medication)1 MedicationAdministration (org.hl7.fhir.dstu3.model.MedicationAdministration)1 MedicationDispense (org.hl7.fhir.dstu3.model.MedicationDispense)1 MedicationRequestDispenseRequestComponent (org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent)1 MedicationAdministrationSearch (uk.gov.hscic.medication.administration.MedicationAdministrationSearch)1 MedicationDispenseSearch (uk.gov.hscic.medication.dispense.MedicationDispenseSearch)1 MedicationAdministrationDetail (uk.gov.hscic.model.medication.MedicationAdministrationDetail)1 MedicationDispenseDetail (uk.gov.hscic.model.medication.MedicationDispenseDetail)1