From e9c2a5f622bc3508c746f54bef653f6a6be1140b Mon Sep 17 00:00:00 2001 From: Richard Ettema Date: Thu, 18 May 2023 17:36:21 -0400 Subject: [PATCH 1/3] #1264 add R5 TestPlan conversion classes to R3, R4 and R4B --- .../convertors/conv30_50/Resource30_50.java | 5 + .../resources30_50/TestPlan30_50.java | 555 ++++++++++++++++++ .../resources40_50/Resource40_50.java | 4 + .../resources40_50/TestPlan40_50.java | 555 ++++++++++++++++++ .../resources43_50/Resource43_50.java | 4 + .../resources43_50/TestPlan43_50.java | 555 ++++++++++++++++++ .../fhir/r5/renderers/RendererFactory.java | 5 +- .../r5/renderers/RequirementsRenderer.java | 35 ++ .../fhir/r5/renderers/TestPlanRenderer.java | 343 +++++++++++ 9 files changed, 2060 insertions(+), 1 deletion(-) create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java create mode 100644 org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TestPlanRenderer.java diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/Resource30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/Resource30_50.java index 9b1a5cb47..9a125d3f0 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/Resource30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/Resource30_50.java @@ -85,6 +85,7 @@ import org.hl7.fhir.convertors.conv30_50.resources30_50.StructureDefinition30_50 import org.hl7.fhir.convertors.conv30_50.resources30_50.StructureMap30_50; import org.hl7.fhir.convertors.conv30_50.resources30_50.Substance30_50; import org.hl7.fhir.convertors.conv30_50.resources30_50.SupplyDelivery30_50; +import org.hl7.fhir.convertors.conv30_50.resources30_50.TestPlan30_50; import org.hl7.fhir.convertors.conv30_50.resources30_50.TestReport30_50; import org.hl7.fhir.convertors.conv30_50.resources30_50.TestScript30_50; import org.hl7.fhir.convertors.conv30_50.resources30_50.ValueSet30_50; @@ -135,6 +136,8 @@ public class Resource30_50 { return ActorDefinition30_50.convertActorDefinition((org.hl7.fhir.dstu3.model.Basic) src); } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { return Requirements30_50.convertRequirements((org.hl7.fhir.dstu3.model.Basic) src); + } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + return TestPlan30_50.convertTestPlan((org.hl7.fhir.dstu3.model.Basic) src); } else { return Basic30_50.convertBasic((org.hl7.fhir.dstu3.model.Basic) src); } @@ -439,6 +442,8 @@ public class Resource30_50 { return Substance30_50.convertSubstance((org.hl7.fhir.r5.model.Substance) src); if (src instanceof org.hl7.fhir.r5.model.SupplyDelivery) return SupplyDelivery30_50.convertSupplyDelivery((org.hl7.fhir.r5.model.SupplyDelivery) src); + if (src instanceof org.hl7.fhir.r5.model.TestPlan) + return TestPlan30_50.convertTestPlan((org.hl7.fhir.r5.model.TestPlan) src); if (src instanceof org.hl7.fhir.r5.model.TestReport) return TestReport30_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); if (src instanceof org.hl7.fhir.r5.model.TestScript) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java new file mode 100644 index 000000000..d7dc227f4 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java @@ -0,0 +1,555 @@ +package org.hl7.fhir.convertors.conv30_50.resources30_50; + +import org.hl7.fhir.convertors.context.ConversionContext30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Coding30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Integer30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50; +import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.dstu3.model.Extension; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.TestPlan.TestCaseDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseAssertionComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestDataComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunScriptComponent; +import org.hl7.fhir.r5.model.UsageContext; + +/* +Copyright (c) 2011+, HL7, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ +//Generated on Thu, Mar 11, 2023 14:26+0500 for FHIR v4.0.0 +public class TestPlan30_50 { + + public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.url"; + public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.version"; + public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.name"; + public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.title"; + public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.status"; + public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.experimental"; + public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.date"; + public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.publisher"; + public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.contact"; + public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.description"; + public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.useContext"; + public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.jurisdiction"; + public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.purpose"; + public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyright"; + public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyrightLabel"; + public static final String CATEGORY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.category"; + public static final String SCOPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.scope"; + public static final String TESTTOOLS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testTools"; + public static final String DEPENDENCY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency"; + public static final String EXITCRITERIA_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.exitCriteria"; + public static final String TESTCASE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + URL_EXTENSION_URL, + VERSION_EXTENSION_URL, + NAME_EXTENSION_URL, + TITLE_EXTENSION_URL, + STATUS_EXTENSION_URL, + EXPERIMENTAL_EXTENSION_URL, + DATE_EXTENSION_URL, + PUBLISHER_EXTENSION_URL, + CONTACT_EXTENSION_URL, + DESCRIPTION_EXTENSION_URL, + USE_CONTEXT_EXTENSION_URL, + JURISDICTION_EXTENSION_URL, + PURPOSE_EXTENSION_URL, + COPYRIGHT_EXTENSION_URL, + COPYRIGHT_LABEL_EXTENSION_URL, + CATEGORY_EXTENSION_URL, + SCOPE_EXTENSION_URL, + TESTTOOLS_EXTENSION_URL, + DEPENDENCY_EXTENSION_URL, + EXITCRITERIA_EXTENSION_URL, + TESTCASE_EXTENSION_URL + }; + + public static org.hl7.fhir.r5.model.TestPlan convertTestPlan(org.hl7.fhir.dstu3.model.Basic src) throws FHIRException { + if (src == null) + return null; + if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + throw new FHIRException("Error in logic: this basic resource is not an TestPlan"); + } + org.hl7.fhir.r5.model.TestPlan tgt = new org.hl7.fhir.r5.model.TestPlan(); + + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); + + for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); + } + if (src.hasExtension(URL_EXTENSION_URL)) { + tgt.setUrlElement(Uri30_50.convertUri((org.hl7.fhir.dstu3.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(VERSION_EXTENSION_URL)) { + tgt.setVersionElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue())); + } + if (src.hasExtension(NAME_EXTENSION_URL)) { + tgt.setNameElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue())); + } + if (src.hasExtension(TITLE_EXTENSION_URL)) { + tgt.setTitleElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(STATUS_EXTENSION_URL)) { + tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue())); + } + if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) { + tgt.setExperimentalElement(Boolean30_50.convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(DATE_EXTENSION_URL)) { + tgt.setDateElement(DateTime30_50.convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(PUBLISHER_EXTENSION_URL)) { + tgt.setPublisherElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) { + tgt.addContact(ContactDetail30_50.convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) ext.getValue())); + } + if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { + tgt.setPublisherElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { + tgt.addUseContext(UsageContext30_50.convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) { + tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) ext.getValue())); + } + if (src.hasExtension(PURPOSE_EXTENSION_URL)) { + tgt.setPurposeElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) { + tgt.setCopyrightElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) { + tgt.setCopyrightLabelElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(CATEGORY_EXTENSION_URL)) { + tgt.addCategory(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(SCOPE_EXTENSION_URL)) { + tgt.getScope().add(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) ext.getValue())); + } + if (src.hasExtension(TESTTOOLS_EXTENSION_URL)) { + tgt.setTestToolsElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(TESTTOOLS_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(DEPENDENCY_EXTENSION_URL)) { + convertTestPlanDependency(ext, tgt.addDependency()); + } + if (src.hasExtension(EXITCRITERIA_EXTENSION_URL)) { + tgt.setExitCriteriaElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(EXITCRITERIA_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(TESTCASE_EXTENSION_URL)) { + convertTestPlanTestCase(ext, tgt.addTestCase()); + } + return tgt; + } + + public static org.hl7.fhir.dstu3.model.Basic convertTestPlan(org.hl7.fhir.r5.model.TestPlan src) throws FHIRException { + if (src == null) + return null; + org.hl7.fhir.dstu3.model.Basic tgt = new org.hl7.fhir.dstu3.model.Basic(); + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); + tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("TestPlan"); // note use of R5 type system + + for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); + } + if (src.hasUrl()) { + tgt.addExtension(URL_EXTENSION_URL, Uri30_50.convertUri(src.getUrlElement())); + } + if (src.hasVersion()) { + tgt.addExtension(VERSION_EXTENSION_URL, String30_50.convertString(src.getVersionElement())); + } + if (src.hasName()) { + tgt.addExtension(NAME_EXTENSION_URL, String30_50.convertString(src.getNameElement())); + } + if (src.hasTitle()) { + tgt.addExtension(TITLE_EXTENSION_URL, String30_50.convertString(src.getTitleElement())); + } + if (src.hasStatus()) { + tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.dstu3.model.CodeType(src.getStatus().toCode())); + } + if (src.hasExperimental()) { + tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean30_50.convertBoolean(src.getExperimentalElement())); + } + if (src.hasDate()) { + tgt.addExtension(DATE_EXTENSION_URL, DateTime30_50.convertDateTime(src.getDateElement())); + } + if (src.hasPublisher()) { + tgt.addExtension(PUBLISHER_EXTENSION_URL, String30_50.convertString(src.getPublisherElement())); + } + for (ContactDetail cd : src.getContact()) { + tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail30_50.convertContactDetail(cd)); + } + if (src.hasDescription()) { + tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getDescriptionElement())); + } + for (UsageContext cd : src.getUseContext()) { + tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext30_50.convertUsageContext(cd)); + } + for (CodeableConcept cd : src.getJurisdiction()) { + tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept30_50.convertCodeableConcept(cd)); + } + if (src.hasPurpose()) { + tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getPurposeElement())); + } + if (src.hasCopyright()) { + tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getCopyrightElement())); + } + if (src.hasCopyrightLabel()) { + tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String30_50.convertString(src.getCopyrightLabelElement())); + } + for (CodeableConcept cc : src.getCategory()) { + tgt.addExtension(CATEGORY_EXTENSION_URL, CodeableConcept30_50.convertCodeableConcept(cc)); + } + for (Reference ref : src.getScope()) { + tgt.addExtension(SCOPE_EXTENSION_URL, Reference30_50.convertReference(ref)); + } + if (src.hasTestTools()) { + tgt.addExtension(TESTTOOLS_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getTestToolsElement())); + } + for (TestPlanDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension(DEPENDENCY_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanDependency(ref, tgte); + } + if (src.hasExitCriteria()) { + tgt.addExtension(EXITCRITERIA_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getExitCriteriaElement())); + } + for (TestPlanTestCaseComponent ref : src.getTestCase()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension(TESTCASE_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanTestCase(ref, tgte); + } + + return tgt; + } + + /* + * R4 to R5 private methods + */ + + private static void convertTestPlanDependency(Extension src, TestPlanDependencyComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description")) { + tgt.setDescriptionElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor")) { + tgt.setPredecessor(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCase(Extension src, TestPlanTestCaseComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence")) { + tgt.setSequenceElement(Integer30_50.convertInteger((org.hl7.fhir.dstu3.model.IntegerType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence").getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope")) { + tgt.getScope().add(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency")) { + convertTestPlanTestCaseDependency(ext, tgt.addDependency()); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun")) { + convertTestPlanTestCaseTestRun(ext, tgt.addTestRun()); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData")) { + convertTestPlanTestCaseTestData(ext, tgt.addTestData()); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion")) { + convertTestPlanTestCaseAssertion(ext, tgt.addAssertion()); + } + } + + private static void convertTestPlanTestCaseDependency(Extension src, TestCaseDependencyComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description")) { + tgt.setDescriptionElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor")) { + tgt.setPredecessor(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCaseTestRun(Extension src, TestPlanTestCaseTestRunComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative")) { + tgt.setNarrativeElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script")) { + convertTestPlanTestCaseTestRunScript(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"), tgt.getScript()); + } + } + + private static void convertTestPlanTestCaseTestRunScript(Extension src, TestPlanTestCaseTestRunScriptComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language")) { + tgt.setLanguage(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString")) { + tgt.setSource(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference")) { + tgt.setSource(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseTestData(Extension src, TestPlanTestCaseTestDataComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type")) { + tgt.setType(Coding30_50.convertCoding((org.hl7.fhir.dstu3.model.Coding) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { + tgt.setContent(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { + tgt.setSource(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { + tgt.setSource(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertion(Extension src, TestPlanTestCaseAssertionComponent tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result" + ); + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type")) { + tgt.getType().add(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object")) { + convertTestPlanTestCaseAssertionObject(ext, tgt.addObject()); + } + for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result")) { + convertTestPlanTestCaseAssertionResult(ext, tgt.addResult()); + } + } + + private static void convertTestPlanTestCaseAssertionObject(Extension src, CodeableReference tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept")) { + tgt.setConcept(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference")) { + tgt.setReference(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(Extension src, CodeableReference tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept")) { + tgt.setConcept(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference")) { + tgt.setReference(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference").getValue())); + } + } + + + /* + * R5 to R4 private methods + */ + + private static void convertTestPlanDependency(TestPlanDependencyComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", MarkDown30_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor", Reference30_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCase(TestPlanTestCaseComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasSequenceElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", Integer30_50.convertInteger(src.getSequenceElement())); + } + for (Reference ref : src.getScope()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", Reference30_50.convertReference(ref)); + } + for (TestCaseDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency"); + tgt.addExtension(tgte); + convertTestPlanTestCaseDependency(ref, tgte); + } + for (TestPlanTestCaseTestRunComponent ref : src.getTestRun()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRun(ref, tgte); + } + for (TestPlanTestCaseTestDataComponent ref : src.getTestData()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestData(ref, tgte); + } + for (TestPlanTestCaseAssertionComponent ref : src.getAssertion()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertion(ref, tgte); + } + } + + private static void convertTestPlanTestCaseDependency(TestCaseDependencyComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", MarkDown30_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor", Reference30_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasNarrativeElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown30_50.convertMarkdown(src.getNarrativeElement())); + } + if (src.hasScript()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRunScript(src.getScript(), tgte); + } + } + + private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasLanguage()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept30_50.convertCodeableConcept(src.getLanguage())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String30_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference30_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding30_50.convertCoding(src.getType())); + } + if (src.hasContent()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference30_50.convertReference(src.getContent())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String30_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference30_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseAssertion(TestPlanTestCaseAssertionComponent src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + for (CodeableConcept cc : src.getType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", CodeableConcept30_50.convertCodeableConcept(cc)); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionObject(ref, tgte); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionResult(ref, tgte); + } + } + + private static void convertTestPlanTestCaseAssertionObject(CodeableReference src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.reference", Reference30_50.convertReference(src.getReference())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(CodeableReference src, Extension tgt) { + ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.reference", Reference30_50.convertReference(src.getReference())); + } + } + +} diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java index 1df2482e6..56455fc73 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/Resource40_50.java @@ -57,6 +57,8 @@ public class Resource40_50 { return ActorDefinition40_50.convertActorDefinition((org.hl7.fhir.r4.model.Basic) src); } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { return Requirements40_50.convertRequirements((org.hl7.fhir.r4.model.Basic) src); + } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + return TestPlan40_50.convertTestPlan((org.hl7.fhir.r4.model.Basic) src); } else { return Basic40_50.convertBasic((org.hl7.fhir.r4.model.Basic) src); } @@ -510,6 +512,8 @@ public class Resource40_50 { if (src instanceof org.hl7.fhir.r5.model.Task) return Task40_50.convertTask((org.hl7.fhir.r5.model.Task) src); if (src instanceof org.hl7.fhir.r5.model.TerminologyCapabilities) return TerminologyCapabilities40_50.convertTerminologyCapabilities((org.hl7.fhir.r5.model.TerminologyCapabilities) src); + if (src instanceof org.hl7.fhir.r5.model.TestPlan) + return TestPlan40_50.convertTestPlan((org.hl7.fhir.r5.model.TestPlan)src); if (src instanceof org.hl7.fhir.r5.model.TestReport) return TestReport40_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); if (src instanceof org.hl7.fhir.r5.model.TestScript) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java new file mode 100644 index 000000000..98132b0c2 --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java @@ -0,0 +1,555 @@ +package org.hl7.fhir.convertors.conv40_50.resources40_50; + +import org.hl7.fhir.convertors.context.ConversionContext40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50; +import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4.model.Extension; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.TestPlan.TestCaseDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseAssertionComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestDataComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunScriptComponent; +import org.hl7.fhir.r5.model.UsageContext; + +/* +Copyright (c) 2011+, HL7, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ +//Generated on Thu, Mar 11, 2023 14:26+0500 for FHIR v4.0.0 +public class TestPlan40_50 { + + public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.url"; + public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.version"; + public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.name"; + public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.title"; + public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.status"; + public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.experimental"; + public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.date"; + public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.publisher"; + public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.contact"; + public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.description"; + public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.useContext"; + public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.jurisdiction"; + public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.purpose"; + public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyright"; + public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyrightLabel"; + public static final String CATEGORY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.category"; + public static final String SCOPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.scope"; + public static final String TESTTOOLS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testTools"; + public static final String DEPENDENCY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency"; + public static final String EXITCRITERIA_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.exitCriteria"; + public static final String TESTCASE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + URL_EXTENSION_URL, + VERSION_EXTENSION_URL, + NAME_EXTENSION_URL, + TITLE_EXTENSION_URL, + STATUS_EXTENSION_URL, + EXPERIMENTAL_EXTENSION_URL, + DATE_EXTENSION_URL, + PUBLISHER_EXTENSION_URL, + CONTACT_EXTENSION_URL, + DESCRIPTION_EXTENSION_URL, + USE_CONTEXT_EXTENSION_URL, + JURISDICTION_EXTENSION_URL, + PURPOSE_EXTENSION_URL, + COPYRIGHT_EXTENSION_URL, + COPYRIGHT_LABEL_EXTENSION_URL, + CATEGORY_EXTENSION_URL, + SCOPE_EXTENSION_URL, + TESTTOOLS_EXTENSION_URL, + DEPENDENCY_EXTENSION_URL, + EXITCRITERIA_EXTENSION_URL, + TESTCASE_EXTENSION_URL + }; + + public static org.hl7.fhir.r5.model.TestPlan convertTestPlan(org.hl7.fhir.r4.model.Basic src) throws FHIRException { + if (src == null) + return null; + if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + throw new FHIRException("Error in logic: this basic resource is not an TestPlan"); + } + org.hl7.fhir.r5.model.TestPlan tgt = new org.hl7.fhir.r5.model.TestPlan(); + + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); + + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); + } + if (src.hasExtension(URL_EXTENSION_URL)) { + tgt.setUrlElement(Uri40_50.convertUri((org.hl7.fhir.r4.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(VERSION_EXTENSION_URL)) { + tgt.setVersionElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue())); + } + if (src.hasExtension(NAME_EXTENSION_URL)) { + tgt.setNameElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue())); + } + if (src.hasExtension(TITLE_EXTENSION_URL)) { + tgt.setTitleElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(STATUS_EXTENSION_URL)) { + tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue())); + } + if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) { + tgt.setExperimentalElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(DATE_EXTENSION_URL)) { + tgt.setDateElement(DateTime40_50.convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(PUBLISHER_EXTENSION_URL)) { + tgt.setPublisherElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) { + tgt.addContact(ContactDetail40_50.convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) ext.getValue())); + } + if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { + tgt.setPublisherElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { + tgt.addUseContext(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) { + tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue())); + } + if (src.hasExtension(PURPOSE_EXTENSION_URL)) { + tgt.setPurposeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) { + tgt.setCopyrightElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) { + tgt.setCopyrightLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CATEGORY_EXTENSION_URL)) { + tgt.addCategory(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(SCOPE_EXTENSION_URL)) { + tgt.getScope().add(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) ext.getValue())); + } + if (src.hasExtension(TESTTOOLS_EXTENSION_URL)) { + tgt.setTestToolsElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(TESTTOOLS_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(DEPENDENCY_EXTENSION_URL)) { + convertTestPlanDependency(ext, tgt.addDependency()); + } + if (src.hasExtension(EXITCRITERIA_EXTENSION_URL)) { + tgt.setExitCriteriaElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(EXITCRITERIA_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(TESTCASE_EXTENSION_URL)) { + convertTestPlanTestCase(ext, tgt.addTestCase()); + } + return tgt; + } + + public static org.hl7.fhir.r4.model.Basic convertTestPlan(org.hl7.fhir.r5.model.TestPlan src) throws FHIRException { + if (src == null) + return null; + org.hl7.fhir.r4.model.Basic tgt = new org.hl7.fhir.r4.model.Basic(); + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); + tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("TestPlan"); // note use of R5 type system + + for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); + } + if (src.hasUrl()) { + tgt.addExtension(URL_EXTENSION_URL, Uri40_50.convertUri(src.getUrlElement())); + } + if (src.hasVersion()) { + tgt.addExtension(VERSION_EXTENSION_URL, String40_50.convertString(src.getVersionElement())); + } + if (src.hasName()) { + tgt.addExtension(NAME_EXTENSION_URL, String40_50.convertString(src.getNameElement())); + } + if (src.hasTitle()) { + tgt.addExtension(TITLE_EXTENSION_URL, String40_50.convertString(src.getTitleElement())); + } + if (src.hasStatus()) { + tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(src.getStatus().toCode())); + } + if (src.hasExperimental()) { + tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean40_50.convertBoolean(src.getExperimentalElement())); + } + if (src.hasDate()) { + tgt.addExtension(DATE_EXTENSION_URL, DateTime40_50.convertDateTime(src.getDateElement())); + } + if (src.hasPublisher()) { + tgt.addExtension(PUBLISHER_EXTENSION_URL, String40_50.convertString(src.getPublisherElement())); + } + for (ContactDetail cd : src.getContact()) { + tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail40_50.convertContactDetail(cd)); + } + if (src.hasDescription()) { + tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement())); + } + for (UsageContext cd : src.getUseContext()) { + tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext40_50.convertUsageContext(cd)); + } + for (CodeableConcept cd : src.getJurisdiction()) { + tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(cd)); + } + if (src.hasPurpose()) { + tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getPurposeElement())); + } + if (src.hasCopyright()) { + tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getCopyrightElement())); + } + if (src.hasCopyrightLabel()) { + tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String40_50.convertString(src.getCopyrightLabelElement())); + } + for (CodeableConcept cc : src.getCategory()) { + tgt.addExtension(CATEGORY_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(cc)); + } + for (Reference ref : src.getScope()) { + tgt.addExtension(SCOPE_EXTENSION_URL, Reference40_50.convertReference(ref)); + } + if (src.hasTestTools()) { + tgt.addExtension(TESTTOOLS_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getTestToolsElement())); + } + for (TestPlanDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(DEPENDENCY_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanDependency(ref, tgte); + } + if (src.hasExitCriteria()) { + tgt.addExtension(EXITCRITERIA_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getExitCriteriaElement())); + } + for (TestPlanTestCaseComponent ref : src.getTestCase()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(TESTCASE_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanTestCase(ref, tgte); + } + + return tgt; + } + + /* + * R4 to R5 private methods + */ + + private static void convertTestPlanDependency(Extension src, TestPlanDependencyComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description")) { + tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor")) { + tgt.setPredecessor(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCase(Extension src, TestPlanTestCaseComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence")) { + tgt.setSequenceElement(Integer40_50.convertInteger((org.hl7.fhir.r4.model.IntegerType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence").getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope")) { + tgt.getScope().add(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency")) { + convertTestPlanTestCaseDependency(ext, tgt.addDependency()); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun")) { + convertTestPlanTestCaseTestRun(ext, tgt.addTestRun()); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData")) { + convertTestPlanTestCaseTestData(ext, tgt.addTestData()); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion")) { + convertTestPlanTestCaseAssertion(ext, tgt.addAssertion()); + } + } + + private static void convertTestPlanTestCaseDependency(Extension src, TestCaseDependencyComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description")) { + tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor")) { + tgt.setPredecessor(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCaseTestRun(Extension src, TestPlanTestCaseTestRunComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative")) { + tgt.setNarrativeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script")) { + convertTestPlanTestCaseTestRunScript(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"), tgt.getScript()); + } + } + + private static void convertTestPlanTestCaseTestRunScript(Extension src, TestPlanTestCaseTestRunScriptComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language")) { + tgt.setLanguage(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString")) { + tgt.setSource(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference")) { + tgt.setSource(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseTestData(Extension src, TestPlanTestCaseTestDataComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type")) { + tgt.setType(Coding40_50.convertCoding((org.hl7.fhir.r4.model.Coding) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { + tgt.setContent(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { + tgt.setSource(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { + tgt.setSource(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertion(Extension src, TestPlanTestCaseAssertionComponent tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result" + ); + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type")) { + tgt.getType().add(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object")) { + convertTestPlanTestCaseAssertionObject(ext, tgt.addObject()); + } + for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result")) { + convertTestPlanTestCaseAssertionResult(ext, tgt.addResult()); + } + } + + private static void convertTestPlanTestCaseAssertionObject(Extension src, CodeableReference tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept")) { + tgt.setConcept(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference")) { + tgt.setReference(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(Extension src, CodeableReference tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept")) { + tgt.setConcept(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference")) { + tgt.setReference(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference").getValue())); + } + } + + + /* + * R5 to R4 private methods + */ + + private static void convertTestPlanDependency(TestPlanDependencyComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor", Reference40_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCase(TestPlanTestCaseComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasSequenceElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", Integer40_50.convertInteger(src.getSequenceElement())); + } + for (Reference ref : src.getScope()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", Reference40_50.convertReference(ref)); + } + for (TestCaseDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency"); + tgt.addExtension(tgte); + convertTestPlanTestCaseDependency(ref, tgte); + } + for (TestPlanTestCaseTestRunComponent ref : src.getTestRun()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRun(ref, tgte); + } + for (TestPlanTestCaseTestDataComponent ref : src.getTestData()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestData(ref, tgte); + } + for (TestPlanTestCaseAssertionComponent ref : src.getAssertion()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertion(ref, tgte); + } + } + + private static void convertTestPlanTestCaseDependency(TestCaseDependencyComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor", Reference40_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasNarrativeElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown40_50.convertMarkdown(src.getNarrativeElement())); + } + if (src.hasScript()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRunScript(src.getScript(), tgte); + } + } + + private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasLanguage()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept40_50.convertCodeableConcept(src.getLanguage())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String40_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference40_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding40_50.convertCoding(src.getType())); + } + if (src.hasContent()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference40_50.convertReference(src.getContent())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String40_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference40_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseAssertion(TestPlanTestCaseAssertionComponent src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + for (CodeableConcept cc : src.getType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", CodeableConcept40_50.convertCodeableConcept(cc)); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionObject(ref, tgte); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionResult(ref, tgte); + } + } + + private static void convertTestPlanTestCaseAssertionObject(CodeableReference src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.concept", CodeableConcept40_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.reference", Reference40_50.convertReference(src.getReference())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(CodeableReference src, Extension tgt) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.concept", CodeableConcept40_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.reference", Reference40_50.convertReference(src.getReference())); + } + } + +} diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java index 141affaef..2d9699f5e 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/Resource43_50.java @@ -56,6 +56,8 @@ public class Resource43_50 { return ActorDefinition43_50.convertActorDefinition((org.hl7.fhir.r4b.model.Basic) src); } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { return Requirements43_50.convertRequirements((org.hl7.fhir.r4b.model.Basic) src); + } else if (basic.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + return TestPlan43_50.convertTestPlan((org.hl7.fhir.r4b.model.Basic) src); } else { return Basic43_50.convertBasic((org.hl7.fhir.r4b.model.Basic) src); } @@ -497,6 +499,8 @@ public class Resource43_50 { if (src instanceof org.hl7.fhir.r5.model.Task) return Task43_50.convertTask((org.hl7.fhir.r5.model.Task) src); if (src instanceof org.hl7.fhir.r5.model.TerminologyCapabilities) return TerminologyCapabilities43_50.convertTerminologyCapabilities((org.hl7.fhir.r5.model.TerminologyCapabilities) src); + if (src instanceof org.hl7.fhir.r5.model.TestPlan) + return TestPlan43_50.convertTestPlan((org.hl7.fhir.r5.model.TestPlan)src); if (src instanceof org.hl7.fhir.r5.model.TestReport) return TestReport43_50.convertTestReport((org.hl7.fhir.r5.model.TestReport) src); if (src instanceof org.hl7.fhir.r5.model.TestScript) diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java new file mode 100644 index 000000000..778e99d2f --- /dev/null +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java @@ -0,0 +1,555 @@ +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.Coding43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_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.Boolean43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Integer43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50; +import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4b.model.Extension; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.TestPlan.TestCaseDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseAssertionComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestDataComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunScriptComponent; +import org.hl7.fhir.r5.model.UsageContext; + +/* +Copyright (c) 2011+, HL7, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ +//Generated on Thu, Mar 11, 2023 14:26+0500 for FHIR v4.0.0 +public class TestPlan43_50 { + + public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.url"; + public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.version"; + public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.name"; + public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.title"; + public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.status"; + public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.experimental"; + public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.date"; + public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.publisher"; + public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.contact"; + public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.description"; + public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.useContext"; + public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.jurisdiction"; + public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.purpose"; + public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyright"; + public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyrightLabel"; + public static final String CATEGORY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.category"; + public static final String SCOPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.scope"; + public static final String TESTTOOLS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testTools"; + public static final String DEPENDENCY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency"; + public static final String EXITCRITERIA_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.exitCriteria"; + public static final String TESTCASE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase"; + + private static final String[] IGNORED_EXTENSION_URLS = new String[]{ + URL_EXTENSION_URL, + VERSION_EXTENSION_URL, + NAME_EXTENSION_URL, + TITLE_EXTENSION_URL, + STATUS_EXTENSION_URL, + EXPERIMENTAL_EXTENSION_URL, + DATE_EXTENSION_URL, + PUBLISHER_EXTENSION_URL, + CONTACT_EXTENSION_URL, + DESCRIPTION_EXTENSION_URL, + USE_CONTEXT_EXTENSION_URL, + JURISDICTION_EXTENSION_URL, + PURPOSE_EXTENSION_URL, + COPYRIGHT_EXTENSION_URL, + COPYRIGHT_LABEL_EXTENSION_URL, + CATEGORY_EXTENSION_URL, + SCOPE_EXTENSION_URL, + TESTTOOLS_EXTENSION_URL, + DEPENDENCY_EXTENSION_URL, + EXITCRITERIA_EXTENSION_URL, + TESTCASE_EXTENSION_URL + }; + + public static org.hl7.fhir.r5.model.TestPlan convertTestPlan(org.hl7.fhir.r4b.model.Basic src) throws FHIRException { + if (src == null) + return null; + if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) { + throw new FHIRException("Error in logic: this basic resource is not an TestPlan"); + } + org.hl7.fhir.r5.model.TestPlan tgt = new org.hl7.fhir.r5.model.TestPlan(); + + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); + + for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); + } + if (src.hasExtension(URL_EXTENSION_URL)) { + tgt.setUrlElement(Uri43_50.convertUri((org.hl7.fhir.r4b.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(VERSION_EXTENSION_URL)) { + tgt.setVersionElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue())); + } + if (src.hasExtension(NAME_EXTENSION_URL)) { + tgt.setNameElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue())); + } + if (src.hasExtension(TITLE_EXTENSION_URL)) { + tgt.setTitleElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(STATUS_EXTENSION_URL)) { + tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue())); + } + if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) { + tgt.setExperimentalElement(Boolean43_50.convertBoolean((org.hl7.fhir.r4b.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue())); + } + if (src.hasExtension(DATE_EXTENSION_URL)) { + tgt.setDateElement(DateTime43_50.convertDateTime((org.hl7.fhir.r4b.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(PUBLISHER_EXTENSION_URL)) { + tgt.setPublisherElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) { + tgt.addContact(ContactDetail43_50.convertContactDetail((org.hl7.fhir.r4b.model.ContactDetail) ext.getValue())); + } + if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { + tgt.setPublisherElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { + tgt.addUseContext(UsageContext43_50.convertUsageContext((org.hl7.fhir.r4b.model.UsageContext) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) { + tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) ext.getValue())); + } + if (src.hasExtension(PURPOSE_EXTENSION_URL)) { + tgt.setPurposeElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) { + tgt.setCopyrightElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue())); + } + if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) { + tgt.setCopyrightLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(CATEGORY_EXTENSION_URL)) { + tgt.addCategory(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(SCOPE_EXTENSION_URL)) { + tgt.getScope().add(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) ext.getValue())); + } + if (src.hasExtension(TESTTOOLS_EXTENSION_URL)) { + tgt.setTestToolsElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(TESTTOOLS_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(DEPENDENCY_EXTENSION_URL)) { + convertTestPlanDependency(ext, tgt.addDependency()); + } + if (src.hasExtension(EXITCRITERIA_EXTENSION_URL)) { + tgt.setExitCriteriaElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(EXITCRITERIA_EXTENSION_URL).getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(TESTCASE_EXTENSION_URL)) { + convertTestPlanTestCase(ext, tgt.addTestCase()); + } + return tgt; + } + + public static org.hl7.fhir.r4b.model.Basic convertTestPlan(org.hl7.fhir.r5.model.TestPlan src) throws FHIRException { + if (src == null) + return null; + org.hl7.fhir.r4b.model.Basic tgt = new org.hl7.fhir.r4b.model.Basic(); + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); + tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("TestPlan"); // note use of R5 type system + + for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); + } + if (src.hasUrl()) { + tgt.addExtension(URL_EXTENSION_URL, Uri43_50.convertUri(src.getUrlElement())); + } + if (src.hasVersion()) { + tgt.addExtension(VERSION_EXTENSION_URL, String43_50.convertString(src.getVersionElement())); + } + if (src.hasName()) { + tgt.addExtension(NAME_EXTENSION_URL, String43_50.convertString(src.getNameElement())); + } + if (src.hasTitle()) { + tgt.addExtension(TITLE_EXTENSION_URL, String43_50.convertString(src.getTitleElement())); + } + if (src.hasStatus()) { + tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.r4b.model.CodeType(src.getStatus().toCode())); + } + if (src.hasExperimental()) { + tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean43_50.convertBoolean(src.getExperimentalElement())); + } + if (src.hasDate()) { + tgt.addExtension(DATE_EXTENSION_URL, DateTime43_50.convertDateTime(src.getDateElement())); + } + if (src.hasPublisher()) { + tgt.addExtension(PUBLISHER_EXTENSION_URL, String43_50.convertString(src.getPublisherElement())); + } + for (ContactDetail cd : src.getContact()) { + tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail43_50.convertContactDetail(cd)); + } + if (src.hasDescription()) { + tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getDescriptionElement())); + } + for (UsageContext cd : src.getUseContext()) { + tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext43_50.convertUsageContext(cd)); + } + for (CodeableConcept cd : src.getJurisdiction()) { + tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept43_50.convertCodeableConcept(cd)); + } + if (src.hasPurpose()) { + tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getPurposeElement())); + } + if (src.hasCopyright()) { + tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getCopyrightElement())); + } + if (src.hasCopyrightLabel()) { + tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String43_50.convertString(src.getCopyrightLabelElement())); + } + for (CodeableConcept cc : src.getCategory()) { + tgt.addExtension(CATEGORY_EXTENSION_URL, CodeableConcept43_50.convertCodeableConcept(cc)); + } + for (Reference ref : src.getScope()) { + tgt.addExtension(SCOPE_EXTENSION_URL, Reference43_50.convertReference(ref)); + } + if (src.hasTestTools()) { + tgt.addExtension(TESTTOOLS_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getTestToolsElement())); + } + for (TestPlanDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension(DEPENDENCY_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanDependency(ref, tgte); + } + if (src.hasExitCriteria()) { + tgt.addExtension(EXITCRITERIA_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getExitCriteriaElement())); + } + for (TestPlanTestCaseComponent ref : src.getTestCase()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension(TESTCASE_EXTENSION_URL); + tgt.addExtension(tgte); + convertTestPlanTestCase(ref, tgte); + } + + return tgt; + } + + /* + * R4 to R5 private methods + */ + + private static void convertTestPlanDependency(Extension src, TestPlanDependencyComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description")) { + tgt.setDescriptionElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor")) { + tgt.setPredecessor(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCase(Extension src, TestPlanTestCaseComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence")) { + tgt.setSequenceElement(Integer43_50.convertInteger((org.hl7.fhir.r4b.model.IntegerType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence").getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope")) { + tgt.getScope().add(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency")) { + convertTestPlanTestCaseDependency(ext, tgt.addDependency()); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun")) { + convertTestPlanTestCaseTestRun(ext, tgt.addTestRun()); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData")) { + convertTestPlanTestCaseTestData(ext, tgt.addTestData()); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion")) { + convertTestPlanTestCaseAssertion(ext, tgt.addAssertion()); + } + } + + private static void convertTestPlanTestCaseDependency(Extension src, TestCaseDependencyComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description")) { + tgt.setDescriptionElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor")) { + tgt.setPredecessor(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor").getValue())); + } + } + + private static void convertTestPlanTestCaseTestRun(Extension src, TestPlanTestCaseTestRunComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative")) { + tgt.setNarrativeElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script")) { + convertTestPlanTestCaseTestRunScript(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"), tgt.getScript()); + } + } + + private static void convertTestPlanTestCaseTestRunScript(Extension src, TestPlanTestCaseTestRunScriptComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language")) { + tgt.setLanguage(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString")) { + tgt.setSource(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference")) { + tgt.setSource(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseTestData(Extension src, TestPlanTestCaseTestDataComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type")) { + tgt.setType(Coding43_50.convertCoding((org.hl7.fhir.r4b.model.Coding) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { + tgt.setContent(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { + tgt.setSource(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { + tgt.setSource(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertion(Extension src, TestPlanTestCaseAssertionComponent tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result" + ); + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type")) { + tgt.getType().add(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) ext.getValue())); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object")) { + convertTestPlanTestCaseAssertionObject(ext, tgt.addObject()); + } + for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result")) { + convertTestPlanTestCaseAssertionResult(ext, tgt.addResult()); + } + } + + private static void convertTestPlanTestCaseAssertionObject(Extension src, CodeableReference tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept")) { + tgt.setConcept(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference")) { + tgt.setReference(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference").getValue())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(Extension src, CodeableReference tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept", + "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference" + ); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept")) { + tgt.setConcept(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept").getValue())); + } + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference")) { + tgt.setReference(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference").getValue())); + } + } + + + /* + * R5 to R4 private methods + */ + + private static void convertTestPlanDependency(TestPlanDependencyComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", MarkDown43_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor", Reference43_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCase(TestPlanTestCaseComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasSequenceElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", Integer43_50.convertInteger(src.getSequenceElement())); + } + for (Reference ref : src.getScope()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", Reference43_50.convertReference(ref)); + } + for (TestCaseDependencyComponent ref : src.getDependency()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency"); + tgt.addExtension(tgte); + convertTestPlanTestCaseDependency(ref, tgte); + } + for (TestPlanTestCaseTestRunComponent ref : src.getTestRun()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRun(ref, tgte); + } + for (TestPlanTestCaseTestDataComponent ref : src.getTestData()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestData(ref, tgte); + } + for (TestPlanTestCaseAssertionComponent ref : src.getAssertion()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertion(ref, tgte); + } + } + + private static void convertTestPlanTestCaseDependency(TestCaseDependencyComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasDescription()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", MarkDown43_50.convertMarkdown(src.getDescriptionElement())); + } + if (src.hasPredecessor()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor", Reference43_50.convertReference(src.getPredecessor())); + } + } + + private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasNarrativeElement()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown43_50.convertMarkdown(src.getNarrativeElement())); + } + if (src.hasScript()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); + tgt.addExtension(tgte); + convertTestPlanTestCaseTestRunScript(src.getScript(), tgte); + } + } + + private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasLanguage()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept43_50.convertCodeableConcept(src.getLanguage())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String43_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference43_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding43_50.convertCoding(src.getType())); + } + if (src.hasContent()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference43_50.convertReference(src.getContent())); + } + if (src.hasSourceStringType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String43_50.convertString(src.getSourceStringType())); + } + if (src.hasSourceReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference43_50.convertReference(src.getSourceReference())); + } + } + + private static void convertTestPlanTestCaseAssertion(TestPlanTestCaseAssertionComponent src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + for (CodeableConcept cc : src.getType()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", CodeableConcept43_50.convertCodeableConcept(cc)); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionObject(ref, tgte); + } + for (CodeableReference ref : src.getObject()) { + org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result"); + tgt.addExtension(tgte); + convertTestPlanTestCaseAssertionResult(ref, tgte); + } + } + + private static void convertTestPlanTestCaseAssertionObject(CodeableReference src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.concept", CodeableConcept43_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.reference", Reference43_50.convertReference(src.getReference())); + } + } + + private static void convertTestPlanTestCaseAssertionResult(CodeableReference src, Extension tgt) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); + if (src.hasConcept()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.concept", CodeableConcept43_50.convertCodeableConcept(src.getConcept())); + } + if (src.hasReference()) { + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.reference", Reference43_50.convertReference(src.getReference())); + } + } + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java index 0f2dd01d4..db7bc2854 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java @@ -94,6 +94,9 @@ public class RendererFactory { if ("StructureMap".equals(resourceName)) { return new StructureMapRenderer(context); } + if ("TestPlan".equals(resourceName)) { + return new TestPlanRenderer(context); + } return new ProfileDrivenRenderer(context); } @@ -146,7 +149,7 @@ public class RendererFactory { return Utilities.existsInList(rt, "CodeSystem", "ValueSet", "ConceptMap", "CapabilityStatement", "CompartmentDefinition", "ImplementationGuide", "Library", "NamingSystem", "OperationDefinition", - "Questionnaire", "SearchParameter", "StructureDefinition", "ActorDefinition", "Requirements"); + "Questionnaire", "SearchParameter", "StructureDefinition", "ActorDefinition", "Requirements", "TestPlan"); } /** diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java index 63d1b8f0c..7edb60e9a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java @@ -2,6 +2,7 @@ package org.hl7.fhir.r5.renderers; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRFormatError; @@ -40,6 +41,7 @@ public class RequirementsRenderer extends ResourceRenderer { public boolean render(XhtmlNode x, Requirements req) throws FHIRFormatError, DefinitionException, IOException { if (req.hasActor()) { + x.h3().addText("Actors"); if (req.getActor().size() == 1) { ActorDefinition acd = context.getWorker().fetchResource(ActorDefinition.class, req.getActor().get(0).getValue(), req); XhtmlNode p = x.para(); @@ -63,6 +65,7 @@ public class RequirementsRenderer extends ResourceRenderer { } } if (req.hasDerivedFrom()) { + x.h3().addText("Derived From"); if (req.getDerivedFrom().size() == 1) { Requirements reqd = context.getWorker().fetchResource(Requirements.class, req.getDerivedFrom().get(0).getValue(), req); XhtmlNode p = x.para(); @@ -86,9 +89,15 @@ public class RequirementsRenderer extends ResourceRenderer { } } + x.h3().addText("Statements"); + XhtmlNode tbl = x.table("grid"); + double statementCount = 0.0; + double satisfiedByCount = 0.0; + for (RequirementsStatementComponent stmt : req.getStatement()) { + statementCount += 1.0; XhtmlNode tr = tbl.tr(); String lbl = stmt.hasLabel() ? stmt.getLabel() : stmt.getKey(); XhtmlNode td = tr.td(); @@ -129,6 +138,7 @@ public class RequirementsRenderer extends ResourceRenderer { } } if (stmt.hasSatisfiedBy()) { + satisfiedByCount += 1.0; XhtmlNode li = ul.li(); li.tx("Satisfied By: "); first = true; @@ -195,6 +205,31 @@ public class RequirementsRenderer extends ResourceRenderer { } } } + + x.h3().addText("Coverage (calculated)"); + + tbl = x.table("grid"); + XhtmlNode tr = tbl.tr(); + tr.td().b().addText("Statistic"); + tr.td().b().addText("Coverage %"); + tr.td().b().addText("Description"); + + tr = tbl.tr(); + tr.td().addText("Satisfied By"); + if (statementCount > 0 && satisfiedByCount > 0) { + double coverage = (satisfiedByCount / statementCount) * 100; + if (coverage < 100.0) { + tr.td().style("background-color: #ffff00").tx(String.format("%.2f", new BigDecimal(coverage)) + "%"); + } + else { + tr.td().style("background-color: #00ff00").tx(String.format("%.2f", new BigDecimal(coverage)) + "%"); + } + } + else { + tr.td().style("background-color: #ff0000; color: #ffffff").tx("0.00%"); + } + tr.td().addText("Percent coverage of the satisfied by artifacts against the Requirements statements"); + return false; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TestPlanRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TestPlanRenderer.java new file mode 100644 index 000000000..86ffa34ad --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/TestPlanRenderer.java @@ -0,0 +1,343 @@ +package org.hl7.fhir.r5.renderers; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +import org.hl7.fhir.exceptions.DefinitionException; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.CodeableReference; +import org.hl7.fhir.r5.model.ContactDetail; +import org.hl7.fhir.r5.model.ContactPoint; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.TestPlan; +import org.hl7.fhir.r5.model.TestPlan.TestCaseDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanDependencyComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseAssertionComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestDataComponent; +import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunComponent; +import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper; +import org.hl7.fhir.r5.renderers.utils.RenderingContext; +import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; +import org.hl7.fhir.r5.utils.EOperationOutcome; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; + +public class TestPlanRenderer extends ResourceRenderer { + + public TestPlanRenderer(RenderingContext context) { + super(context); + } + + public TestPlanRenderer(RenderingContext context, ResourceContext rcontext) { + super(context, rcontext); + } + + @Override + public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { + return render(x, (TestPlan) r); + } + + public boolean render(XhtmlNode x, TestPlan tp) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { + XhtmlNode p = null; + if (!tp.getContact().isEmpty()) { + p = x.para(); + p.b().tx("Contact:"); + p.tx(" ("); + boolean firsti = true; + for (ContactDetail ci : tp.getContact()) { + if (firsti) + firsti = false; + else + p.tx(", "); + if (ci.hasName()) + p.addText(ci.getName() + ": "); + boolean first = true; + for (ContactPoint c : ci.getTelecom()) { + if (first) + first = false; + else + p.tx(", "); + addTelecom(p, c); + } + } + p.tx(")"); + } + + if (tp.hasCategory()) { + p = x.para(); + p.b().tx("Category: "); + boolean first = true; + for (CodeableConcept cc : tp.getCategory()) { + if (first) + first = false; + else + p.tx(", "); + renderCodeableConcept(p, cc, false); + } + } + + if (tp.hasScope()) { + if (tp.getScope().size() == 1) { + p = x.para(); + p.b().tx("Test Plan Scope: "); + renderReference(tp, p, tp.getScopeFirstRep()); + } else { + x.para().b().tx("Test Plan Scopes:"); + XhtmlNode ul = x.ul(); + for (Reference ref : tp.getScope()) { + renderReference(tp, ul.li(), ref); + } + } + } + + if (tp.hasDependency()) { + if (tp.getDependency().size() == 1) { + p = x.para(); + p.b().tx("Test Plan Dependency: "); + XhtmlNode t = x.table("grid"); + XhtmlNode tr = t.tr(); + if (!Utilities.noString(tp.getDependencyFirstRep().getDescription())) { + addMarkdown(tr.td(), tp.getDependencyFirstRep().getDescription()); + } + tr = t.tr(); + renderReference(tp, tr.td(), tp.getDependencyFirstRep().getPredecessor()); + } else { + x.para().b().tx("Test Plan Dependencies:"); + XhtmlNode ul = x.ul(); + XhtmlNode li = null; + for (TestPlanDependencyComponent d : tp.getDependency()) { + li = ul.li(); + if (!Utilities.noString(d.getDescription())) { + addMarkdown(li, d.getDescription()); + } + else { + li.addText("Dependency - no description"); + } + if (d.hasPredecessor()) { + XhtmlNode liul = li.ul(); + XhtmlNode liulli = liul.li(); + renderReference(tp, liulli, d.getPredecessor()); + } + } + } + } + + if (tp.hasExitCriteria()) { + addMarkdown(x, tp.getExitCriteria()); + } + + if (tp.hasTestCase()) { + for (TestPlanTestCaseComponent tc : tp.getTestCase()) { + x.h2().addText("Test Case" + (tc.hasSequence() ? " - Sequence" + tc.getSequence() : "")); + + if (tc.hasScope()) { + if (tc.getScope().size() == 1) { + p = x.para(); + p.b().tx("Test Case Scope: "); + renderReference(tp, p, tc.getScopeFirstRep()); + } else { + x.para().b().tx("Test Case Scopes:"); + XhtmlNode ul = x.ul(); + for (Reference ref : tc.getScope()) { + renderReference(tp, ul.li(), ref); + } + } + } + + if (tc.hasDependency()) { + if (tc.getDependency().size() == 1) { + x.h3().addText("Test Case Dependency"); + XhtmlNode t = x.table("grid"); + XhtmlNode tr = t.tr(); + if (!Utilities.noString(tc.getDependencyFirstRep().getDescription())) { + addMarkdown(tr.td(), tc.getDependencyFirstRep().getDescription()); + } + tr = t.tr(); + renderReference(tp, tr.td(), tc.getDependencyFirstRep().getPredecessor()); + } else { + x.h3().addText("Test Case Dependencies"); + XhtmlNode ul = x.ul(); + XhtmlNode li = null; + for (TestCaseDependencyComponent d : tc.getDependency()) { + li = ul.li(); + if (!Utilities.noString(d.getDescription())) { + addMarkdown(li, d.getDescription()); + } + else { + li.addText("Dependency - no description"); + } + if (d.hasPredecessor()) { + XhtmlNode liul = li.ul(); + XhtmlNode liulli = liul.li(); + renderReference(tp, liulli, d.getPredecessor()); + } + } + } + } + + if (tc.hasTestRun()) { + if (tc.getTestRun().size() == 1) { + x.h3().addText("Test Run"); + renderTestRun(x, tp, tc.getTestRunFirstRep()); + } + else { + int count = 0; + for (TestPlanTestCaseTestRunComponent trun : tc.getTestRun()) { + count++; + x.h3().addText("Test Run " + count); + renderTestRun(x, tp, trun); + } + } + } + + if (tc.hasTestData()) { + if (tc.getTestData().size() == 1) { + x.h3().addText("Test Data"); + renderTestData(x, tp, tc.getTestDataFirstRep()); + } + else { + int count = 0; + for (TestPlanTestCaseTestDataComponent tdata : tc.getTestData()) { + count++; + x.h3().addText("Test Data " + count); + renderTestData(x, tp, tdata); + } + } + } + + if (tc.hasAssertion()) { + if (tc.getAssertion().size() == 1) { + x.h3().addText("Assertion"); + renderAssertion(x, tp, tc.getAssertionFirstRep()); + } + else { + int count = 0; + for (TestPlanTestCaseAssertionComponent as : tc.getAssertion()) { + count++; + x.h3().addText("Assertion " + count); + renderAssertion(x, tp, as); + } + } + } + } + } + + return false; + } + + private void renderTestRun(XhtmlNode x, TestPlan tp, TestPlanTestCaseTestRunComponent trun) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { + if (trun.hasNarrative()) { + addMarkdown(x, trun.getNarrative()); + } + + if (trun.hasScript()) { + XhtmlNode t = x.table("grid"); + XhtmlNode tr = t.tr(); + tr.td().b().addText("Language"); + tr.td().b().addText("Source[x]"); + tr = t.tr(); + if (trun.getScript().hasLanguage()) { + renderCodeableConcept(tr.td(), trun.getScript().getLanguage(), false); + } + else { + tr.td().addText("??"); + } + if (trun.getScript().hasSourceReference()) { + renderReference(tp, tr.td(), trun.getScript().getSourceReference()); + } + else if(trun.getScript().hasSourceStringType()) { + tr.td().addText(trun.getScript().getSourceStringType().asStringValue()); + } + else { + tr.td().addText("??"); + } + } + } + + private void renderTestData(XhtmlNode x, TestPlan tp, TestPlanTestCaseTestDataComponent tdata) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { + XhtmlNode t = x.table("grid"); + XhtmlNode tr = t.tr(); + tr.td().b().addText("Type"); + tr.td().b().addText("Content"); + tr.td().b().addText("Source[x]"); + tr = t.tr(); + if (tdata.hasType()) { + renderCoding(tr.td(), tdata.getType()); + } + else { + tr.td().addText("??"); + } + if (tdata.hasContent()) { + renderReference(tp, tr.td(), tdata.getContent()); + } + else { + tr.td().addText("??"); + } + if (tdata.hasSourceReference()) { + renderReference(tp, tr.td(), tdata.getSourceReference()); + } + else if(tdata.hasSourceStringType()) { + tr.td().addText(tdata.getSourceStringType().asStringValue()); + } + else { + tr.td().addText("??"); + } + } + + private void renderAssertion(XhtmlNode x, TestPlan tp, TestPlanTestCaseAssertionComponent as) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { + XhtmlNode t = x.table("grid"); + XhtmlNode tr = t.tr(); + tr.td().b().addText("Type"); + tr.td().b().addText("Content"); + tr.td().b().addText("Result"); + tr = t.tr(); + if (as.hasType()) { + XhtmlNode td = tr.td(); + XhtmlNode ul = td.ul(); + for (CodeableConcept cc : as.getType()) { + renderCodeableConcept(ul.li(), cc, false); + } + } + else { + tr.td().addText("??"); + } + if (as.hasObject()) { + XhtmlNode td = tr.td(); + XhtmlNode ul = td.ul(); + for (CodeableReference cr : as.getObject()) { + renderCodeableReference(ul.li(), cr, false); + } + } + else { + tr.td().addText("??"); + } + if (as.hasResult()) { + XhtmlNode td = tr.td(); + XhtmlNode ul = td.ul(); + for (CodeableReference cr : as.getResult()) { + renderCodeableReference(ul.li(), cr, false); + } + } + else { + tr.td().addText("??"); + } + } + + @Override + public String display(Resource r) throws UnsupportedEncodingException, IOException { + return null; + } + + @Override + public String display(ResourceWrapper r) throws UnsupportedEncodingException, IOException { + if (r.has("title")) { + return r.children("title").get(0).getBase().primitiveValue(); + } + return "??"; + } + +} From e6c1cd22f4fe087b71a0822e8d770e3c0d99744a Mon Sep 17 00:00:00 2001 From: Richard Ettema Date: Thu, 18 May 2023 21:06:49 -0400 Subject: [PATCH 2/3] Added unit test classes for TestPlan conversion --- .../resources30_50/TestPlan30_50.java | 34 ++++++------ .../resources40_50/TestPlan40_50.java | 26 ++++----- .../resources43_50/TestPlan43_50.java | 26 ++++----- .../conv30_50/TestPlan30_50Test.java | 34 ++++++++++++ .../conv40_50/TestPlan40_50Test.java | 34 ++++++++++++ .../conv43_50/TestPlan43_50Test.java | 35 ++++++++++++ .../test/resources/testplan_50_example.json | 54 +++++++++++++++++++ 7 files changed, 200 insertions(+), 43 deletions(-) create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/TestPlan30_50Test.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/TestPlan40_50Test.java create mode 100644 org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/TestPlan43_50Test.java create mode 100644 org.hl7.fhir.convertors/src/test/resources/testplan_50_example.json diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java index d7dc227f4..35ba08b6e 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv30_50/resources30_50/TestPlan30_50.java @@ -147,7 +147,7 @@ public class TestPlan30_50 { tgt.addContact(ContactDetail30_50.convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) ext.getValue())); } if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { - tgt.setPublisherElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + tgt.setDescriptionElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); } for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { tgt.addUseContext(UsageContext30_50.convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) ext.getValue())); @@ -368,11 +368,11 @@ public class TestPlan30_50 { if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { tgt.setContent(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { - tgt.setSource(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString")) { + tgt.setSource(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { - tgt.setSource(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference")) { + tgt.setSource(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference").getValue())); } } @@ -477,7 +477,7 @@ public class TestPlan30_50 { private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); if (src.hasNarrativeElement()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown30_50.convertMarkdown(src.getNarrativeElement())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", MarkDown30_50.convertMarkdown(src.getNarrativeElement())); } if (src.hasScript()) { org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); @@ -489,29 +489,29 @@ public class TestPlan30_50 { private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); if (src.hasLanguage()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept30_50.convertCodeableConcept(src.getLanguage())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", CodeableConcept30_50.convertCodeableConcept(src.getLanguage())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String30_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", String30_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference30_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference", Reference30_50.convertReference(src.getSourceReference())); } } private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); if (src.hasType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding30_50.convertCoding(src.getType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", Coding30_50.convertCoding(src.getType())); } if (src.hasContent()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference30_50.convertReference(src.getContent())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", Reference30_50.convertReference(src.getContent())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String30_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", String30_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference30_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference", Reference30_50.convertReference(src.getSourceReference())); } } @@ -535,20 +535,20 @@ public class TestPlan30_50 { private static void convertTestPlanTestCaseAssertionObject(CodeableReference src, Extension tgt) { ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); if (src.hasConcept()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); } if (src.hasReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.reference", Reference30_50.convertReference(src.getReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference", Reference30_50.convertReference(src.getReference())); } } private static void convertTestPlanTestCaseAssertionResult(CodeableReference src, Extension tgt) { ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); if (src.hasConcept()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept", CodeableConcept30_50.convertCodeableConcept(src.getConcept())); } if (src.hasReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.reference", Reference30_50.convertReference(src.getReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference", Reference30_50.convertReference(src.getReference())); } } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java index 98132b0c2..7aab99164 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/TestPlan40_50.java @@ -147,7 +147,7 @@ public class TestPlan40_50 { tgt.addContact(ContactDetail40_50.convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) ext.getValue())); } if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { - tgt.setPublisherElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); } for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { tgt.addUseContext(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) ext.getValue())); @@ -368,11 +368,11 @@ public class TestPlan40_50 { if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { tgt.setContent(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { - tgt.setSource(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString")) { + tgt.setSource(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { - tgt.setSource(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference")) { + tgt.setSource(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference").getValue())); } } @@ -477,7 +477,7 @@ public class TestPlan40_50 { private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); if (src.hasNarrativeElement()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown40_50.convertMarkdown(src.getNarrativeElement())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", MarkDown40_50.convertMarkdown(src.getNarrativeElement())); } if (src.hasScript()) { org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); @@ -489,29 +489,29 @@ public class TestPlan40_50 { private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); if (src.hasLanguage()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept40_50.convertCodeableConcept(src.getLanguage())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", CodeableConcept40_50.convertCodeableConcept(src.getLanguage())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String40_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", String40_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference40_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference", Reference40_50.convertReference(src.getSourceReference())); } } private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); if (src.hasType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding40_50.convertCoding(src.getType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", Coding40_50.convertCoding(src.getType())); } if (src.hasContent()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference40_50.convertReference(src.getContent())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", Reference40_50.convertReference(src.getContent())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String40_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", String40_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference40_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference", Reference40_50.convertReference(src.getSourceReference())); } } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java index 778e99d2f..0aeaa88cf 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/TestPlan43_50.java @@ -147,7 +147,7 @@ public class TestPlan43_50 { tgt.addContact(ContactDetail43_50.convertContactDetail((org.hl7.fhir.r4b.model.ContactDetail) ext.getValue())); } if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { - tgt.setPublisherElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); + tgt.setDescriptionElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); } for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { tgt.addUseContext(UsageContext43_50.convertUsageContext((org.hl7.fhir.r4b.model.UsageContext) ext.getValue())); @@ -368,11 +368,11 @@ public class TestPlan43_50 { if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) { tgt.setContent(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString")) { - tgt.setSource(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceString").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString")) { + tgt.setSource(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString").getValue())); } - if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference")) { - tgt.setSource(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.script.sourceReference").getValue())); + if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference")) { + tgt.setSource(Reference43_50.convertReference((org.hl7.fhir.r4b.model.Reference) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference").getValue())); } } @@ -477,7 +477,7 @@ public class TestPlan43_50 { private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) { ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); if (src.hasNarrativeElement()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.narrative", MarkDown43_50.convertMarkdown(src.getNarrativeElement())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", MarkDown43_50.convertMarkdown(src.getNarrativeElement())); } if (src.hasScript()) { org.hl7.fhir.r4b.model.Extension tgte = new org.hl7.fhir.r4b.model.Extension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"); @@ -489,29 +489,29 @@ public class TestPlan43_50 { private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) { ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); if (src.hasLanguage()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.language", CodeableConcept43_50.convertCodeableConcept(src.getLanguage())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", CodeableConcept43_50.convertCodeableConcept(src.getLanguage())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceString", String43_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", String43_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.script.sourceReference", Reference43_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference", Reference43_50.convertReference(src.getSourceReference())); } } private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) { ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); if (src.hasType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.type", Coding43_50.convertCoding(src.getType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", Coding43_50.convertCoding(src.getType())); } if (src.hasContent()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.content", Reference43_50.convertReference(src.getContent())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", Reference43_50.convertReference(src.getContent())); } if (src.hasSourceStringType()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceString", String43_50.convertString(src.getSourceStringType())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", String43_50.convertString(src.getSourceStringType())); } if (src.hasSourceReference()) { - tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.testRun.testData.sourceReference", Reference43_50.convertReference(src.getSourceReference())); + tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference", Reference43_50.convertReference(src.getSourceReference())); } } diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/TestPlan30_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/TestPlan30_50Test.java new file mode 100644 index 000000000..332b3e83b --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv30_50/TestPlan30_50Test.java @@ -0,0 +1,34 @@ +package org.hl7.fhir.convertors.conv30_50; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class TestPlan30_50Test { + + @Test + @DisplayName("Test r5 -> dstu3 TestPlan conversion.") + public void testR5_dstu3() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/testplan_50_example.json"); + + org.hl7.fhir.r5.model.TestPlan r5_actual = (org.hl7.fhir.r5.model.TestPlan) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input); + org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_50.convertResource(r5_actual); + + org.hl7.fhir.dstu3.formats.XmlParser r4_parser = new org.hl7.fhir.dstu3.formats.XmlParser(); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + r4_parser.compose(stream, dstu3_conv); + + org.hl7.fhir.dstu3.model.Resource dstu3_streamed = (org.hl7.fhir.dstu3.model.Basic) new org.hl7.fhir.dstu3.formats.XmlParser().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/java/org/hl7/fhir/convertors/conv40_50/TestPlan40_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/TestPlan40_50Test.java new file mode 100644 index 000000000..e32a1c50f --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv40_50/TestPlan40_50Test.java @@ -0,0 +1,34 @@ +package org.hl7.fhir.convertors.conv40_50; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class TestPlan40_50Test { + + @Test + @DisplayName("Test r5 -> r4 TestPlan conversion.") + public void testR5_R4() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/testplan_50_example.json"); + + org.hl7.fhir.r5.model.TestPlan r5_actual = (org.hl7.fhir.r5.model.TestPlan) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_input); + org.hl7.fhir.r4.model.Resource r4_conv = VersionConvertorFactory_40_50.convertResource(r5_actual); + + org.hl7.fhir.r4.formats.XmlParser r4_parser = new org.hl7.fhir.r4.formats.XmlParser(); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + r4_parser.compose(stream, r4_conv); + + org.hl7.fhir.r4.model.Resource r4_streamed = (org.hl7.fhir.r4.model.Basic) new org.hl7.fhir.r4.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray())); + org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_streamed); + + assertTrue(r5_actual.equalsDeep(r5_conv), "should be the same"); + } +} diff --git a/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/TestPlan43_50Test.java b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/TestPlan43_50Test.java new file mode 100644 index 000000000..1ec4cd6a4 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/java/org/hl7/fhir/convertors/conv43_50/TestPlan43_50Test.java @@ -0,0 +1,35 @@ +package org.hl7.fhir.convertors.conv43_50; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +public class TestPlan43_50Test { + + @Test + @DisplayName("Test r5 -> r4 TestPlan conversion.") + public void testR5_R4() throws IOException { + InputStream r5_input = this.getClass().getResourceAsStream("/testplan_50_example.json"); + + org.hl7.fhir.r5.model.TestPlan r5_actual = (org.hl7.fhir.r5.model.TestPlan) 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 = (org.hl7.fhir.r4b.model.Basic) 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"); + } + +} diff --git a/org.hl7.fhir.convertors/src/test/resources/testplan_50_example.json b/org.hl7.fhir.convertors/src/test/resources/testplan_50_example.json new file mode 100644 index 000000000..ee4b0ade7 --- /dev/null +++ b/org.hl7.fhir.convertors/src/test/resources/testplan_50_example.json @@ -0,0 +1,54 @@ +{ + "resourceType": "TestPlan", + "id": "example1", + "url": "http://hl7.org/fhir/TestPlan/example1", + "name": "ExampleTestPlan1", + "title": "Example TestPlan 1", + "date": "2023-05-17T23:02:30.239Z", + "description": "Example TestPlan for testing", + "status": "active", + "publisher": "Health Level 7 (HL7) International", + "category": [ + { + "coding": [ + { + "system": "http://hl7.org/fhir/testscript-scope-phase-codes", + "code": "integration" + } + ] + } + ], + "testCase": [ + { + "sequence": 1, + "testRun": [ + { + "narrative": "Read JSON formatted Observation and validate against the Dev Satisfaction IG", + "script": { + "language": { + "coding": [ + { + "system": "http://example.org/fhir/testplan/language", + "code": "testscript" + } + ] + }, + "sourceString": "http://hl7.org/fhir/TestScript/example1" + } + } + ], + "testData": [ + { + "type": { + "system": "http://example.org/fhir/testplan/testData-type", + "code": "example" + }, + "content": { + "reference": "Observation/example1" + }, + "sourceString": "http://hl7.org/fhir/Observation/example1" + } + ] + } + ] +} From 1ee320a462a60b38f10fbe6835511c56497f4f82 Mon Sep 17 00:00:00 2001 From: Richard Ettema Date: Mon, 22 May 2023 17:54:58 -0400 Subject: [PATCH 3/3] revert changes to RequirementsRenderer --- .../r5/renderers/RequirementsRenderer.java | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java index 7edb60e9a..63d1b8f0c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RequirementsRenderer.java @@ -2,7 +2,6 @@ package org.hl7.fhir.r5.renderers; import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRFormatError; @@ -41,7 +40,6 @@ public class RequirementsRenderer extends ResourceRenderer { public boolean render(XhtmlNode x, Requirements req) throws FHIRFormatError, DefinitionException, IOException { if (req.hasActor()) { - x.h3().addText("Actors"); if (req.getActor().size() == 1) { ActorDefinition acd = context.getWorker().fetchResource(ActorDefinition.class, req.getActor().get(0).getValue(), req); XhtmlNode p = x.para(); @@ -65,7 +63,6 @@ public class RequirementsRenderer extends ResourceRenderer { } } if (req.hasDerivedFrom()) { - x.h3().addText("Derived From"); if (req.getDerivedFrom().size() == 1) { Requirements reqd = context.getWorker().fetchResource(Requirements.class, req.getDerivedFrom().get(0).getValue(), req); XhtmlNode p = x.para(); @@ -89,15 +86,9 @@ public class RequirementsRenderer extends ResourceRenderer { } } - x.h3().addText("Statements"); - XhtmlNode tbl = x.table("grid"); - double statementCount = 0.0; - double satisfiedByCount = 0.0; - for (RequirementsStatementComponent stmt : req.getStatement()) { - statementCount += 1.0; XhtmlNode tr = tbl.tr(); String lbl = stmt.hasLabel() ? stmt.getLabel() : stmt.getKey(); XhtmlNode td = tr.td(); @@ -138,7 +129,6 @@ public class RequirementsRenderer extends ResourceRenderer { } } if (stmt.hasSatisfiedBy()) { - satisfiedByCount += 1.0; XhtmlNode li = ul.li(); li.tx("Satisfied By: "); first = true; @@ -205,31 +195,6 @@ public class RequirementsRenderer extends ResourceRenderer { } } } - - x.h3().addText("Coverage (calculated)"); - - tbl = x.table("grid"); - XhtmlNode tr = tbl.tr(); - tr.td().b().addText("Statistic"); - tr.td().b().addText("Coverage %"); - tr.td().b().addText("Description"); - - tr = tbl.tr(); - tr.td().addText("Satisfied By"); - if (statementCount > 0 && satisfiedByCount > 0) { - double coverage = (satisfiedByCount / statementCount) * 100; - if (coverage < 100.0) { - tr.td().style("background-color: #ffff00").tx(String.format("%.2f", new BigDecimal(coverage)) + "%"); - } - else { - tr.td().style("background-color: #00ff00").tx(String.format("%.2f", new BigDecimal(coverage)) + "%"); - } - } - else { - tr.td().style("background-color: #ff0000; color: #ffffff").tx("0.00%"); - } - tr.td().addText("Percent coverage of the satisfied by artifacts against the Requirements statements"); - return false; }