Added test scripts for ValueSet conversion
This commit is contained in:
parent
4f78eb033c
commit
7d0822a0d8
|
@ -13,7 +13,7 @@ public class TestScript40_50Test {
|
|||
|
||||
|
||||
@Test
|
||||
@DisplayName("Test TestScript R4 <-> R5 with resoutce scope extension")
|
||||
@DisplayName("Test TestScript R4 <-> R5 with resource scope extension")
|
||||
public void testValueExpressionConversion40_10() throws IOException {
|
||||
InputStream r4_stream = this.getClass().getResourceAsStream("/test_script_r4.json");
|
||||
org.hl7.fhir.r4.model.TestScript r4_input = (org.hl7.fhir.r4.model.TestScript) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_stream);
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package org.hl7.fhir.convertors.conv40_50;
|
||||
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
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 ValueSet40_50Test {
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Test ValueSet R4 <-> R5 with property extensions")
|
||||
public void testValueExpressionConversion40_10() throws IOException {
|
||||
InputStream r4_stream = this.getClass().getResourceAsStream("/value_set_r4.json");
|
||||
org.hl7.fhir.r4.model.ValueSet r4_input = (org.hl7.fhir.r4.model.ValueSet) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_stream);
|
||||
|
||||
InputStream r5_stream = this.getClass().getResourceAsStream("/value_set_r5.json");
|
||||
org.hl7.fhir.r5.model.ValueSet r5_input = (org.hl7.fhir.r5.model.ValueSet) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_stream);
|
||||
|
||||
org.hl7.fhir.r5.model.ValueSet r5_output = (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_40_50.convertResource(r4_input);
|
||||
org.hl7.fhir.r4.model.ValueSet r4_output = (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(r5_input);
|
||||
|
||||
org.hl7.fhir.r5.formats.JsonParser r5_parser = new org.hl7.fhir.r5.formats.JsonParser();
|
||||
String r5_in = r5_parser.setOutputStyle(OutputStyle.PRETTY).composeString(r5_input);
|
||||
String r5_out = r5_parser.composeString(r5_output);
|
||||
boolean pass = r5_input.equalsDeep(r5_output);
|
||||
if (!pass) {
|
||||
System.out.println("R5. Expected out ->\n"+ r5_in + "\n\nActual out ->\n" + r5_out);
|
||||
}
|
||||
Assertions.assertTrue(pass);
|
||||
|
||||
org.hl7.fhir.r4.formats.JsonParser r4_parser = new org.hl7.fhir.r4.formats.JsonParser();
|
||||
String r4_in = r4_parser.composeString(r4_input);
|
||||
String r4_out = r4_parser.composeString(r4_output);
|
||||
pass = r4_input.equalsDeep(r4_output);
|
||||
if (!pass) {
|
||||
System.out.println("R4. Expected out ->\n"+ r4_in + "\n\nActual out ->\n" + r4_out);
|
||||
}
|
||||
Assertions.assertTrue(pass);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
"resourceType" : "ValueSet",
|
||||
"id" : "VSPHQ9",
|
||||
"url" : "http://example.org/ValueSet/VSPHQ9",
|
||||
"name" : "VSPHQ9",
|
||||
"status" : "active",
|
||||
"immutable" : true,
|
||||
"compose" : {
|
||||
"include" : [{
|
||||
"system" : "http://example.org/CodeSystem/CSPHQ9",
|
||||
"concept" : [{
|
||||
"code" : "Not-at-all",
|
||||
"display" : "Not at all"
|
||||
},
|
||||
{
|
||||
"code" : "Several-days",
|
||||
"display" : "Several days"
|
||||
},
|
||||
{
|
||||
"code" : "More than half the days",
|
||||
"display" : "More than half the days"
|
||||
},
|
||||
{
|
||||
"code" : "Nearly every day",
|
||||
"display" : "Nearly every day"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"expansion" : {
|
||||
"extension" : [{
|
||||
"extension" : [{
|
||||
"url" : "code",
|
||||
"valueCode" : "itemWeight"
|
||||
},
|
||||
{
|
||||
"url" : "uri",
|
||||
"valueUri" : "http://hl7.org/fhir/concept-properties#itemWeight"
|
||||
}],
|
||||
"url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.property"
|
||||
}],
|
||||
"timestamp" : "2024-12-06T22:52:00-07:00",
|
||||
"contains" : [{
|
||||
"extension" : [{
|
||||
"extension" : [{
|
||||
"url" : "code",
|
||||
"valueCode" : "itemWeight"
|
||||
},
|
||||
{
|
||||
"url" : "value[x]",
|
||||
"valueDecimal" : 0
|
||||
}],
|
||||
"url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property"
|
||||
}],
|
||||
"code" : "not-at-all",
|
||||
"display" : "Not at all"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"extension" : [{
|
||||
"url" : "code",
|
||||
"valueCode" : "itemWeight"
|
||||
},
|
||||
{
|
||||
"url" : "value[x]",
|
||||
"valueDecimal" : 1
|
||||
}],
|
||||
"url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property"
|
||||
}],
|
||||
"code" : "Several-days",
|
||||
"display" : "Several days"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"extension" : [{
|
||||
"url" : "code",
|
||||
"valueCode" : "itemWeight"
|
||||
},
|
||||
{
|
||||
"url" : "value[x]",
|
||||
"valueDecimal" : 2
|
||||
}],
|
||||
"url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property"
|
||||
}],
|
||||
"code" : "More than half the days",
|
||||
"display" : "More than half the days"
|
||||
},
|
||||
{
|
||||
"extension" : [{
|
||||
"extension" : [{
|
||||
"url" : "code",
|
||||
"valueCode" : "itemWeight"
|
||||
},
|
||||
{
|
||||
"url" : "value[x]",
|
||||
"valueDecimal" : 4
|
||||
}],
|
||||
"url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-ValueSet.expansion.contains.property"
|
||||
}],
|
||||
"code" : "Nearly every day",
|
||||
"display" : "Nearly every day"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"resourceType" : "ValueSet",
|
||||
"id" : "VSPHQ9",
|
||||
"url" : "http://example.org/ValueSet/VSPHQ9",
|
||||
"name" : "VSPHQ9",
|
||||
"status" : "active",
|
||||
"immutable" : true,
|
||||
"compose" : {
|
||||
"include" : [{
|
||||
"system" : "http://example.org/CodeSystem/CSPHQ9",
|
||||
"concept" : [{
|
||||
"code" : "Not-at-all",
|
||||
"display" : "Not at all"
|
||||
},
|
||||
{
|
||||
"code" : "Several-days",
|
||||
"display" : "Several days"
|
||||
},
|
||||
{
|
||||
"code" : "More than half the days",
|
||||
"display" : "More than half the days"
|
||||
},
|
||||
{
|
||||
"code" : "Nearly every day",
|
||||
"display" : "Nearly every day"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"expansion" : {
|
||||
"timestamp" : "2024-12-06T22:52:00-07:00",
|
||||
"property" : [{
|
||||
"code" : "itemWeight",
|
||||
"uri" : "http://hl7.org/fhir/concept-properties#itemWeight"
|
||||
}],
|
||||
"contains" : [{
|
||||
"code" : "not-at-all",
|
||||
"display" : "Not at all",
|
||||
"property" : [{
|
||||
"code" : "itemWeight",
|
||||
"valueDecimal" : 0
|
||||
}]
|
||||
},
|
||||
{
|
||||
"code" : "Several-days",
|
||||
"display" : "Several days",
|
||||
"property" : [{
|
||||
"code" : "itemWeight",
|
||||
"valueDecimal" : 1
|
||||
}]
|
||||
},
|
||||
{
|
||||
"code" : "More than half the days",
|
||||
"display" : "More than half the days",
|
||||
"property" : [{
|
||||
"code" : "itemWeight",
|
||||
"valueDecimal" : 2
|
||||
}]
|
||||
},
|
||||
{
|
||||
"code" : "Nearly every day",
|
||||
"display" : "Nearly every day",
|
||||
"property" : [{
|
||||
"code" : "itemWeight",
|
||||
"valueDecimal" : 4
|
||||
}]
|
||||
}]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue