Search in sources :

Example 1 with MedicationDispenseDetail

use of uk.gov.hscic.model.medication.MedicationDispenseDetail in project gpconnect-demonstrator by nhsconnect.

the class MedicationDispenseEntityToMedicationDispenseDetailTransformer method transform.

@Override
public MedicationDispenseDetail transform(MedicationDispenseEntity item) {
    MedicationDispenseDetail dispenseDetail = new MedicationDispenseDetail();
    dispenseDetail.setId(item.getId());
    dispenseDetail.setStatus(item.getStatus());
    dispenseDetail.setPatientId(item.getPatientId());
    dispenseDetail.setMedicationOrderId(item.getMedicationOrderId());
    dispenseDetail.setMedicationId(item.getMedicationId());
    dispenseDetail.setMedicationName(item.getMedicationName());
    dispenseDetail.setDosageText(item.getDosageText());
    dispenseDetail.setLastUpdated(item.getLastUpdated());
    return dispenseDetail;
}
Also used : MedicationDispenseDetail(uk.gov.hscic.model.medication.MedicationDispenseDetail)

Example 2 with MedicationDispenseDetail

use of uk.gov.hscic.model.medication.MedicationDispenseDetail 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)

Aggregations

MedicationDispenseDetail (uk.gov.hscic.model.medication.MedicationDispenseDetail)2 Search (ca.uhn.fhir.rest.annotation.Search)1 ArrayList (java.util.ArrayList)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 Medication (org.hl7.fhir.dstu3.model.Medication)1 MedicationDispense (org.hl7.fhir.dstu3.model.MedicationDispense)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 MedicationDispenseSearch (uk.gov.hscic.medication.dispense.MedicationDispenseSearch)1