diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/resources30_40/CapabilityStatement30_40.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/resources30_40/CapabilityStatement30_40.java index 81b110c18..025ebaccb 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/resources30_40/CapabilityStatement30_40.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_40/resources30_40/CapabilityStatement30_40.java @@ -24,7 +24,6 @@ public class CapabilityStatement30_40 { if (src == null) return null; org.hl7.fhir.dstu3.model.CapabilityStatement tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement(); - //FIXME add ignore ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement())); diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java index 04788034b..19ea47cde 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/CapabilityStatement30_50.java @@ -20,26 +20,11 @@ import org.hl7.fhir.exceptions.FHIRException; public class CapabilityStatement30_50 { - public static final String ACCEPT_UNKNOWN_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown"; - public static final String PROFILE_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile"; - - public static final String ACCEPT_LANGUAGE_EXTENSION_URL = "http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptLanguage"; - - private static final String[] IGNORED_R5_EXTENSION_URLS = new String[]{ - - ACCEPT_UNKNOWN_EXTENSION_URL - }; - - private static final String[] IGNORED_DSTU3_EXTENSION_URLS = new String[]{ - PROFILE_EXTENSION_URL, - ACCEPT_LANGUAGE_EXTENSION_URL - }; public static org.hl7.fhir.r5.model.CapabilityStatement convertCapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement src) throws FHIRException { if (src == null) return null; org.hl7.fhir.r5.model.CapabilityStatement tgt = new org.hl7.fhir.r5.model.CapabilityStatement(); - //FIXME add ignore - ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_DSTU3_EXTENSION_URLS); + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); if (src.hasVersion()) @@ -78,17 +63,14 @@ public class CapabilityStatement30_50 { if (src.hasFhirVersion()) tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(fixCode(src.getFhirVersion()))); if (src.hasAcceptUnknown()) - tgt.addExtension().setUrl(ACCEPT_UNKNOWN_EXTENSION_URL).setValue(new org.hl7.fhir.r5.model.CodeType(src.getAcceptUnknownElement().asStringValue())); + tgt.addExtension().setUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").setValue(new org.hl7.fhir.r5.model.CodeType(src.getAcceptUnknownElement().asStringValue())); for (org.hl7.fhir.dstu3.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.dstu3.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue()); - for (org.hl7.fhir.dstu3.model.Extension extension : src.getExtensionsByUrl(ACCEPT_LANGUAGE_EXTENSION_URL)) { - tgt.addAcceptLanguageElement().setValue(extension.getValue().primitiveValue()); - } for (org.hl7.fhir.dstu3.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue()); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementRestComponent t : src.getRest()) tgt.addRest(convertCapabilityStatementRestComponent(t)); for (org.hl7.fhir.dstu3.model.Reference t : src.getProfile()) - tgt.addExtension(PROFILE_EXTENSION_URL, Reference30_50.convertReference(t)); + tgt.addExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile", Reference30_50.convertReference(t)); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementMessagingComponent t : src.getMessaging()) tgt.addMessaging(convertCapabilityStatementMessagingComponent(t)); for (org.hl7.fhir.dstu3.model.CapabilityStatement.CapabilityStatementDocumentComponent t : src.getDocument()) @@ -108,7 +90,7 @@ public class CapabilityStatement30_50 { if (src == null) return null; org.hl7.fhir.dstu3.model.CapabilityStatement tgt = new org.hl7.fhir.dstu3.model.CapabilityStatement(); - ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_R5_EXTENSION_URLS); + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); if (src.hasUrl()) tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement())); if (src.hasVersion()) @@ -146,20 +128,17 @@ public class CapabilityStatement30_50 { tgt.setImplementation(convertCapabilityStatementImplementationComponent(src.getImplementation())); if (src.hasFhirVersion()) tgt.setFhirVersion(src.getFhirVersion().toCode()); - if (src.hasExtension(ACCEPT_UNKNOWN_EXTENSION_URL)) - tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(src.getExtensionByUrl(ACCEPT_UNKNOWN_EXTENSION_URL).getValue().primitiveValue())); + if (src.hasExtension("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown")) + tgt.setAcceptUnknown(org.hl7.fhir.dstu3.model.CapabilityStatement.UnknownContentCode.fromCode(src.getExtensionByUrl("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.acceptUnknown").getValue().primitiveValue())); for (org.hl7.fhir.r5.model.CodeType t : src.getFormat()) tgt.addFormat(t.getValue()); for (org.hl7.fhir.r5.model.CodeType t : src.getPatchFormat()) tgt.addPatchFormat(t.getValue()); - for (org.hl7.fhir.r5.model.CodeType t : src.getAcceptLanguage()) { - tgt.addExtension(ACCEPT_LANGUAGE_EXTENSION_URL, Code30_50.convertCodeToString(t)); - } for (org.hl7.fhir.r5.model.UriType t : src.getImplementationGuide()) tgt.addImplementationGuide(t.getValue()); for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestComponent r : src.getRest()) for (org.hl7.fhir.r5.model.CapabilityStatement.CapabilityStatementRestResourceComponent rr : r.getResource()) for (org.hl7.fhir.r5.model.CanonicalType t : rr.getSupportedProfile()) tgt.addProfile(Reference30_50.convertCanonicalToReference(t)); for (org.hl7.fhir.r5.model.Extension ext : src.getExtension()) { - if (PROFILE_EXTENSION_URL.equals(ext.getUrl())) { + if ("http://hl7.org/fhir/3.0/StructureDefinition/extension-CapabilityStatement.profile".equals(ext.getUrl())) { tgt.addProfile(Reference30_50.convertReference((org.hl7.fhir.r5.model.Reference) ext.getValue())); } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/CapabilityStatement30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/CapabilityStatement30_50Test.java deleted file mode 100644 index 2f1161066..000000000 --- a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/CapabilityStatement30_50Test.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.hl7.fhir.convertors.conv30_50; - -import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; -import org.hl7.fhir.r5.formats.JsonParser; -import org.junit.jupiter.api.Disabled; -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 CapabilityStatement30_50Test { - - - @Test - @DisplayName("Test r5 -> dstu3 capabilityStatement conversion.") - public void testR5_DSTU3() throws IOException { - InputStream r5_input = this.getClass().getResourceAsStream("/capability_statement_50.json"); - - JsonParser r5_parser = new JsonParser(); - org.hl7.fhir.r5.model.CapabilityStatement r5_actual = (org.hl7.fhir.r5.model.CapabilityStatement) r5_parser.parse(r5_input); - org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_50.convertResource(r5_actual); - - org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser(); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - dstu3_parser.compose(stream, dstu3_conv); - - org.hl7.fhir.dstu3.model.Resource dstu3_streamed = (org.hl7.fhir.dstu3.model.CapabilityStatement) dstu3_parser.parse(new ByteArrayInputStream(stream.toByteArray())); - org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_30_50.convertResource(dstu3_streamed); - - assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); - } - -} diff --git a/org.hl7.fhir.convertors/src/test/resources/capability_statement_50.json b/org.hl7.fhir.convertors/src/test/resources/capability_statement_50.json deleted file mode 100644 index fa1a4a9a2..000000000 --- a/org.hl7.fhir.convertors/src/test/resources/capability_statement_50.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "resourceType" : "CapabilityStatement", - "id" : "example", - "text" : { - "status" : "generated", - "div" : "
\n\t\t\t\n

The EHR Server supports the following transactions for the resource Person: read, vread, \n update, history, search(name,gender), create and updates.

\n\t\t\t\n

The EHR System supports the following message: admin-notify::Person.

\n\t\t\t\n

The EHR Application has a \n \n general document profile.\n \n

\n\t\t\n
" - }, - "url" : "urn:uuid:68d043b5-9ecf-4559-a57a-396e0d452311", - "version" : "20130510", - "name" : "ACMEEHR", - "title" : "ACME EHR capability statement", - "status" : "draft", - "experimental" : true, - "date" : "2012-01-04", - "publisher" : "ACME Corporation", - "contact" : [{ - "name" : "System Administrator", - "telecom" : [{ - "system" : "email", - "value" : "wile@acme.org" - }] - }], - "description" : "This is the FHIR capability statement for the main EHR at ACME for the private interface - it does not describe the public interface", - "useContext" : [{ - "code" : { - "system" : "http://terminology.hl7.org/CodeSystem/usage-context-type", - "code" : "focus" - }, - "valueCodeableConcept" : { - "coding" : [{ - "system" : "http://terminology.hl7.org/CodeSystem/variant-state", - "code" : "positive" - }] - } - }], - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "US", - "display" : "United States of America (the)" - }] - }], - "purpose" : "Main EHR capability statement, published for contracting and operational support", - "copyright" : "Copyright © Acme Healthcare and GoodCorp EHR Systems", - "kind" : "instance", - "instantiates" : ["http://ihe.org/fhir/CapabilityStatement/pixm-client"], - "software" : { - "name" : "EHR", - "version" : "0.00.020.2134", - "releaseDate" : "2012-01-04" - }, - "implementation" : { - "description" : "main EHR at ACME", - "url" : "http://10.2.3.4/fhir" - }, - "fhirVersion" : "5.0.0", - "format" : ["xml", - "json"], - "patchFormat" : ["application/xml-patch+xml", - "application/json-patch+json"], - "acceptLanguage" : ["en", - "es"], - "implementationGuide" : ["http://example.org/fhir/us/lab"], - "rest" : [{ - "mode" : "server", - "documentation" : "Main FHIR endpoint for acem health", - "security" : { - "cors" : true, - "service" : [{ - "coding" : [{ - "system" : "http://hl7.org/fhir/restful-security-service", - "code" : "SMART-on-FHIR" - }] - }], - "description" : "See Smart on FHIR documentation" - }, - "resource" : [{ - "type" : "Patient", - "profile" : "http://registry.fhir.org/r5/StructureDefinition/7896271d-57f6-4231-89dc-dcc91eab2416", - "supportedProfile" : ["http://registry.fhir.org/r5/StructureDefinition/00ab9e7a-06c7-4f77-9234-4154ca1e3347"], - "documentation" : "This server does not let the clients create identities.", - "interaction" : [{ - "code" : "read" - }, - { - "code" : "vread", - "documentation" : "Only supported for patient records since 12-Dec 2012" - }, - { - "code" : "update" - }, - { - "code" : "history-instance" - }, - { - "code" : "create" - }, - { - "code" : "history-type" - }], - "versioning" : "versioned-update", - "readHistory" : true, - "updateCreate" : false, - "conditionalCreate" : true, - "conditionalRead" : "full-support", - "conditionalUpdate" : false, - "conditionalPatch" : false, - "conditionalDelete" : "not-supported", - "searchInclude" : ["Patient:organization"], - "searchRevInclude" : ["Person:patient"], - "searchParam" : [{ - "name" : "identifier", - "definition" : "http://hl7.org/fhir/SearchParameter/Patient-identifier", - "type" : "token", - "documentation" : "Only supports search by institution MRN" - }, - { - "name" : "general-practitioner", - "definition" : "http://hl7.org/fhir/SearchParameter/Patient-general-practitioner", - "type" : "reference" - }] - }], - "interaction" : [{ - "code" : "transaction" - }, - { - "code" : "history-system" - }], - "compartment" : ["http://hl7.org/fhir/CompartmentDefinition/patient"] - }], - "messaging" : [{ - "endpoint" : [{ - "protocol" : { - "system" : "http://hl7.org/fhir/message-transport", - "code" : "mllp" - }, - "address" : "mllp:10.1.1.10:9234" - }], - "reliableCache" : 30, - "documentation" : "ADT A08 equivalent for external system notifications", - "supportedMessage" : [{ - "mode" : "receiver", - "definition" : "http://hl7.org/fhir/MessageDefinition/example" - }] - }], - "document" : [{ - "mode" : "consumer", - "documentation" : "Basic rules for all documents in the EHR system", - "profile" : "http://fhir.hl7.org/base/Profilebc054d23-75e1-4dc6-aca5-838b6b1ac81d/_history/b5fdd9fc-b021-4ea1-911a-721a60663796" - }] -} \ No newline at end of file