use of org.hl7.fhir.dstu3.model.Dosage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationMapperUtils method buildDosage.
public static Dosage buildDosage(List<RCMRMT030101UK04PertinentInformation> pertinentInformationList) {
Dosage dosage = new Dosage();
var pertinentInformationDosage = pertinentInformationList.stream().filter(RCMRMT030101UK04PertinentInformation::hasPertinentMedicationDosage).map(RCMRMT030101UK04PertinentInformation::getPertinentMedicationDosage).filter(RCMRMT030101UK04MedicationDosage::hasText).map(RCMRMT030101UK04MedicationDosage::getText).findFirst();
pertinentInformationDosage.ifPresentOrElse(dosage::setText, () -> dosage.setText(NO_INFORMATION_AVAILABLE));
return dosage;
}
use of org.hl7.fhir.dstu3.model.Dosage in project gpconnect-demonstrator by nhsconnect.
the class MedicationRequestResourceProvider method getMedicationRequestFromDetail.
private MedicationRequest getMedicationRequestFromDetail(MedicationRequestDetail requestDetail) {
MedicationRequest medicationRequest = new MedicationRequest();
medicationRequest.setId(requestDetail.getId().toString());
List<Identifier> identifiers = new ArrayList<>();
Identifier identifier = new Identifier().setSystem("https://fhir.nhs.uk/Id/cross-care-setting-identifier").setValue(requestDetail.getGuid());
identifiers.add(identifier);
medicationRequest.setIdentifier(identifiers);
medicationRequest.setMeta(new Meta().addProfile(SystemURL.SD_GPC_MEDICATION_REQUEST));
setBasedOnReferences(medicationRequest, requestDetail);
if (requestDetail.getPrescriptionTypeCode().contains("repeat")) {
medicationRequest.setGroupIdentifier(new Identifier().setValue(requestDetail.getGroupIdentifier()));
}
try {
medicationRequest.setStatus(MedicationRequestStatus.fromCode(requestDetail.getStatusCode()));
} catch (FHIRException e) {
throw new UnprocessableEntityException(e.getMessage());
}
try {
medicationRequest.setIntent(MedicationRequestIntent.fromCode(requestDetail.getIntentCode()));
} catch (FHIRException e) {
throw new UnprocessableEntityException(e.getMessage());
}
if (requestDetail.getMedicationId() != null) {
medicationRequest.setMedication(new Reference(new IdType("Medication", requestDetail.getMedicationId())));
}
if (requestDetail.getPatientId() != null) {
medicationRequest.setSubject(new Reference(new IdType("Patient", requestDetail.getPatientId())));
}
if (requestDetail.getAuthorisingPractitionerId() != null) {
medicationRequest.setRecorder(new Reference(new IdType("Practitioner", requestDetail.getAuthorisingPractitionerId())));
}
if (requestDetail.getPriorMedicationRequestId() != null) {
medicationRequest.setPriorPrescription(new Reference(new IdType("MedicationRequest", requestDetail.getPriorMedicationRequestId())));
}
medicationRequest.setAuthoredOn(requestDetail.getAuthoredOn());
medicationRequest.setDispenseRequest(getDispenseRequestComponent(requestDetail));
// medicationRequest.setRequester(getRequesterComponent(requestDetail)); //TODO - spec needs to clarify whether this should be populated or not
setReasonCodes(medicationRequest, requestDetail);
setNotes(medicationRequest, requestDetail);
if (medicationRequest.getIntent() != MedicationRequestIntent.ORDER) {
setRepeatInformation(medicationRequest, requestDetail);
}
setPrescriptionType(medicationRequest, requestDetail);
setStatusReason(medicationRequest, requestDetail);
String dosageInstructionText = requestDetail.getDosageText();
medicationRequest.addDosageInstruction(new Dosage().setText(dosageInstructionText == null || dosageInstructionText.trim().isEmpty() ? NO_INFORMATION_AVAILABLE : dosageInstructionText).setPatientInstruction(requestDetail.getDosageInstructions()));
return medicationRequest;
}
use of org.hl7.fhir.dstu3.model.Dosage in project bunsen by cerner.
the class TestData method newMedicationRequest.
/**
* Returns a new MedicationRequest for testing.
*
* @return a FHIR MedicationRequest for testing.
*/
public static MedicationRequest newMedicationRequest() {
MedicationRequest medicationRequest = new MedicationRequest();
medicationRequest.setId("test-medication-request");
CodeableConcept itemCodeableConcept = new CodeableConcept();
itemCodeableConcept.addCoding().setSystem("http://www.nlm.nih.gov/research/umls/rxnorm").setCode("103109").setDisplay("Vitamin E 3 MG Oral Tablet [Ephynal]").setUserSelected(true);
medicationRequest.setMedication(itemCodeableConcept);
medicationRequest.setSubject(new Reference("Patient/12345").setDisplay("Here is a display for you."));
medicationRequest.setDosageInstruction(ImmutableList.of(new Dosage().setTiming(new Timing().setRepeat(new TimingRepeatComponent().setCount(10)))));
medicationRequest.setSubstitution(new MedicationRequestSubstitutionComponent().setAllowed(true));
return medicationRequest;
}
use of org.hl7.fhir.dstu3.model.Dosage in project synthea by synthetichealth.
the class FhirR4 method medicationAdministration.
/**
* Add a MedicationAdministration if needed for the given medication.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Entry for the Person
* @param bundle Bundle to add the MedicationAdministration to
* @param encounterEntry Current Encounter entry
* @param medication The Medication
* @param medicationRequest The related medicationRequest
* @return The added Entry
*/
private static BundleEntryComponent medicationAdministration(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Medication medication, MedicationRequest medicationRequest) {
MedicationAdministration medicationResource = new MedicationAdministration();
medicationResource.setSubject(new Reference(personEntry.getFullUrl()));
medicationResource.setContext(new Reference(encounterEntry.getFullUrl()));
Code code = medication.codes.get(0);
String system = code.system.equals("SNOMED-CT") ? SNOMED_URI : RXNORM_URI;
medicationResource.setMedication(mapCodeToCodeableConcept(code, system));
medicationResource.setEffective(new DateTimeType(new Date(medication.start)));
medicationResource.setStatus(MedicationAdministration.MedicationAdministrationStatus.COMPLETED);
if (medication.prescriptionDetails != null) {
JsonObject rxInfo = medication.prescriptionDetails;
MedicationAdministrationDosageComponent dosage = new MedicationAdministrationDosageComponent();
// as_needed is false
if ((rxInfo.has("dosage")) && (!rxInfo.has("as_needed"))) {
Quantity dose = new SimpleQuantity().setValue(rxInfo.get("dosage").getAsJsonObject().get("amount").getAsDouble());
dosage.setDose((SimpleQuantity) dose);
if (rxInfo.has("instructions")) {
for (JsonElement instructionElement : rxInfo.get("instructions").getAsJsonArray()) {
JsonObject instruction = instructionElement.getAsJsonObject();
dosage.setText(instruction.get("display").getAsString());
}
}
}
if (rxInfo.has("refills")) {
SimpleQuantity rate = new SimpleQuantity();
rate.setValue(rxInfo.get("refills").getAsLong());
dosage.setRate(rate);
}
medicationResource.setDosage(dosage);
}
if (!medication.reasons.isEmpty()) {
// Only one element in list
Code reason = medication.reasons.get(0);
for (BundleEntryComponent entry : bundle.getEntry()) {
if (entry.getResource().fhirType().equals("Condition")) {
Condition condition = (Condition) entry.getResource();
// Only one element in list
Coding coding = condition.getCode().getCoding().get(0);
if (reason.code.equals(coding.getCode())) {
medicationResource.addReasonReference().setReference(entry.getFullUrl());
}
}
}
}
BundleEntryComponent medicationAdminEntry = newEntry(rand, bundle, medicationResource);
return medicationAdminEntry;
}
use of org.hl7.fhir.dstu3.model.Dosage in project gpconnect-demonstrator by nhsconnect.
the class MedicationStatementResourceProvider method getMedicationStatementResource.
public MedicationStatement getMedicationStatementResource(MedicationStatementDetail statementDetail) {
MedicationStatement medicationStatement = new MedicationStatement();
medicationStatement.setId(statementDetail.getId().toString());
List<Identifier> identifiers = new ArrayList<>();
Identifier identifier = new Identifier().setSystem("https://fhir.nhs.uk/Id/cross-care-setting-identifier").setValue(statementDetail.getGuid());
identifiers.add(identifier);
medicationStatement.setIdentifier(identifiers);
medicationStatement.setMeta(new Meta().addProfile(SystemURL.SD_GPC_MEDICATION_STATEMENT));
medicationStatement.addExtension(new Extension(SystemURL.SD_CC_EXT_MEDICATION_STATEMENT_LAST_ISSUE, new DateTimeType(statementDetail.getLastIssueDate(), TemporalPrecisionEnum.DAY)));
if (statementDetail.getMedicationRequestPlanId() != null) {
medicationStatement.addBasedOn(new Reference(new IdType("MedicationRequest", statementDetail.getMedicationRequestPlanId())));
}
try {
medicationStatement.setStatus(MedicationStatementStatus.fromCode(statementDetail.getStatusCode()));
} catch (FHIRException e) {
throw new UnprocessableEntityException(e.getMessage());
}
if (statementDetail.getMedicationId() != null) {
medicationStatement.setMedication(new Reference(new IdType("Medication", statementDetail.getMedicationId())));
}
medicationStatement.setEffective(new Period().setStart(statementDetail.getStartDate()).setEnd(statementDetail.getEndDate()));
medicationStatement.setDateAsserted(statementDetail.getDateAsserted());
if (statementDetail.getPatientId() != null)
medicationStatement.setSubject(new Reference(new IdType("Patient", statementDetail.getPatientId())));
try {
medicationStatement.setTaken(statementDetail.getTakenCode() != null ? MedicationStatementTaken.fromCode(statementDetail.getTakenCode()) : MedicationStatementTaken.UNK);
} catch (FHIRException e) {
throw new UnprocessableEntityException(e.getMessage());
}
setReasonCodes(medicationStatement, statementDetail);
setNotes(medicationStatement, statementDetail);
String dosageText = statementDetail.getDosageText();
medicationStatement.addDosage(new Dosage().setText(dosageText == null || dosageText.trim().isEmpty() ? NO_INFORMATION_AVAILABLE : dosageText).setPatientInstruction(statementDetail.getDosagePatientInstruction()));
String prescribingAgency = statementDetail.getPrescribingAgency();
if (prescribingAgency != null && !prescribingAgency.trim().isEmpty()) {
String prescribingAgencyDisplay = "";
if (prescribingAgency.equalsIgnoreCase("prescribed-at-gp-practice")) {
prescribingAgencyDisplay = "Prescribed at GP practice";
} else if (prescribingAgency.equalsIgnoreCase("prescribed-by-another-organisation")) {
prescribingAgencyDisplay = "Prescribed by another organisation";
}
Coding coding = new Coding(SystemURL.CS_CC_PRESCRIBING_AGENCY_STU3, prescribingAgency, prescribingAgencyDisplay);
CodeableConcept codeableConcept = new CodeableConcept().addCoding(coding);
medicationStatement.addExtension(new Extension(SystemURL.SD_EXTENSION_CC_PRESCRIBING_AGENCY, codeableConcept));
}
// #281 1.2.5 add dosageLastChanged
Date dosageLastChanged = statementDetail.getDosageLastChanged();
if (dosageLastChanged != null) {
medicationStatement.addExtension(new Extension(SystemURL.SD_EXTENSION_CC_DOSAGE_LAST_CHANGED, new DateTimeType(dosageLastChanged)));
}
return medicationStatement;
}
Aggregations