Merge pull request #325 from ItayGoren/converting-medication-request
Converting medication request
This commit is contained in:
commit
2a6e148089
|
@ -37,6 +37,7 @@ import org.hl7.fhir.convertors.conv10_40.ImplementationGuide10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.List10_40;
|
import org.hl7.fhir.convertors.conv10_40.List10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.Location10_40;
|
import org.hl7.fhir.convertors.conv10_40.Location10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.MedicationDispense10_40;
|
import org.hl7.fhir.convertors.conv10_40.MedicationDispense10_40;
|
||||||
|
import org.hl7.fhir.convertors.conv10_40.MedicationRequest10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.MedicationStatement10_40;
|
import org.hl7.fhir.convertors.conv10_40.MedicationStatement10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.MessageHeader10_40;
|
import org.hl7.fhir.convertors.conv10_40.MessageHeader10_40;
|
||||||
import org.hl7.fhir.convertors.conv10_40.NamingSystem10_40;
|
import org.hl7.fhir.convertors.conv10_40.NamingSystem10_40;
|
||||||
|
@ -3239,6 +3240,8 @@ public class VersionConvertor_10_40 {
|
||||||
return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src);
|
return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src);
|
||||||
if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement)
|
if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement)
|
||||||
return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src);
|
return MedicationStatement10_40.convertMedicationStatement((org.hl7.fhir.dstu2.model.MedicationStatement) src);
|
||||||
|
if (src instanceof org.hl7.fhir.dstu2.model.MedicationOrder)
|
||||||
|
return MedicationRequest10_40.convertMedicationRequest((org.hl7.fhir.dstu2.model.MedicationOrder) src);
|
||||||
if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader)
|
if (src instanceof org.hl7.fhir.dstu2.model.MessageHeader)
|
||||||
return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src);
|
return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src);
|
||||||
if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem)
|
if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem)
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package org.hl7.fhir.convertors.conv10_40;
|
||||||
|
|
||||||
|
import org.hl7.fhir.convertors.VersionConvertor_10_40;
|
||||||
|
import org.hl7.fhir.dstu2.model.MedicationOrder;
|
||||||
|
import org.hl7.fhir.dstu3.model.MedicationRequest;
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r4.model.Dosage;
|
||||||
|
|
||||||
|
public class MedicationRequest10_40 {
|
||||||
|
public static org.hl7.fhir.r4.model.MedicationRequest convertMedicationRequest(org.hl7.fhir.dstu2.model.MedicationOrder src) throws FHIRException {
|
||||||
|
if (src == null)
|
||||||
|
return null;
|
||||||
|
org.hl7.fhir.r4.model.MedicationRequest tgt = new org.hl7.fhir.r4.model.MedicationRequest();
|
||||||
|
VersionConvertor_10_40.copyDomainResource(src, tgt);
|
||||||
|
tgt.setIntent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent.ORDER);
|
||||||
|
for (org.hl7.fhir.dstu2.model.Identifier identifier : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(identifier));
|
||||||
|
if (src.hasDateWritten())
|
||||||
|
tgt.setAuthoredOn(src.getDateWritten());
|
||||||
|
if (src.hasStatus())
|
||||||
|
tgt.setStatus(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus.fromCode(src.getStatus().toCode()));
|
||||||
|
if (src.hasPatient())
|
||||||
|
tgt.setSubject(VersionConvertor_10_40.convertReference(src.getPatient()));
|
||||||
|
if (src.hasPrescriber())
|
||||||
|
tgt.setRequester(VersionConvertor_10_40.convertReference(src.getPrescriber()));
|
||||||
|
if (src.hasReasonCodeableConcept())
|
||||||
|
tgt.addReasonCode(VersionConvertor_10_40.convertCodeableConcept(src.getReasonCodeableConcept()));
|
||||||
|
if (src.hasReasonReference())
|
||||||
|
tgt.addReasonReference(VersionConvertor_10_40.convertReference((src.getReasonReference())));
|
||||||
|
if (src.hasNote())
|
||||||
|
tgt.addNote(new org.hl7.fhir.r4.model.Annotation(new org.hl7.fhir.r4.model.MarkdownType((src.getNote()))));
|
||||||
|
if (src.hasMedicationCodeableConcept())
|
||||||
|
tgt.setMedication(VersionConvertor_10_40.convertCodeableConcept(src.getMedicationCodeableConcept()));
|
||||||
|
if (src.hasMedicationReference())
|
||||||
|
tgt.setMedication(VersionConvertor_10_40.convertReference(src.getMedicationReference()));
|
||||||
|
for (MedicationOrder.MedicationOrderDosageInstructionComponent dosage : src.getDosageInstruction())
|
||||||
|
tgt.addDosageInstruction(medDosageInstruction(dosage));
|
||||||
|
if (src.hasDispenseRequest())
|
||||||
|
tgt.setDispenseRequest(medDispenseRequest(src.getDispenseRequest()));
|
||||||
|
if (src.hasSubstitution())
|
||||||
|
tgt.setSubstitution(medSubstitution(src.getSubstitution()));
|
||||||
|
if (src.hasPriorPrescription())
|
||||||
|
tgt.setPriorPrescription(VersionConvertor_10_40.convertReference(src.getPriorPrescription()));
|
||||||
|
return tgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static org.hl7.fhir.r4.model.Dosage medDosageInstruction(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDosageInstructionComponent src) {
|
||||||
|
if (src == null || src.isEmpty())
|
||||||
|
return null;
|
||||||
|
org.hl7.fhir.r4.model.Dosage tgt = new org.hl7.fhir.r4.model.Dosage();
|
||||||
|
if (src.hasText())
|
||||||
|
tgt.setText(src.getText());
|
||||||
|
if (src.hasAdditionalInstructions())
|
||||||
|
tgt.addAdditionalInstruction(VersionConvertor_10_40.convertCodeableConcept(src.getAdditionalInstructions()));
|
||||||
|
if (src.hasTiming())
|
||||||
|
tgt.setTiming(VersionConvertor_10_40.convertTiming(src.getTiming()));
|
||||||
|
if (src.hasAsNeeded())
|
||||||
|
tgt.setAsNeeded(VersionConvertor_10_40.convertType(src.getAsNeeded()));
|
||||||
|
if (src.hasSiteCodeableConcept())
|
||||||
|
tgt.setSite(VersionConvertor_10_40.convertCodeableConcept(src.getSiteCodeableConcept()));
|
||||||
|
if (src.hasRoute())
|
||||||
|
tgt.setRoute(VersionConvertor_10_40.convertCodeableConcept(src.getRoute()));
|
||||||
|
if (src.hasMethod())
|
||||||
|
tgt.setMethod(VersionConvertor_10_40.convertCodeableConcept(src.getMethod()));
|
||||||
|
Dosage.DosageDoseAndRateComponent dose_and_rate = new Dosage.DosageDoseAndRateComponent();
|
||||||
|
if (src.hasDose())
|
||||||
|
dose_and_rate.setDose(VersionConvertor_10_40.convertType(src.getDose()));
|
||||||
|
if (src.hasRate())
|
||||||
|
dose_and_rate.setDose(VersionConvertor_10_40.convertType(src.getRate()));
|
||||||
|
tgt.addDoseAndRate(dose_and_rate);
|
||||||
|
if (src.hasMaxDosePerPeriod())
|
||||||
|
tgt.setMaxDosePerPeriod(VersionConvertor_10_40.convertRatio(src.getMaxDosePerPeriod()));
|
||||||
|
return tgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent medDispenseRequest(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderDispenseRequestComponent src) {
|
||||||
|
if (src == null || src.isEmpty())
|
||||||
|
return null;
|
||||||
|
org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestDispenseRequestComponent();
|
||||||
|
if (src.hasValidityPeriod())
|
||||||
|
tgt.setValidityPeriod(VersionConvertor_10_40.convertPeriod(src.getValidityPeriod()));
|
||||||
|
if (src.hasNumberOfRepeatsAllowed())
|
||||||
|
tgt.setNumberOfRepeatsAllowed(src.getNumberOfRepeatsAllowed());
|
||||||
|
if (src.hasQuantity())
|
||||||
|
tgt.setQuantity(VersionConvertor_10_40.convertSimpleQuantity(src.getQuantity()));
|
||||||
|
if (src.hasExpectedSupplyDuration())
|
||||||
|
tgt.setExpectedSupplyDuration(VersionConvertor_10_40.convertDuration(src.getExpectedSupplyDuration()));
|
||||||
|
return tgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent medSubstitution(org.hl7.fhir.dstu2.model.MedicationOrder.MedicationOrderSubstitutionComponent src) {
|
||||||
|
if (src == null || src.isEmpty())
|
||||||
|
return null;
|
||||||
|
org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent tgt = new org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestSubstitutionComponent();
|
||||||
|
if (src.hasReason())
|
||||||
|
tgt.setReason(VersionConvertor_10_40.convertCodeableConcept(src.getReason()));
|
||||||
|
return tgt;
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,8 +43,14 @@ public class MedicationRequest30_40 {
|
||||||
tgt.setPriorPrescription(VersionConvertor_30_40.convertReference(src.getPriorPrescription()));
|
tgt.setPriorPrescription(VersionConvertor_30_40.convertReference(src.getPriorPrescription()));
|
||||||
for (org.hl7.fhir.dstu3.model.Reference t : src.getDetectedIssue()) tgt.addDetectedIssue(VersionConvertor_30_40.convertReference(t));
|
for (org.hl7.fhir.dstu3.model.Reference t : src.getDetectedIssue()) tgt.addDetectedIssue(VersionConvertor_30_40.convertReference(t));
|
||||||
for (org.hl7.fhir.dstu3.model.Reference t : src.getEventHistory()) tgt.addEventHistory(VersionConvertor_30_40.convertReference(t));
|
for (org.hl7.fhir.dstu3.model.Reference t : src.getEventHistory()) tgt.addEventHistory(VersionConvertor_30_40.convertReference(t));
|
||||||
if (src.hasRequester() && src.getRequester().hasAgent()) {
|
if (src.hasRequester()) {
|
||||||
tgt.setRequester(VersionConvertor_30_40.convertReference(src.getRequester().getAgent()));
|
if (src.getRequester().hasAgent()) {
|
||||||
|
tgt.setRequester(VersionConvertor_30_40.convertReference(src.getRequester().getAgent()));
|
||||||
|
}
|
||||||
|
if (src.getRequester().hasOnBehalfOf()) {
|
||||||
|
tgt.addExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-MedicationRequest.requester.onBehalfOf",
|
||||||
|
VersionConvertor_30_40.convertReference(src.getRequester().getOnBehalfOf()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.hl7.fhir.convertors.conv10_40;
|
||||||
|
|
||||||
|
import org.hl7.fhir.convertors.VersionConvertorAdvisor40;
|
||||||
|
import org.hl7.fhir.convertors.VersionConvertor_10_40;
|
||||||
|
import org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class MedicationRequest10_40Test {
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test 10_40 MedicationRequest conversion")
|
||||||
|
public void testMedicationRequestConversion() throws IOException {
|
||||||
|
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_medication_request_10.json");
|
||||||
|
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_medication_request_40.json");
|
||||||
|
|
||||||
|
org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(dstu2_input);
|
||||||
|
VersionConvertorAdvisor40 advisor = new IGR2ConvertorAdvisor();
|
||||||
|
org.hl7.fhir.r4.model.Resource r4_actual = VersionConvertor_10_40.convertResource(dstu2, advisor);
|
||||||
|
|
||||||
|
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
|
||||||
|
org.hl7.fhir.r4.model.Resource r4_expected = r4_parser.parse(r4_exepected_input);
|
||||||
|
|
||||||
|
Assertions.assertTrue(r4_expected.equalsDeep(r4_actual),
|
||||||
|
"Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
{"resourceType": "MedicationOrder",
|
||||||
|
"dateWritten": "2016-11-13",
|
||||||
|
"status": "active",
|
||||||
|
"id": "T5YI1tCzs--JEvCICFbx8zgB",
|
||||||
|
"identifier": [{"use": "usual",
|
||||||
|
"system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.798268",
|
||||||
|
"value": "988736"},
|
||||||
|
{"use": "usual",
|
||||||
|
"system": "urn:oid:1.2.840.114350.1.13.0.1.7.3.798268.801",
|
||||||
|
"value": "988736:2150291843"}],
|
||||||
|
"patient": {"display": "Jason Argonaut",
|
||||||
|
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"},
|
||||||
|
"prescriber": {"display": "Historical Provider, MD",
|
||||||
|
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/T-kmjPGEVPAmnBfmx56HsKgB"},
|
||||||
|
"medicationReference": {"display": "amitriptyline 10 MG tablet",
|
||||||
|
"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Medication/T0eKLT7EB2ApMM8HCEURdMAB"},
|
||||||
|
"dosageInstruction": [{"text": "Take 10 mg by mouth nightly.",
|
||||||
|
"asNeededBoolean": "False",
|
||||||
|
"route": {"text": "Oral",
|
||||||
|
"coding": [{"system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.698288.330",
|
||||||
|
"code": "15",
|
||||||
|
"display": "Oral"}]},
|
||||||
|
"method": {"text": "Take",
|
||||||
|
"coding": [{"system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.798268.8600",
|
||||||
|
"code": "11",
|
||||||
|
"display": "Take"}]},
|
||||||
|
"timing": {"repeat": {"frequency": 1,
|
||||||
|
"period": 1.0,
|
||||||
|
"periodUnits": "d",
|
||||||
|
"boundsPeriod": {"start": "2016-11-15T00:00:00Z",
|
||||||
|
"end": "2016-11-23T00:00:00Z"}}},
|
||||||
|
"doseQuantity": {"value": 10.0,
|
||||||
|
"unit": "mg",
|
||||||
|
"code": "mg",
|
||||||
|
"system": "http://unitsofmeasure.org"}}],
|
||||||
|
"dispenseRequest": {"validityPeriod": {"start": "2016-11-15T00:00:00Z",
|
||||||
|
"end": "2016-11-23T00:00:00Z"}}}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{"resourceType": "MedicationRequest",
|
||||||
|
"id": "T5YI1tCzs--JEvCICFbx8zgB",
|
||||||
|
"identifier": [{"use": "usual",
|
||||||
|
"system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.798268",
|
||||||
|
"value": "988736"},
|
||||||
|
{"use": "usual",
|
||||||
|
"system": "urn:oid:1.2.840.114350.1.13.0.1.7.3.798268.801",
|
||||||
|
"value": "988736:2150291843"}],
|
||||||
|
"status": "active",
|
||||||
|
"intent": "order",
|
||||||
|
"medicationReference": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Medication/T0eKLT7EB2ApMM8HCEURdMAB",
|
||||||
|
"display": "amitriptyline 10 MG tablet"},
|
||||||
|
"subject": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB",
|
||||||
|
"display": "Jason Argonaut"},
|
||||||
|
"authoredOn": "2016-11-13T00:00:00",
|
||||||
|
"requester": {"reference": "https://open-ic.epic.com/Argonaut/api/FHIR/DSTU2/Practitioner/T-kmjPGEVPAmnBfmx56HsKgB",
|
||||||
|
"display": "Historical Provider, MD"},
|
||||||
|
"dosageInstruction": [{"text": "Take 10 mg by mouth nightly.",
|
||||||
|
"timing": {"repeat": {"boundsPeriod": {"start": "2016-11-15T00:00:00Z",
|
||||||
|
"end": "2016-11-23T00:00:00Z"},
|
||||||
|
"count": 0,
|
||||||
|
"frequency": 1,
|
||||||
|
"frequencyMax": 0,
|
||||||
|
"period": 1.0,
|
||||||
|
"periodUnit": "d"}},
|
||||||
|
"asNeededBoolean": "False",
|
||||||
|
"route": {"coding": [{"system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.698288.330",
|
||||||
|
"code": "15",
|
||||||
|
"display": "Oral"}],
|
||||||
|
"text": "Oral"},
|
||||||
|
"method": {"coding": [{"system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.798268.8600",
|
||||||
|
"code": "11",
|
||||||
|
"display": "Take"}],
|
||||||
|
"text": "Take"},
|
||||||
|
"doseAndRate": [{"doseQuantity": {"value": 10.0,
|
||||||
|
"unit": "mg",
|
||||||
|
"system": "http://unitsofmeasure.org",
|
||||||
|
"code": "mg"}}]}],
|
||||||
|
"dispenseRequest": {"validityPeriod": {"start": "2016-11-15T00:00:00Z",
|
||||||
|
"end": "2016-11-23T00:00:00Z"}}}
|
Loading…
Reference in New Issue