use of org.hl7.v3.RCMRMT030101UK04Authorise in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationRequestPlanMapper method mapToPlanMedicationRequest.
public MedicationRequest mapToPlanMedicationRequest(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04MedicationStatement medicationStatement, RCMRMT030101UK04Authorise supplyAuthorise, String practiseCode) {
var ehrSupplyAuthoriseIdExtract = extractEhrSupplyAuthoriseId(supplyAuthorise);
if (ehrSupplyAuthoriseIdExtract.isPresent()) {
var ehrSupplyAuthoriseId = ehrSupplyAuthoriseIdExtract.get();
var discontinue = extractMatchingDiscontinue(ehrSupplyAuthoriseId, ehrExtract);
MedicationRequest medicationRequest = createMedicationRequestSkeleton(ehrSupplyAuthoriseId);
medicationRequest.addIdentifier(buildIdentifier(ehrSupplyAuthoriseId, practiseCode));
medicationRequest.setStatus(buildMedicationRequestStatus(supplyAuthorise));
medicationRequest.setIntent(PLAN);
medicationRequest.addDosageInstruction(buildDosage(medicationStatement.getPertinentInformation()));
medicationRequest.setDispenseRequest(buildDispenseRequestForAuthorise(supplyAuthorise, medicationStatement));
List<Extension> repeatInformationExtensions = new ArrayList<>();
extractSupplyAuthoriseRepeatInformation(supplyAuthorise).ifPresent(repeatInformationExtensions::add);
extractRepeatInformationIssued(ehrExtract, supplyAuthorise, ehrSupplyAuthoriseId).ifPresent(repeatInformationExtensions::add);
extractAuthorisationExpiryDate(supplyAuthorise).ifPresent(repeatInformationExtensions::add);
buildCondensedExtensions(REPEAT_INFORMATION_URL, repeatInformationExtensions).ifPresent(medicationRequest::addExtension);
List<Extension> statusChangeExtensions = new ArrayList<>();
discontinue.map(this::buildStatusChangeDateExtension).ifPresent(statusChangeExtensions::add);
discontinue.map(this::extractTermText).map(this::buildStatusReasonCodeableConceptExtension).ifPresent(statusChangeExtensions::add);
buildCondensedExtensions(STATUS_CHANGE_URL, statusChangeExtensions).ifPresent(medicationRequest::addExtension);
buildPrescriptionTypeExtension(supplyAuthorise).ifPresent(medicationRequest::addExtension);
buildNotesForAuthorise(supplyAuthorise).forEach(medicationRequest::addNote);
extractPriorPrescription(supplyAuthorise).ifPresent(medicationRequest::setPriorPrescription);
medicationMapper.extractMedicationReference(medicationStatement).ifPresent(medicationRequest::setMedication);
return medicationRequest;
}
return null;
}
use of org.hl7.v3.RCMRMT030101UK04Authorise in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationStatementMapper method mapToMedicationStatement.
public MedicationStatement mapToMedicationStatement(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04MedicationStatement medicationStatement, RCMRMT030101UK04Authorise supplyAuthorise, String practiseCode, DateTimeType authoredOn) {
var ehrSupplyAuthoriseIdExtract = extractEhrSupplyAuthoriseId(supplyAuthorise);
if (ehrSupplyAuthoriseIdExtract.isPresent()) {
String ehrSupplyAuthoriseId = ehrSupplyAuthoriseIdExtract.get();
MedicationStatement medicationStatement1 = new MedicationStatement();
medicationStatement1.setId(ehrSupplyAuthoriseId + MS_SUFFIX);
medicationStatement1.setMeta(generateMeta(MEDICATION_STATEMENT_URL));
medicationStatement1.addIdentifier(buildIdentifier(ehrSupplyAuthoriseId + MS_SUFFIX, practiseCode));
medicationStatement1.setTaken(UNK);
medicationStatement1.addBasedOn(new Reference(new IdType(ResourceType.MedicationRequest.name(), ehrSupplyAuthoriseId)));
medicationStatement1.addExtension(generatePrescribingAgencyExtension());
medicationStatement1.setStatus(buildMedicationStatementStatus(supplyAuthorise));
medicationStatement1.addDosage(buildDosage(medicationStatement.getPertinentInformation()));
extractHighestSupplyPrescribeTime(ehrExtract, ehrSupplyAuthoriseId).map(dateTime -> new Extension(MS_LAST_ISSUE_DATE, dateTime)).ifPresent(medicationStatement1::addExtension);
medicationMapper.extractMedicationReference(medicationStatement).ifPresent(medicationStatement1::setMedication);
MedicationMapperUtils.extractDispenseRequestPeriodStart(supplyAuthorise).ifPresentOrElse(dateTimeType -> {
medicationStatement1.setEffective(buildDispenseRequestPeriodEnd(supplyAuthorise, medicationStatement).setStartElement(dateTimeType));
}, () -> {
medicationStatement1.setEffective(buildDispenseRequestPeriodEnd(supplyAuthorise, medicationStatement).setStartElement(authoredOn));
});
return medicationStatement1;
}
return null;
}
Aggregations