More test prep, start conversion work

This commit is contained in:
dotasek 2023-04-17 18:12:55 -04:00
parent 9c3e3c918e
commit d8ac44fee4
4 changed files with 94 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package org.hl7.fhir.convertors.conv43_50.resources43_50;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_43_50;
import org.hl7.fhir.convertors.context.ConversionContext43_50;
import org.hl7.fhir.convertors.conv43_50.SubscriptionTopic43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Code43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Id43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
@ -10,7 +9,6 @@ import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Extension43
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Meta43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Narrative43_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.SubscriptionTopic;
public class Resource43_50 {
@ -246,6 +244,8 @@ public class Resource43_50 {
return StructureDefinition43_50.convertStructureDefinition((org.hl7.fhir.r4b.model.StructureDefinition) src);
if (src instanceof org.hl7.fhir.r4b.model.StructureMap)
return StructureMap43_50.convertStructureMap((org.hl7.fhir.r4b.model.StructureMap) src);
if (src instanceof org.hl7.fhir.r4b.model.SubscriptionStatus)
return SubscriptionStatus43_50.convertSubscriptionStatus((org.hl7.fhir.r4b.model.SubscriptionStatus)src);
if (src instanceof org.hl7.fhir.r4b.model.SubscriptionTopic)
return SubscriptionTopic43_50.convertSubscriptionTopic((org.hl7.fhir.r4b.model.SubscriptionTopic)src);
if (src instanceof org.hl7.fhir.r4b.model.Substance)
@ -482,6 +482,8 @@ public class Resource43_50 {
return StructureDefinition43_50.convertStructureDefinition((org.hl7.fhir.r5.model.StructureDefinition) src);
if (src instanceof org.hl7.fhir.r5.model.StructureMap)
return StructureMap43_50.convertStructureMap((org.hl7.fhir.r5.model.StructureMap) src);
if (src instanceof org.hl7.fhir.r5.model.SubscriptionStatus)
return SubscriptionStatus43_50.convertSubscriptionStatus((org.hl7.fhir.r5.model.SubscriptionStatus)src);
if (src instanceof org.hl7.fhir.r5.model.SubscriptionTopic)
return SubscriptionTopic43_50.convertSubscriptionTopic((org.hl7.fhir.r5.model.SubscriptionTopic)src);
if (src instanceof org.hl7.fhir.r5.model.Substance)

View File

@ -0,0 +1,36 @@
package org.hl7.fhir.convertors.conv43_50.resources43_50;
import org.hl7.fhir.convertors.context.ConversionContext43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.*;
import java.util.stream.Collectors;
public class SubscriptionStatus43_50 {
public static org.hl7.fhir.r4b.model.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.r5.model.SubscriptionStatus src) {
if (src == null)
return null;
org.hl7.fhir.r4b.model.SubscriptionStatus tgt = new org.hl7.fhir.r4b.model.SubscriptionStatus();
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyResource(src, tgt);
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
return tgt;
}
public static org.hl7.fhir.r5.model.SubscriptionStatus convertSubscriptionStatus(org.hl7.fhir.r4b.model.SubscriptionStatus src) {
if (src == null)
return null;
org.hl7.fhir.r5.model.SubscriptionStatus tgt = new org.hl7.fhir.r5.model.SubscriptionStatus();
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyResource(src, tgt);
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
return tgt;
}
}

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.convertors.conv43_50;
package org.hl7.fhir.convertors.conv43_50.resources43_50;
import org.hl7.fhir.convertors.context.ConversionContext43_50;
import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;

View File

@ -0,0 +1,53 @@
package org.hl7.fhir.convertors.conv43_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SubscriptionStatus43_50Test {
@Test
@DisplayName("Test r5 -> r4 SubscriptionTopic conversion.")
public void testR5_R4b() throws IOException {
InputStream r5_input = this.getClass().getResourceAsStream("/subscription_status_50.json");
org.hl7.fhir.r5.model.SubscriptionStatus r5_actual = (org.hl7.fhir.r5.model.SubscriptionStatus) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input);
org.hl7.fhir.r4b.model.Resource r4b_conv = VersionConvertorFactory_43_50.convertResource(r5_actual);
org.hl7.fhir.r4b.formats.JsonParser r4b_parser = new org.hl7.fhir.r4b.formats.JsonParser();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
r4b_parser.compose(stream, r4b_conv);
org.hl7.fhir.r4b.model.Resource r4b_streamed = new org.hl7.fhir.r4b.formats.JsonParser().parse(new ByteArrayInputStream(stream.toByteArray()));
org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4b_streamed);
assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same");
}
@Test
@DisplayName("Test r4b -> r5 SubscriptionTopic conversion.")
public void testR4b_R5() throws IOException {
InputStream r4b_input = this.getClass().getResourceAsStream("/subscription_status_43.json");
org.hl7.fhir.r4b.model.SubscriptionStatus r4b_actual = (org.hl7.fhir.r4b.model.SubscriptionStatus) new org.hl7.fhir.r4b.formats.JsonParser().parse(r4b_input);
org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4b_actual);
org.hl7.fhir.r5.formats.JsonParser r5_parser = new org.hl7.fhir.r5.formats.JsonParser();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
r5_parser.compose(stream, r5_conv);
org.hl7.fhir.r5.model.Resource r5_streamed = new org.hl7.fhir.r5.formats.JsonParser().parse(new ByteArrayInputStream(stream.toByteArray()));
org.hl7.fhir.r4b.model.Resource r4b_conv = VersionConvertorFactory_43_50.convertResource(r5_streamed);
assertTrue(r4b_actual.equalsDeep(r4b_conv), "should be the same");
}
}