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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations