From e156be4e49e4e1a96418a5042ed2bd00d836edc5 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Sat, 29 Aug 2020 20:56:47 +0300 Subject: [PATCH 1/8] add "OnBehalfOf" for medication request when converting STU3 do R4 --- .../convertors/conv30_40/MedicationRequest30_40.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/MedicationRequest30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/MedicationRequest30_40.java index 03a47a3ac..a1e43f08b 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/MedicationRequest30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/MedicationRequest30_40.java @@ -43,8 +43,14 @@ public class MedicationRequest30_40 { 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.getEventHistory()) tgt.addEventHistory(VersionConvertor_30_40.convertReference(t)); - if (src.hasRequester() && src.getRequester().hasAgent()) { - tgt.setRequester(VersionConvertor_30_40.convertReference(src.getRequester().getAgent())); + if (src.hasRequester()) { + 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; } From 3f54167fba7ff72f1816d81e2f52a490e60f3ab0 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Sat, 29 Aug 2020 22:16:52 +0300 Subject: [PATCH 2/8] Add MedicationRequest10_40 --- .editorconfig | 2 +- .../conv10_40/MedicationRequest10_40.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java diff --git a/.editorconfig b/.editorconfig index cd68918bc..f5149f4a7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ [*.java] charset = utf-8 indent_style = space -indent_size = 2 +indent_size = 4 diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java new file mode 100644 index 000000000..17e6007e1 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java @@ -0,0 +1,39 @@ +package org.hl7.fhir.convertors.conv10_40; + +import org.hl7.fhir.convertors.VersionConvertor_10_40; +import org.hl7.fhir.exceptions.FHIRException; + +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())); + // TODO dosage instruction + // TODO dispense request + // TODO substitution + if (src.hasPriorPrescription()) + tgt.setPriorPrescription(VersionConvertor_10_40.convertReference(src.getPriorPrescription())); + return tgt; + } +} From 169d030e2e8922fb1356b745b858eb08b9b0833d Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Sat, 29 Aug 2020 22:31:28 +0300 Subject: [PATCH 3/8] finish adding MedicationRequest10_40 --- .../convertors/VersionConvertor_10_40.java | 2 + .../conv10_40/MedicationRequest10_40.java | 71 +++++++++++++++++-- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index 9acc003ae..bbd248114 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -3236,6 +3236,8 @@ public class VersionConvertor_10_40 { return MedicationDispense10_40.convertMedicationDispense((org.hl7.fhir.dstu2.model.MedicationDispense) src); if (src instanceof org.hl7.fhir.dstu2.model.MedicationStatement) 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) return MessageHeader10_40.convertMessageHeader((org.hl7.fhir.dstu2.model.MessageHeader) src); if (src instanceof org.hl7.fhir.dstu2.model.NamingSystem) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java index 17e6007e1..25e745d33 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40.java @@ -1,7 +1,10 @@ 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 { @@ -18,22 +21,78 @@ public class MedicationRequest10_40 { if (src.hasPatient()) tgt.setSubject(VersionConvertor_10_40.convertReference(src.getPatient())); if (src.hasPrescriber()) - tgt.setRequester(VersionConvertor_10_40.convertReference(src.getPrescriber()); + 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())); + 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()))); + 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())); - // TODO dosage instruction - // TODO dispense request - // TODO substitution + 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; + } } From 046540624d68ccba45d7f9cec8bdc5fe62d2c058 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Sat, 29 Aug 2020 23:02:19 +0300 Subject: [PATCH 4/8] add missing import --- .../java/org/hl7/fhir/convertors/VersionConvertor_10_40.java | 1 + 1 file changed, 1 insertion(+) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java index bbd248114..6a656ac6f 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/VersionConvertor_10_40.java @@ -36,6 +36,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.Location10_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.MessageHeader10_40; import org.hl7.fhir.convertors.conv10_40.NamingSystem10_40; From 82f96965fdfdcb308002343bc10a951b32766288 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Mon, 31 Aug 2020 15:41:17 +0300 Subject: [PATCH 5/8] adding tests --- .../conv10_40/MedicationRequest10_40Test.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java new file mode 100644 index 000000000..0c60d5a0f --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java @@ -0,0 +1,109 @@ +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 { + String dstu2_string = + "{'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'}}}"; + String r4_expected_string = + "{\"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\"}}}"; + + InputStream input = org.apache.commons.io.IOUtils.toInputStream(dstu2_string, "UTF-8"); + org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(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_expected_string); + + Assertions.assertTrue(r4_expected.equalsDeep(r4_actual), + "Failed comparing\n" + r4_parser.composeString(r4_actual) + "\nand\n" + r4_parser.composeString(r4_expected)); + } + +} From 0c1c61b275a27fa2f73702ebe4ccba9f6d232812 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Mon, 31 Aug 2020 22:06:01 +0300 Subject: [PATCH 6/8] fixing pr comments --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index f5149f4a7..cd68918bc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ [*.java] charset = utf-8 indent_style = space -indent_size = 4 +indent_size = 2 From 84e55aa8255069367481fb8047818f497fb2e736 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Mon, 31 Aug 2020 22:16:26 +0300 Subject: [PATCH 7/8] fix pr comments --- .../conv10_40/MedicationRequest10_40Test.java | 86 +------------------ .../example_medication_request_10.json | 37 ++++++++ .../example_medication_request_40.json | 40 +++++++++ 3 files changed, 81 insertions(+), 82 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json create mode 100644 org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java index 0c60d5a0f..e423fc1cc 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java @@ -14,93 +14,15 @@ public class MedicationRequest10_40Test { @Test @DisplayName("Test 10_40 MedicationRequest conversion") public void testMedicationRequestConversion() throws IOException { - String dstu2_string = - "{'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'}}}"; - String r4_expected_string = - "{\"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\"}}}"; + InputStream dstu2_input = this.getClass().getResourceAsStream("/example_medication_request_10.json"); + InputStream r4_exepected_input = this.getClass().getResourceAsStream("/example_medication_request_40.json"); - InputStream input = org.apache.commons.io.IOUtils.toInputStream(dstu2_string, "UTF-8"); - org.hl7.fhir.dstu2.model.MedicationOrder dstu2 = (org.hl7.fhir.dstu2.model.MedicationOrder) new org.hl7.fhir.dstu2.formats.JsonParser().parse(input); + 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_expected_string); + 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)); diff --git a/org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json b/org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json new file mode 100644 index 000000000..15be241c9 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json @@ -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"}}} diff --git a/org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json b/org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json new file mode 100644 index 000000000..0b3a6f0ed --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json @@ -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+02: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"}}} \ No newline at end of file From c2427096caabf7933b13a88a614480d4d59065e9 Mon Sep 17 00:00:00 2001 From: Itay Goren Date: Mon, 31 Aug 2020 22:58:47 +0300 Subject: [PATCH 8/8] fix test error + add files conventions --- .../fhir/convertors/conv10_40/MedicationRequest10_40Test.java | 4 ++-- ...edication_request_10.json => 0_medication_request_10.json} | 0 ...edication_request_40.json => 0_medication_request_40.json} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename org.hl7.fhir.convertors/src/test/resources/{example_medication_request_10.json => 0_medication_request_10.json} (100%) rename org.hl7.fhir.convertors/src/test/resources/{example_medication_request_40.json => 0_medication_request_40.json} (95%) diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java index e423fc1cc..2972bbf51 100644 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv10_40/MedicationRequest10_40Test.java @@ -14,8 +14,8 @@ public class MedicationRequest10_40Test { @Test @DisplayName("Test 10_40 MedicationRequest conversion") public void testMedicationRequestConversion() throws IOException { - InputStream dstu2_input = this.getClass().getResourceAsStream("/example_medication_request_10.json"); - InputStream r4_exepected_input = this.getClass().getResourceAsStream("/example_medication_request_40.json"); + 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(); diff --git a/org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json b/org.hl7.fhir.convertors/src/test/resources/0_medication_request_10.json similarity index 100% rename from org.hl7.fhir.convertors/src/test/resources/example_medication_request_10.json rename to org.hl7.fhir.convertors/src/test/resources/0_medication_request_10.json diff --git a/org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json b/org.hl7.fhir.convertors/src/test/resources/0_medication_request_40.json similarity index 95% rename from org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json rename to org.hl7.fhir.convertors/src/test/resources/0_medication_request_40.json index 0b3a6f0ed..325b59a1a 100644 --- a/org.hl7.fhir.convertors/src/test/resources/example_medication_request_40.json +++ b/org.hl7.fhir.convertors/src/test/resources/0_medication_request_40.json @@ -12,7 +12,7 @@ "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+02:00", + "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.", @@ -37,4 +37,4 @@ "system": "http://unitsofmeasure.org", "code": "mg"}}]}], "dispenseRequest": {"validityPeriod": {"start": "2016-11-15T00:00:00Z", - "end": "2016-11-23T00:00:00Z"}}} \ No newline at end of file + "end": "2016-11-23T00:00:00Z"}}}