use of org.hl7.v3.RCMRMT030101UK04Prescribe in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationRequestOrderMapper method mapToOrderMedicationRequest.
public MedicationRequest mapToOrderMedicationRequest(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04MedicationStatement medicationStatement, RCMRMT030101UK04Prescribe supplyPrescribe, String practiseCode) {
var ehrSupplyPrescribeIdExtract = extractEhrSupplyPrescribeId(supplyPrescribe);
var inFulfillmentOfId = extractInFulfillmentOfId(supplyPrescribe);
if (ehrSupplyPrescribeIdExtract.isPresent()) {
var ehrSupplyPrescribeId = ehrSupplyPrescribeIdExtract.get();
MedicationRequest medicationRequest = createMedicationRequestSkeleton(ehrSupplyPrescribeId);
medicationRequest.addIdentifier(buildIdentifier(ehrSupplyPrescribeId, practiseCode));
medicationRequest.setStatus(COMPLETED);
medicationRequest.setIntent(ORDER);
medicationRequest.addDosageInstruction(buildDosage(medicationStatement.getPertinentInformation()));
medicationRequest.setDispenseRequest(buildDispenseRequestForPrescribe(supplyPrescribe));
buildNotesForPrescribe(supplyPrescribe).forEach(medicationRequest::addNote);
medicationMapper.extractMedicationReference(medicationStatement).ifPresent(medicationRequest::setMedication);
inFulfillmentOfId.ifPresent(inFulfillmentId -> {
var supplyAuthorise = extractSupplyAuthorise(ehrExtract, inFulfillmentId);
buildPrescriptionTypeExtension(supplyAuthorise).ifPresent(medicationRequest::addExtension);
medicationRequest.addBasedOn(buildMedicationRequestReference(inFulfillmentId));
});
return medicationRequest;
}
return null;
}
Aggregations