WIP SubscriptionTopic conversion tests + initial work
This commit is contained in:
parent
48e86fa905
commit
a734a2f819
|
@ -0,0 +1,122 @@
|
|||
package org.hl7.fhir.convertors.conv43_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 org.hl7.fhir.convertors.conv43_50.resources43_50.Enumerations43_50;
|
||||
import org.hl7.fhir.r4b.model.Enumeration;
|
||||
import org.hl7.fhir.r4b.model.Resource;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SubscriptionTopic43_50 {
|
||||
public static org.hl7.fhir.r4b.model.SubscriptionTopic convertSubscriptionTopic(org.hl7.fhir.r5.model.SubscriptionTopic src) {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r4b.model.SubscriptionTopic tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic();
|
||||
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
|
||||
if (src.hasUrl())
|
||||
tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement()));
|
||||
for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
|
||||
tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
|
||||
if (src.hasTitle())
|
||||
tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
|
||||
for (org.hl7.fhir.r5.model.CanonicalType t : src.getDerivedFrom())
|
||||
tgt.getDerivedFrom().add(Canonical43_50.convertCanonical(t));
|
||||
if (src.hasStatus())
|
||||
tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
|
||||
if (src.hasVersion())
|
||||
tgt.setVersionElement(String43_50.convertString(src.getVersionElement()));
|
||||
if (src.hasTitle())
|
||||
tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
|
||||
if (src.hasStatus())
|
||||
tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
|
||||
if (src.hasExperimental())
|
||||
tgt.setExperimentalElement(Boolean43_50.convertBoolean(src.getExperimentalElement()));
|
||||
if (src.hasDate())
|
||||
tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
|
||||
if (src.hasPublisher())
|
||||
tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement()));
|
||||
for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
|
||||
tgt.addContact(ContactDetail43_50.convertContactDetail(t));
|
||||
if (src.hasDescription())
|
||||
tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
|
||||
for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
|
||||
tgt.addUseContext(UsageContext43_50.convertUsageContext(t));
|
||||
for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
|
||||
tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept(t));
|
||||
if (src.hasPurpose())
|
||||
tgt.setPurposeElement(MarkDown43_50.convertMarkdown(src.getPurposeElement()));
|
||||
if (src.hasCopyright())
|
||||
tgt.setCopyrightElement(MarkDown43_50.convertMarkdown(src.getCopyrightElement()));
|
||||
if (src.hasApprovalDate())
|
||||
tgt.setApprovalDateElement(Date43_50.convertDate(src.getApprovalDateElement()));
|
||||
if (src.hasLastReviewDate())
|
||||
tgt.setLastReviewDateElement(Date43_50.convertDate(src.getLastReviewDateElement()));
|
||||
if (src.hasEffectivePeriod())
|
||||
tgt.setEffectivePeriod(Period43_50.convertPeriod(src.getEffectivePeriod()));
|
||||
for(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent triggerComponent : src.getResourceTrigger()) {
|
||||
tgt.addResourceTrigger(convertResourceTrigger(triggerComponent));}
|
||||
return tgt;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent convertResourceTrigger(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent src) {
|
||||
org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent();
|
||||
ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
|
||||
if (src.hasDescription()) {
|
||||
tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
|
||||
}
|
||||
if (src.hasResource()) {
|
||||
tgt.setResource(src.getResource());
|
||||
}
|
||||
if (src.hasSupportedInteraction()) {
|
||||
for (org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger> srcItem : src.getSupportedInteraction()) {
|
||||
tgt.addSupportedInteraction(convertInteractionTrigger(srcItem.getValue()));
|
||||
}
|
||||
}
|
||||
if (src.hasQueryCriteria()) {
|
||||
tgt.setQueryCriteria(convertResourceTriggerQueryCriteriaComponent(src.getQueryCriteria()));
|
||||
}
|
||||
if (src.hasFhirPathCriteria()) {
|
||||
tgt.setFhirPathCriteriaElement(String43_50.convertString(src.getFhirPathCriteriaElement()));
|
||||
}
|
||||
return tgt;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent convertResourceTriggerQueryCriteriaComponent(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent src) {
|
||||
org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent();
|
||||
if (src.hasPrevious()) {
|
||||
tgt.setPreviousElement(String43_50.convertString(src.getPreviousElement()));
|
||||
}
|
||||
if (src.hasCurrent()) {
|
||||
tgt.setCurrentElement(String43_50.convertString(src.getCurrentElement()));
|
||||
}
|
||||
return tgt;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger convertInteractionTrigger(org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger value) {
|
||||
switch(value) {
|
||||
case CREATE : return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.CREATE;
|
||||
case UPDATE: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.UPDATE;
|
||||
case DELETE: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.DELETE;
|
||||
case NULL: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.NULL;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static org.hl7.fhir.r5.model.SubscriptionTopic convertSubscriptionTopic(org.hl7.fhir.r4b.model.SubscriptionTopic src) {
|
||||
if (src == null)
|
||||
return null;
|
||||
org.hl7.fhir.r5.model.SubscriptionTopic tgt = new org.hl7.fhir.r5.model.SubscriptionTopic();
|
||||
return tgt;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
@ -9,6 +10,7 @@ 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 {
|
||||
|
||||
|
@ -244,6 +246,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.SubscriptionTopic)
|
||||
return SubscriptionTopic43_50.convertSubscriptionTopic((org.hl7.fhir.r4b.model.SubscriptionTopic)src);
|
||||
if (src instanceof org.hl7.fhir.r4b.model.Substance)
|
||||
return Substance43_50.convertSubstance((org.hl7.fhir.r4b.model.Substance) src);
|
||||
if (src instanceof org.hl7.fhir.r4b.model.SupplyDelivery)
|
||||
|
@ -478,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.SubscriptionTopic)
|
||||
return SubscriptionTopic43_50.convertSubscriptionTopic((org.hl7.fhir.r5.model.SubscriptionTopic)src);
|
||||
if (src instanceof org.hl7.fhir.r5.model.Substance)
|
||||
return Substance43_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src);
|
||||
if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
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 SubscriptionTopic43_50Test {
|
||||
|
||||
@Test
|
||||
@DisplayName("Test r5 -> r4 SubscriptionTopic conversion.")
|
||||
public void testR5_R4() throws IOException {
|
||||
InputStream r5_input = this.getClass().getResourceAsStream("/subscription_topic_50.json");
|
||||
|
||||
org.hl7.fhir.r5.model.SubscriptionTopic r5_actual = (org.hl7.fhir.r5.model.SubscriptionTopic) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input);
|
||||
org.hl7.fhir.r4b.model.Resource r4_conv = VersionConvertorFactory_43_50.convertResource(r5_actual);
|
||||
|
||||
org.hl7.fhir.r4b.formats.XmlParser r4_parser = new org.hl7.fhir.r4b.formats.XmlParser();
|
||||
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
r4_parser.compose(stream, r4_conv);
|
||||
|
||||
org.hl7.fhir.r4b.model.Resource r4_streamed = new org.hl7.fhir.r4b.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray()));
|
||||
org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_43_50.convertResource(r4_streamed);
|
||||
|
||||
assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"resourceType" : "SubscriptionTopic",
|
||||
"id" : "example",
|
||||
"text" : {
|
||||
"status" : "generated",
|
||||
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: SubscriptionTopic</b><a name=\"example\"> </a></p><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Resource SubscriptionTopic "example" </p></div><p><b>url</b>: <code>http://example.org/FHIR/R5/SubscriptionTopic/example</code></p><p><b>identifier</b>: id:\u00a0urn:uuid:1caa02ba-051b-4602-8856-65921748ae76</p><p><b>version</b>: 1.0.0-beta.1</p><p><b>title</b>: example</p><p><b>status</b>: draft</p><p><b>date</b>: 2019-01-01</p><p><b>description</b>: Example topic for completed encounters</p><blockquote><p><b>resourceTrigger</b></p><p><b>description</b>: An Encounter has been completed</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>supportedInteraction</b>: update</p><h3>QueryCriteria</h3><table class=\"grid\"><tr><td>-</td><td><b>Previous</b></td><td><b>ResultForCreate</b></td><td><b>Current</b></td><td><b>ResultForDelete</b></td><td><b>RequireBoth</b></td></tr><tr><td>*</td><td>status:not=completed</td><td>test-passes</td><td>status=completed</td><td>test-fails</td><td>true</td></tr></table><p><b>fhirPathCriteria</b>: (%previous.empty() | (%previous.status != 'completed')) and (%current.status = 'completed')</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: subject</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the group membership of the subject of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: _in</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the length of an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: length</p><p><b>comparator</b>: gt, lt, ge, le</p></blockquote><blockquote><p><b>canFilterBy</b></p><p><b>description</b>: Filter based on the account for billing an encounter.</p><p><b>resource</b>: <a href=\"encounter.html\">Encounter</a></p><p><b>filterParameter</b>: account</p><p><b>modifier</b>: missing, not, identifier</p></blockquote><h3>NotificationShapes</h3><table class=\"grid\"><tr><td>-</td><td><b>Resource</b></td><td><b>Include</b></td></tr><tr><td>*</td><td><a href=\"encounter.html\">Encounter</a></td><td>Encounter:patient&iterate=Patient.link, Encounter:practitioner, Encounter:service-provider, Encounter:account, Encounter:diagnosis, Encounter:observation, Encounter:location</td></tr></table></div>"
|
||||
},
|
||||
"url" : "http://example.org/FHIR/R5/SubscriptionTopic/example",
|
||||
"identifier" : [{
|
||||
"system" : "urn:ietf:rfc:3986",
|
||||
"value" : "urn:uuid:1caa02ba-051b-4602-8856-65921748ae76"
|
||||
}],
|
||||
"version" : "1.0.0-beta.1",
|
||||
"title" : "example",
|
||||
"status" : "draft",
|
||||
"date" : "2019-01-01",
|
||||
"description" : "Example topic for completed encounters",
|
||||
"resourceTrigger" : [{
|
||||
"description" : "An Encounter has been completed",
|
||||
"resource" : "http://hl7.org/fhir/StructureDefinition/Encounter",
|
||||
"supportedInteraction" : ["update"],
|
||||
"queryCriteria" : {
|
||||
"previous" : "status:not=completed",
|
||||
"resultForCreate" : "test-passes",
|
||||
"current" : "status=completed",
|
||||
"resultForDelete" : "test-fails",
|
||||
"requireBoth" : true
|
||||
},
|
||||
"fhirPathCriteria" : "(%previous.empty() | (%previous.status != 'completed')) and (%current.status = 'completed')"
|
||||
}],
|
||||
"canFilterBy" : [{
|
||||
"description" : "Filter based on the subject of an encounter.",
|
||||
"resource" : "Encounter",
|
||||
"filterParameter" : "subject"
|
||||
},
|
||||
{
|
||||
"description" : "Filter based on the group membership of the subject of an encounter.",
|
||||
"resource" : "Encounter",
|
||||
"filterParameter" : "_in"
|
||||
},
|
||||
{
|
||||
"description" : "Filter based on the length of an encounter.",
|
||||
"resource" : "Encounter",
|
||||
"filterParameter" : "length",
|
||||
"comparator" : ["gt",
|
||||
"lt",
|
||||
"ge",
|
||||
"le"]
|
||||
},
|
||||
{
|
||||
"description" : "Filter based on the account for billing an encounter.",
|
||||
"resource" : "Encounter",
|
||||
"filterParameter" : "account",
|
||||
"modifier" : ["missing",
|
||||
"not",
|
||||
"identifier"]
|
||||
}],
|
||||
"notificationShape" : [{
|
||||
"resource" : "Encounter",
|
||||
"include" : ["Encounter:patient&iterate=Patient.link",
|
||||
"Encounter:practitioner",
|
||||
"Encounter:service-provider",
|
||||
"Encounter:account",
|
||||
"Encounter:diagnosis",
|
||||
"Encounter:observation",
|
||||
"Encounter:location"]
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue