Search in sources :

Example 1 with MedicationOrder

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

the class RdfParser method composeMedicationOrderMedicationOrderDosageInstructionComponent.

protected void composeMedicationOrderMedicationOrderDosageInstructionComponent(Complex parent, String parentType, String name, MedicationOrder.MedicationOrderDosageInstructionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "dosageInstruction", name, element, index);
    if (element.hasTextElement())
        composeString(t, "MedicationOrder", "text", element.getTextElement(), -1);
    if (element.hasAdditionalInstructions())
        composeCodeableConcept(t, "MedicationOrder", "additionalInstructions", element.getAdditionalInstructions(), -1);
    if (element.hasTiming())
        composeTiming(t, "MedicationOrder", "timing", element.getTiming(), -1);
    if (element.hasAsNeeded())
        composeType(t, "MedicationOrder", "asNeeded", element.getAsNeeded(), -1);
    if (element.hasSite())
        composeType(t, "MedicationOrder", "site", element.getSite(), -1);
    if (element.hasRoute())
        composeCodeableConcept(t, "MedicationOrder", "route", element.getRoute(), -1);
    if (element.hasMethod())
        composeCodeableConcept(t, "MedicationOrder", "method", element.getMethod(), -1);
    if (element.hasDose())
        composeType(t, "MedicationOrder", "dose", element.getDose(), -1);
    if (element.hasRate())
        composeType(t, "MedicationOrder", "rate", element.getRate(), -1);
    if (element.hasMaxDosePerPeriod())
        composeRatio(t, "MedicationOrder", "maxDosePerPeriod", element.getMaxDosePerPeriod(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 2 with MedicationOrder

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

the class RdfParser method composeMedicationOrderMedicationOrderDispenseRequestComponent.

protected void composeMedicationOrderMedicationOrderDispenseRequestComponent(Complex parent, String parentType, String name, MedicationOrder.MedicationOrderDispenseRequestComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "dispenseRequest", name, element, index);
    if (element.hasMedication())
        composeType(t, "MedicationOrder", "medication", element.getMedication(), -1);
    if (element.hasValidityPeriod())
        composePeriod(t, "MedicationOrder", "validityPeriod", element.getValidityPeriod(), -1);
    if (element.hasNumberOfRepeatsAllowedElement())
        composePositiveInt(t, "MedicationOrder", "numberOfRepeatsAllowed", element.getNumberOfRepeatsAllowedElement(), -1);
    if (element.hasQuantity())
        composeQuantity(t, "MedicationOrder", "quantity", element.getQuantity(), -1);
    if (element.hasExpectedSupplyDuration())
        composeQuantity(t, "MedicationOrder", "expectedSupplyDuration", element.getExpectedSupplyDuration(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 3 with MedicationOrder

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

the class RdfParser method composeMedicationOrder.

protected void composeMedicationOrder(Complex parent, String parentType, String name, MedicationOrder element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "MedicationOrder", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "MedicationOrder", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "MedicationOrder", "status", element.getStatusElement(), -1);
    if (element.hasMedication())
        composeType(t, "MedicationOrder", "medication", element.getMedication(), -1);
    if (element.hasPatient())
        composeReference(t, "MedicationOrder", "patient", element.getPatient(), -1);
    if (element.hasEncounter())
        composeReference(t, "MedicationOrder", "encounter", element.getEncounter(), -1);
    if (element.hasDateWrittenElement())
        composeDateTime(t, "MedicationOrder", "dateWritten", element.getDateWrittenElement(), -1);
    if (element.hasPrescriber())
        composeReference(t, "MedicationOrder", "prescriber", element.getPrescriber(), -1);
    for (int i = 0; i < element.getReasonCode().size(); i++) composeCodeableConcept(t, "MedicationOrder", "reasonCode", element.getReasonCode().get(i), i);
    for (int i = 0; i < element.getReasonReference().size(); i++) composeReference(t, "MedicationOrder", "reasonReference", element.getReasonReference().get(i), i);
    if (element.hasDateEndedElement())
        composeDateTime(t, "MedicationOrder", "dateEnded", element.getDateEndedElement(), -1);
    if (element.hasReasonEnded())
        composeCodeableConcept(t, "MedicationOrder", "reasonEnded", element.getReasonEnded(), -1);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "MedicationOrder", "note", element.getNote().get(i), i);
    for (int i = 0; i < element.getDosageInstruction().size(); i++) composeMedicationOrderMedicationOrderDosageInstructionComponent(t, "MedicationOrder", "dosageInstruction", element.getDosageInstruction().get(i), i);
    if (element.hasDispenseRequest())
        composeMedicationOrderMedicationOrderDispenseRequestComponent(t, "MedicationOrder", "dispenseRequest", element.getDispenseRequest(), -1);
    if (element.hasSubstitution())
        composeMedicationOrderMedicationOrderSubstitutionComponent(t, "MedicationOrder", "substitution", element.getSubstitution(), -1);
    if (element.hasPriorPrescription())
        composeReference(t, "MedicationOrder", "priorPrescription", element.getPriorPrescription(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 4 with MedicationOrder

use of org.hl7.fhir.dstu2.model.MedicationOrder in project gpconnect-demonstrator by nhsconnect.

the class MedicationAdministrationResourceProvider method getMedicationAdministrationsForPatientId.

@Search
public List<MedicationAdministration> getMedicationAdministrationsForPatientId(@RequiredParam(name = "patient") String patientId) {
    ArrayList<MedicationAdministration> medicationAdministrations = new ArrayList<>();
    List<MedicationAdministrationDetail> medicationAdministrationDetailList = medicationAdministrationSearch.findMedicationAdministrationForPatient(Long.parseLong(patientId));
    if (medicationAdministrationDetailList != null && !medicationAdministrationDetailList.isEmpty()) {
        for (MedicationAdministrationDetail medicationAdministrationDetail : medicationAdministrationDetailList) {
            MedicationAdministration medicationAdministration = new MedicationAdministration();
            String resourceId = String.valueOf(medicationAdministrationDetail.getId());
            String versionId = String.valueOf(medicationAdministrationDetail.getLastUpdated().getTime());
            String resourceType = medicationAdministration.getResourceType().toString();
            IdType id = new IdType(resourceType, resourceId, versionId);
            medicationAdministration.setId(id);
            medicationAdministration.getMeta().setVersionId(versionId);
            medicationAdministration.getMeta().setLastUpdated(medicationAdministrationDetail.getLastUpdated());
            medicationAdministration.addDefinition(new Reference("Patient/" + medicationAdministrationDetail.getPatientId()));
            medicationAdministration.addDefinition(new Reference("Practitioner/" + medicationAdministrationDetail.getPractitionerId()));
            medicationAdministration.setPrescription(new Reference("MedicationOrder/" + medicationAdministrationDetail.getPrescriptionId()));
            medicationAdministration.setEffective(new DateType(medicationAdministrationDetail.getAdministrationDate()));
            medicationAdministration.setMedication(new Reference("Medication/" + medicationAdministrationDetail.getMedicationId()));
            medicationAdministrations.add(medicationAdministration);
        }
    }
    return medicationAdministrations;
}
Also used : MedicationAdministrationDetail(uk.gov.hscic.model.medication.MedicationAdministrationDetail) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) MedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration) DateType(org.hl7.fhir.dstu3.model.DateType) IdType(org.hl7.fhir.dstu3.model.IdType) Search(ca.uhn.fhir.rest.annotation.Search) MedicationAdministrationSearch(uk.gov.hscic.medication.administration.MedicationAdministrationSearch)

Example 5 with MedicationOrder

use of org.hl7.fhir.dstu2.model.MedicationOrder in project gpconnect-demonstrator by nhsconnect.

the class MedicationOrderResourceProvider method medicationOrderDetailsToMedicationOrderResourceConverter.

private MedicationRequest medicationOrderDetailsToMedicationOrderResourceConverter(MedicationOrderDetails medicationOrderDetails) {
    MedicationRequest medicationOrder = new MedicationRequest();
    String resourceId = String.valueOf(medicationOrderDetails.getId());
    String versionId = String.valueOf(medicationOrderDetails.getLastUpdated().getTime());
    String resourceType = medicationOrder.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    medicationOrder.setId(id);
    medicationOrder.getMeta().setVersionId(versionId);
    medicationOrder.getMeta().setLastUpdated(medicationOrderDetails.getLastUpdated());
    switch(medicationOrderDetails.getOrderStatus().toLowerCase(Locale.UK)) {
        case "active":
            medicationOrder.setStatus(MedicationRequestStatus.ACTIVE);
            break;
        case "completed":
            medicationOrder.setStatus(MedicationRequestStatus.COMPLETED);
            break;
        case "draft":
            medicationOrder.setStatus(MedicationRequestStatus.DRAFT);
            break;
        case "entered_in_error":
            medicationOrder.setStatus(MedicationRequestStatus.ENTEREDINERROR);
            break;
        case "on_hold":
            medicationOrder.setStatus(MedicationRequestStatus.ONHOLD);
            break;
        case "stopped":
            medicationOrder.setStatus(MedicationRequestStatus.STOPPED);
            break;
    }
    if (medicationOrderDetails.getPatientId() != null) {
        medicationOrder.setSubject(new Reference("Patient/" + medicationOrderDetails.getPatientId()));
    } else {
        medicationOrder.setSubject(new Reference());
    }
    medicationOrder.setRecorder(new Reference("Practitioner/" + medicationOrderDetails.getAutherId()));
    medicationOrder.setMedication(new Reference("Medication/" + medicationOrderDetails.getMedicationId()));
    medicationOrder.addDosageInstruction().setText(medicationOrderDetails.getDosageText());
    MedicationRequestDispenseRequestComponent dispenseRequest = new MedicationRequestDispenseRequestComponent();
    dispenseRequest.addExtension(new Extension(SystemURL.SD_EXTENSION_MEDICATION_QUANTITY_TEXT, new StringDt(medicationOrderDetails.getDispenseQuantityText())));
    dispenseRequest.addExtension(new Extension(SystemURL.SD_EXTENSION_PERSCRIPTION_REPEAT_REVIEW_DATE, new DateTimeDt(medicationOrderDetails.getDispenseReviewDate())));
    dispenseRequest.setId("Medication/" + medicationOrderDetails.getDispenseMedicationId());
    dispenseRequest.setNumberOfRepeatsAllowed(medicationOrderDetails.getDispenseRepeatsAllowed());
    medicationOrder.setDispenseRequest(dispenseRequest);
    return medicationOrder;
}
Also used : DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) MedicationRequestDispenseRequestComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent) StringDt(ca.uhn.fhir.model.primitive.StringDt)

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