converting procedures from dstu2 to r4 (#429)
* converting procedures from dstu2 to r4 * Update VersionConvertor_10_40.java * Update VersionConvertor_10_40.java * Update VersionConvertor_10_40.java * Update Procedure10_40Test.java * add description to the release notes Co-authored-by: Mark Iantorno <markiantorno@gmail.com>
This commit is contained in:
parent
42d148a80e
commit
5b3f4fa85c
|
@ -1 +1,2 @@
|
|||
add medication conversion from dstu2 to r4
|
||||
* add procedures conversion form dstu2 to r4
|
||||
* add medication conversion from dstu2 to r4
|
||||
|
|
|
@ -2923,6 +2923,8 @@ public class VersionConvertor_10_40 {
|
|||
return TestScript10_40.convertTestScript((org.hl7.fhir.dstu2.model.TestScript) src);
|
||||
if (src instanceof org.hl7.fhir.dstu2.model.ValueSet)
|
||||
return ValueSet10_40.convertValueSet((org.hl7.fhir.dstu2.model.ValueSet) src, advisor);
|
||||
if (src instanceof org.hl7.fhir.dstu2.model.Procedure)
|
||||
return Procedure10_40.convertProcedure((org.hl7.fhir.dstu2.model.Procedure) src);
|
||||
if (src instanceof org.hl7.fhir.dstu2.model.Medication)
|
||||
return Medication10_40.convertMedication((org.hl7.fhir.dstu2.model.Medication) src);
|
||||
throw new FHIRException("Unknown resource " + src.fhirType());
|
||||
|
|
|
@ -41,6 +41,8 @@ public class Procedure10_30 {
|
|||
if (src.hasBasedOn())
|
||||
tgt.setRequest(VersionConvertor_10_30.convertReference(src.getBasedOnFirstRep()));
|
||||
for (org.hl7.fhir.dstu3.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
|
||||
for (org.hl7.fhir.dstu3.model.Annotation note : src.getNote()) tgt.addNotes(VersionConvertor_10_30.convertAnnotation(note));
|
||||
for (org.hl7.fhir.dstu3.model.Reference r : src.getUsedReference()) tgt.addUsed(VersionConvertor_10_30.convertReference(r));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
|
@ -80,6 +82,8 @@ public class Procedure10_30 {
|
|||
if (src.hasRequest())
|
||||
tgt.addBasedOn(VersionConvertor_10_30.convertReference(src.getRequest()));
|
||||
for (org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
|
||||
for (org.hl7.fhir.dstu2.model.Annotation note : src.getNotes()) tgt.addNote(VersionConvertor_10_30.convertAnnotation(note));
|
||||
for (org.hl7.fhir.dstu2.model.Reference r : src.getUsed()) tgt.addUsedReference(VersionConvertor_10_30.convertReference(r));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
package org.hl7.fhir.convertors.conv10_40;
|
||||
|
||||
import org.hl7.fhir.convertors.VersionConvertor_10_30;
|
||||
import org.hl7.fhir.convertors.VersionConvertor_10_40;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Procedure;
|
||||
|
||||
public class Procedure10_40 {
|
||||
|
||||
public static org.hl7.fhir.r4.model.Procedure convertProcedure(org.hl7.fhir.dstu2.model.Procedure src) throws FHIRException {
|
||||
if (src == null || src.isEmpty())
|
||||
return null;
|
||||
org.hl7.fhir.r4.model.Procedure tgt = new org.hl7.fhir.r4.model.Procedure();
|
||||
VersionConvertor_10_40.copyDomainResource(src, tgt);
|
||||
for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_40.convertIdentifier(t));
|
||||
if (src.hasSubject())
|
||||
tgt.setSubject(VersionConvertor_10_40.convertReference(src.getSubject()));
|
||||
if (src.hasStatus() && src.hasNotPerformed()) {
|
||||
if (src.getNotPerformed()) {
|
||||
tgt.setStatus(Procedure.ProcedureStatus.NOTDONE);
|
||||
} else {
|
||||
tgt.setStatus(convertProcedureStatus(src.getStatus()));
|
||||
}
|
||||
}
|
||||
if (src.hasCategory())
|
||||
tgt.setCategory(VersionConvertor_10_40.convertCodeableConcept(src.getCategory()));
|
||||
if (src.hasCode())
|
||||
tgt.setCode(VersionConvertor_10_40.convertCodeableConcept(src.getCode()));
|
||||
if (src.hasReasonNotPerformed())
|
||||
tgt.setStatusReason(VersionConvertor_10_40.convertCodeableConcept(src.getReasonNotPerformed().get(0)));
|
||||
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getBodySite()) tgt.addBodySite(VersionConvertor_10_40.convertCodeableConcept(t));
|
||||
if (src.hasReasonCodeableConcept())
|
||||
tgt.addReasonCode(VersionConvertor_10_40.convertCodeableConcept(src.getReasonCodeableConcept()));
|
||||
if (src.hasReasonReference())
|
||||
tgt.addReasonReference(VersionConvertor_10_40.convertReference(src.getReasonReference()));
|
||||
if (src.hasPerformed())
|
||||
tgt.setPerformed(VersionConvertor_10_40.convertType(src.getPerformed()));
|
||||
for (org.hl7.fhir.dstu2.model.Procedure.ProcedurePerformerComponent t : src.getPerformer()) tgt.addPerformer(convertProcedurePerformerComponent(t));
|
||||
if (src.hasEncounter())
|
||||
tgt.setEncounter(VersionConvertor_10_40.convertReference(src.getEncounter()));
|
||||
if (src.hasLocation())
|
||||
tgt.setLocation(VersionConvertor_10_40.convertReference(src.getLocation()));
|
||||
if (src.hasOutcome())
|
||||
tgt.setOutcome(VersionConvertor_10_40.convertCodeableConcept(src.getOutcome()));
|
||||
for (org.hl7.fhir.dstu2.model.Reference t : src.getReport()) tgt.addReport(VersionConvertor_10_40.convertReference(t));
|
||||
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getComplication()) tgt.addComplication(VersionConvertor_10_40.convertCodeableConcept(t));
|
||||
for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getFollowUp()) tgt.addFollowUp(VersionConvertor_10_40.convertCodeableConcept(t));
|
||||
if (src.hasRequest())
|
||||
tgt.addBasedOn(VersionConvertor_10_40.convertReference(src.getRequest()));
|
||||
for (org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice()) tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
|
||||
for (org.hl7.fhir.dstu2.model.Annotation note : src.getNotes()) tgt.addNote(VersionConvertor_10_40.convertAnnotation(note));
|
||||
for (org.hl7.fhir.dstu2.model.Reference r : src.getUsed()) tgt.addUsedReference(VersionConvertor_10_40.convertReference(r));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.r4.model.Procedure.ProcedureStatus convertProcedureStatus(org.hl7.fhir.dstu2.model.Procedure.ProcedureStatus src) {
|
||||
switch(src) {
|
||||
case ENTEREDINERROR:
|
||||
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.ENTEREDINERROR;
|
||||
case INPROGRESS:
|
||||
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.INPROGRESS;
|
||||
case ABORTED:
|
||||
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.STOPPED;
|
||||
case COMPLETED:
|
||||
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED;
|
||||
default:
|
||||
return org.hl7.fhir.r4.model.Procedure.ProcedureStatus.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.dstu2.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
|
||||
if (src == null || src.isEmpty())
|
||||
return null;
|
||||
org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedurePerformerComponent();
|
||||
VersionConvertor_10_40.copyElement(src, tgt);
|
||||
if (src.hasActor())
|
||||
tgt.setActor(VersionConvertor_10_40.convertReference(src.getActor()));
|
||||
if (src.hasRole())
|
||||
tgt.setFunction(VersionConvertor_10_40.convertCodeableConcept(src.getRole()));
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.dstu2.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
|
||||
if (src == null || src.isEmpty())
|
||||
return null;
|
||||
org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4.model.Procedure.ProcedureFocalDeviceComponent();
|
||||
VersionConvertor_10_40.copyElement(src, tgt);
|
||||
if (src.hasAction())
|
||||
tgt.setAction(VersionConvertor_10_40.convertCodeableConcept(src.getAction()));
|
||||
if (src.hasManipulated())
|
||||
tgt.setManipulated(VersionConvertor_10_40.convertReference(src.getManipulated()));
|
||||
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 Procedure10_40Test {
|
||||
@Test
|
||||
@DisplayName("Test 10_40 Procedure conversion")
|
||||
public void testProcedureConversion() throws IOException {
|
||||
InputStream dstu2_input = this.getClass().getResourceAsStream("/0_procedure_10.json");
|
||||
InputStream r4_exepected_input = this.getClass().getResourceAsStream("/0_procedure_40.json");
|
||||
|
||||
org.hl7.fhir.dstu2.model.Procedure dstu2 = (org.hl7.fhir.dstu2.model.Procedure) 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,39 @@
|
|||
{
|
||||
"resourceType": "Procedure",
|
||||
"id": "MrShokoProcedure",
|
||||
"identifier": [
|
||||
{
|
||||
"use": "usual",
|
||||
"type": {
|
||||
"text": "ORD"
|
||||
},
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.798268",
|
||||
"value": "1158800385"
|
||||
},
|
||||
{
|
||||
"use": "usual",
|
||||
"type": {
|
||||
"text": "EAP"
|
||||
},
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
|
||||
"value": "183667"
|
||||
}
|
||||
],
|
||||
"subject": {
|
||||
"display": "Mr Shoko",
|
||||
"reference": "Mr Shoko"
|
||||
},
|
||||
"status": "completed",
|
||||
"code": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
|
||||
"code": "183667",
|
||||
"display": "COLONOSCOPY "
|
||||
}
|
||||
],
|
||||
"text": "Colonoscopy"
|
||||
},
|
||||
"notPerformed": false,
|
||||
"performedDateTime": "2010-01-01T01:01:01Z"
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"resourceType": "Procedure",
|
||||
"id": "MrShokoProcedure",
|
||||
"identifier": [
|
||||
{
|
||||
"use": "usual",
|
||||
"type": {
|
||||
"text": "ORD"
|
||||
},
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.798268",
|
||||
"value": "1158800385"
|
||||
},
|
||||
{
|
||||
"use": "usual",
|
||||
"type": {
|
||||
"text": "EAP"
|
||||
},
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
|
||||
"value": "183667"
|
||||
}
|
||||
],
|
||||
"subject": {
|
||||
"display": "Mr Shoko",
|
||||
"reference": "Mr Shoko"
|
||||
},
|
||||
"status": "completed",
|
||||
"code": {
|
||||
"coding": [
|
||||
{
|
||||
"system": "urn:oid:1.2.840.114350.1.13.404.2.7.2.696580",
|
||||
"code": "183667",
|
||||
"display": "COLONOSCOPY "
|
||||
}
|
||||
],
|
||||
"text": "Colonoscopy"
|
||||
},
|
||||
"performedDateTime": "2010-01-01T01:01:01Z"
|
||||
}
|
Loading…
Reference in New Issue