add copying of aggregation mode for conversion from 50 to 30

This commit is contained in:
tyfni 2021-05-18 13:39:36 +02:00
parent ac7b94058a
commit 56738f7acf
5 changed files with 99 additions and 0 deletions

View File

@ -1,3 +1,4 @@
* add copying of aggregation mode for conversion from 50 to 30
* add test for Observation conversion from 10 to 40
* add procedures conversion form dstu2 to r4
* add medication conversion from dstu2 to r4

View File

@ -1826,6 +1826,10 @@ public class VersionConvertor_30_50 {
tgt.setProfile(u.getValue());
}
}
for (org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.AggregationMode> t : src.getAggregation()) {
org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode> a = convertAggregationMode(t);
if (!tgt.hasAggregation(a.getValue())) copyElement(t, tgt.addAggregation(a.getValue()));
}
}
static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ElementDefinition.AggregationMode> convertAggregationMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ElementDefinition.AggregationMode> src) throws FHIRException {

View File

@ -0,0 +1,28 @@
package org.hl7.fhir.convertors.conv30_50;
import org.hl7.fhir.convertors.VersionConvertor_30_40;
import org.hl7.fhir.convertors.VersionConvertor_30_50;
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 StructureDefinition30_50Test {
@Test
@DisplayName("Test r5 -> dstu3 device conversion.")
public void test1() throws IOException {
InputStream r5_input = this.getClass().getResourceAsStream("/0_structuredefinition_50.json");
InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/0_structuredefinition_30.json");
org.hl7.fhir.r5.model.StructureDefinition r5_actual = (org.hl7.fhir.r5.model.StructureDefinition) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input);
org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertor_30_50.convertResource(r5_actual, true);
org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv),
"Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_conv));
}
}

View File

@ -0,0 +1,33 @@
{
"resourceType": "StructureDefinition",
"id": "ehealth-observation",
"url": "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-observation",
"name": "ehealth-observation",
"title": "eHealth Observation",
"status": "draft",
"kind": "resource",
"abstract": "false",
"type": "Observation",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Observation",
"derivation": "constraint",
"snapshot": {
"element": [
{
"id": "Observation.subject",
"path": "Observation.subject",
"min": "1",
"type": [
{
"code": "Reference",
"targetProfile": [
"http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-patient"
],
"aggregation": [
"referenced"
]
}
]
}
]
}
}

View File

@ -0,0 +1,33 @@
{
"resourceType": "StructureDefinition",
"id": "ehealth-observation",
"url": "http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-observation",
"name": "ehealth-observation",
"title": "eHealth Observation",
"status": "draft",
"kind": "resource",
"abstract": "false",
"type": "Observation",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Observation",
"derivation": "constraint",
"snapshot": {
"element": [
{
"id": "Observation.subject",
"path": "Observation.subject",
"min": "1",
"type": [
{
"code": "Reference",
"targetProfile": [
"http://ehealth.sundhed.dk/fhir/StructureDefinition/ehealth-patient"
],
"aggregation": [
"referenced"
]
}
]
}
]
}
}