001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
014import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
015import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
016import org.hl7.fhir.exceptions.FHIRException;
017import org.hl7.fhir.r4.model.Extension;
018import org.hl7.fhir.r5.model.CodeableConcept;
019import org.hl7.fhir.r5.model.CodeableReference;
020import org.hl7.fhir.r5.model.ContactDetail;
021import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
022import org.hl7.fhir.r5.model.Reference;
023import org.hl7.fhir.r5.model.TestPlan.TestCaseDependencyComponent;
024import org.hl7.fhir.r5.model.TestPlan.TestPlanDependencyComponent;
025import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseAssertionComponent;
026import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseComponent;
027import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestDataComponent;
028import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunComponent;
029import org.hl7.fhir.r5.model.TestPlan.TestPlanTestCaseTestRunScriptComponent;
030import org.hl7.fhir.r5.model.UsageContext;
031
032/*
033Copyright (c) 2011+, HL7, Inc.
034All rights reserved.
035
036Redistribution and use in source and binary forms, with or without modification, 
037are permitted provided that the following conditions are met:
038
039 * Redistributions of source code must retain the above copyright notice, this 
040   list of conditions and the following disclaimer.
041 * Redistributions in binary form must reproduce the above copyright notice, 
042   this list of conditions and the following disclaimer in the documentation 
043   and/or other materials provided with the distribution.
044 * Neither the name of HL7 nor the names of its contributors may be used to 
045   endorse or promote products derived from this software without specific 
046   prior written permission.
047
048THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
049ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
050WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
051IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
052INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
053NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
054PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
055WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
056ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
057POSSIBILITY OF SUCH DAMAGE.
058
059*/
060//Generated on Thu, Mar 11, 2023 14:26+0500 for FHIR v4.0.0
061public class TestPlan40_50 {
062
063  public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.url";
064  public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.version";
065  public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.name";
066  public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.title";
067  public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.status";
068  public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.experimental";
069  public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.date";
070  public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.publisher";
071  public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.contact";
072  public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.description";
073  public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.useContext";
074  public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.jurisdiction";
075  public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.purpose";
076  public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyright";
077  public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.copyrightLabel";
078  public static final String CATEGORY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.category";
079  public static final String SCOPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.scope";
080  public static final String TESTTOOLS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testTools";
081  public static final String DEPENDENCY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency";
082  public static final String EXITCRITERIA_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.exitCriteria";
083  public static final String TESTCASE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase";
084
085  private static final String[] IGNORED_EXTENSION_URLS = new String[]{
086    URL_EXTENSION_URL,
087    VERSION_EXTENSION_URL,
088    NAME_EXTENSION_URL,
089    TITLE_EXTENSION_URL,
090    STATUS_EXTENSION_URL,
091    EXPERIMENTAL_EXTENSION_URL,
092    DATE_EXTENSION_URL,
093    PUBLISHER_EXTENSION_URL,
094    CONTACT_EXTENSION_URL,
095    DESCRIPTION_EXTENSION_URL,
096    USE_CONTEXT_EXTENSION_URL,
097    JURISDICTION_EXTENSION_URL,
098    PURPOSE_EXTENSION_URL,
099    COPYRIGHT_EXTENSION_URL,
100    COPYRIGHT_LABEL_EXTENSION_URL,
101    CATEGORY_EXTENSION_URL,
102    SCOPE_EXTENSION_URL,
103    TESTTOOLS_EXTENSION_URL,
104    DEPENDENCY_EXTENSION_URL,
105    EXITCRITERIA_EXTENSION_URL,
106    TESTCASE_EXTENSION_URL
107  };
108
109  public static org.hl7.fhir.r5.model.TestPlan convertTestPlan(org.hl7.fhir.r4.model.Basic src) throws FHIRException {
110    if (src == null)
111      return null;
112    if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "TestPlan")) {
113      throw new FHIRException("Error in logic: this basic resource is not an TestPlan");
114    }
115    org.hl7.fhir.r5.model.TestPlan tgt = new org.hl7.fhir.r5.model.TestPlan();
116
117    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
118            
119    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) {
120      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
121    }
122    if (src.hasExtension(URL_EXTENSION_URL)) {
123      tgt.setUrlElement(Uri40_50.convertUri((org.hl7.fhir.r4.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue()));
124    }
125    if (src.hasExtension(VERSION_EXTENSION_URL)) {
126      tgt.setVersionElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue()));
127    }
128    if (src.hasExtension(NAME_EXTENSION_URL)) {
129      tgt.setNameElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue()));
130    }
131    if (src.hasExtension(TITLE_EXTENSION_URL)) {
132      tgt.setTitleElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue()));
133    }
134    if (src.hasExtension(STATUS_EXTENSION_URL)) {
135      tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue()));
136    }
137    if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) {
138      tgt.setExperimentalElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue()));
139    }
140    if (src.hasExtension(DATE_EXTENSION_URL)) {
141      tgt.setDateElement(DateTime40_50.convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue()));
142    }
143    if (src.hasExtension(PUBLISHER_EXTENSION_URL)) {
144      tgt.setPublisherElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue()));
145    }
146    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) {
147      tgt.addContact(ContactDetail40_50.convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) ext.getValue()));
148    }
149    if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) {
150      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue()));
151    }
152    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) {
153      tgt.addUseContext(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) ext.getValue()));
154    }
155    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) {
156      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue()));
157    }
158    if (src.hasExtension(PURPOSE_EXTENSION_URL)) {
159      tgt.setPurposeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue()));
160    }
161    if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) {
162      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue()));
163    }
164    if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) {
165      tgt.setCopyrightLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue()));
166    }
167    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CATEGORY_EXTENSION_URL)) {
168      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue()));
169    }
170    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(SCOPE_EXTENSION_URL)) {
171      tgt.getScope().add(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) ext.getValue()));
172    }
173    if (src.hasExtension(TESTTOOLS_EXTENSION_URL)) {
174      tgt.setTestToolsElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(TESTTOOLS_EXTENSION_URL).getValue()));
175    }
176    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(DEPENDENCY_EXTENSION_URL)) {
177      convertTestPlanDependency(ext, tgt.addDependency());
178    }
179    if (src.hasExtension(EXITCRITERIA_EXTENSION_URL)) {
180      tgt.setExitCriteriaElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(EXITCRITERIA_EXTENSION_URL).getValue()));
181    }
182    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(TESTCASE_EXTENSION_URL)) {
183      convertTestPlanTestCase(ext, tgt.addTestCase());
184    }
185    return tgt;
186  }
187
188  public static org.hl7.fhir.r4.model.Basic convertTestPlan(org.hl7.fhir.r5.model.TestPlan src) throws FHIRException {
189    if (src == null)
190      return null;
191    org.hl7.fhir.r4.model.Basic tgt = new org.hl7.fhir.r4.model.Basic();
192    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
193    tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("TestPlan"); // note use of R5 type system
194    
195    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) {
196      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
197    }
198    if (src.hasUrl()) {
199      tgt.addExtension(URL_EXTENSION_URL, Uri40_50.convertUri(src.getUrlElement()));
200    }
201    if (src.hasVersion()) {
202      tgt.addExtension(VERSION_EXTENSION_URL, String40_50.convertString(src.getVersionElement()));
203    }
204    if (src.hasName()) {
205      tgt.addExtension(NAME_EXTENSION_URL, String40_50.convertString(src.getNameElement()));
206    }
207    if (src.hasTitle()) {
208      tgt.addExtension(TITLE_EXTENSION_URL, String40_50.convertString(src.getTitleElement()));
209    }
210    if (src.hasStatus()) {
211      tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(src.getStatus().toCode()));
212    }
213    if (src.hasExperimental()) {
214      tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean40_50.convertBoolean(src.getExperimentalElement()));
215    }
216    if (src.hasDate()) {
217      tgt.addExtension(DATE_EXTENSION_URL, DateTime40_50.convertDateTime(src.getDateElement()));
218    }
219    if (src.hasPublisher()) {
220      tgt.addExtension(PUBLISHER_EXTENSION_URL, String40_50.convertString(src.getPublisherElement()));
221    }
222    for (ContactDetail cd : src.getContact()) {
223      tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail40_50.convertContactDetail(cd));
224    }
225    if (src.hasDescription()) {
226      tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
227    }
228    for (UsageContext cd : src.getUseContext()) {
229      tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext40_50.convertUsageContext(cd));
230    }
231    for (CodeableConcept cd : src.getJurisdiction()) {
232      tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(cd));
233    }
234    if (src.hasPurpose()) {
235      tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getPurposeElement()));
236    }
237    if (src.hasCopyright()) {
238      tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
239    }
240    if (src.hasCopyrightLabel()) {
241      tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String40_50.convertString(src.getCopyrightLabelElement()));
242    }
243    for (CodeableConcept cc : src.getCategory()) {
244      tgt.addExtension(CATEGORY_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(cc));
245    }
246    for (Reference ref : src.getScope()) {
247      tgt.addExtension(SCOPE_EXTENSION_URL, Reference40_50.convertReference(ref));
248    }
249    if (src.hasTestTools()) {
250      tgt.addExtension(TESTTOOLS_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getTestToolsElement()));
251    }
252    for (TestPlanDependencyComponent ref : src.getDependency()) {
253      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(DEPENDENCY_EXTENSION_URL);
254      tgt.addExtension(tgte);
255      convertTestPlanDependency(ref, tgte);
256    }
257    if (src.hasExitCriteria()) {
258      tgt.addExtension(EXITCRITERIA_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getExitCriteriaElement()));
259    }
260    for (TestPlanTestCaseComponent ref : src.getTestCase()) {
261      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(TESTCASE_EXTENSION_URL);
262      tgt.addExtension(tgte);
263      convertTestPlanTestCase(ref, tgte);
264    }
265
266    return tgt;
267  }
268
269  /*
270   * R4 to R5 private methods
271   */
272
273  private static void convertTestPlanDependency(Extension src, TestPlanDependencyComponent tgt) {
274    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
275        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description",
276        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor"
277        );
278    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description")) {
279      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()));
280    }
281    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor")) {
282      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()));
283    }
284  }
285
286  private static void convertTestPlanTestCase(Extension src, TestPlanTestCaseComponent tgt) {
287    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
288        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence",
289        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope",
290        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency",
291        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun",
292        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData",
293        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion"
294        );
295    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence")) {
296      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()));
297    }
298    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope")) {
299      tgt.getScope().add(Reference40_50.convertReference((org.hl7.fhir.r4.model.Reference) ext.getValue()));
300    }
301    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency")) {
302      convertTestPlanTestCaseDependency(ext, tgt.addDependency());
303    }
304    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun")) {
305      convertTestPlanTestCaseTestRun(ext, tgt.addTestRun());
306    }
307    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData")) {
308      convertTestPlanTestCaseTestData(ext, tgt.addTestData());
309    }
310    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion")) {
311      convertTestPlanTestCaseAssertion(ext, tgt.addAssertion());
312    }
313  }
314
315  private static void convertTestPlanTestCaseDependency(Extension src, TestCaseDependencyComponent tgt) {
316    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
317        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description",
318        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor"
319        );
320    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description")) {
321      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()));
322    }
323    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor")) {
324      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()));
325    }
326  }
327
328  private static void convertTestPlanTestCaseTestRun(Extension src, TestPlanTestCaseTestRunComponent tgt) {
329    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
330        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative",
331        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"
332        );
333    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative")) {
334      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()));
335    }
336    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script")) {
337      convertTestPlanTestCaseTestRunScript(src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script"), tgt.getScript());
338    }
339  }
340
341  private static void convertTestPlanTestCaseTestRunScript(Extension src, TestPlanTestCaseTestRunScriptComponent tgt) {
342    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
343        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language",
344        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString",
345        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference"
346        );
347    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language")) {
348      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()));
349    }
350    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString")) {
351      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()));
352    }
353    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference")) {
354      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()));
355    }
356  }
357
358  private static void convertTestPlanTestCaseTestData(Extension src, TestPlanTestCaseTestDataComponent tgt) {
359    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
360        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type",
361        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content",
362        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString",
363        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference"
364        );
365    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type")) {
366      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()));
367    }
368    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content")) {
369      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()));
370    }
371    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString")) {
372      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()));
373    }
374    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference")) {
375      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()));
376    }
377  }
378
379  private static void convertTestPlanTestCaseAssertion(Extension src, TestPlanTestCaseAssertionComponent tgt) {
380    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
381        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type",
382        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object",
383        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result"
384        );
385    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type")) {
386      tgt.getType().add(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue()));
387    }
388    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object")) {
389      convertTestPlanTestCaseAssertionObject(ext, tgt.addObject());
390    }
391    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result")) {
392      convertTestPlanTestCaseAssertionResult(ext, tgt.addResult());
393    }
394  }
395
396  private static void convertTestPlanTestCaseAssertionObject(Extension src, CodeableReference tgt) {
397    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
398        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept",
399        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference"
400        );
401    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.concept")) {
402      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()));
403    }
404    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.object.reference")) {
405      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()));
406    }
407  }
408
409  private static void convertTestPlanTestCaseAssertionResult(Extension src, CodeableReference tgt) {
410    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
411        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept",
412        "http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference"
413        );
414    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.concept")) {
415      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()));
416    }
417    if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.result.reference")) {
418      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()));
419    }
420  }
421
422
423  /*
424   * R5 to R4 private methods
425   */
426
427  private static void convertTestPlanDependency(TestPlanDependencyComponent src, Extension tgt) {
428    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
429    if (src.hasDescription()) {
430      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
431    }
432    if (src.hasPredecessor()) {
433      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.dependency.predecessor", Reference40_50.convertReference(src.getPredecessor()));
434    }
435  }
436
437  private static void convertTestPlanTestCase(TestPlanTestCaseComponent src, Extension tgt) {
438    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
439    if (src.hasSequenceElement()) {
440      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.sequence", Integer40_50.convertInteger(src.getSequenceElement()));
441    }
442    for (Reference ref : src.getScope()) {
443      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.scope", Reference40_50.convertReference(ref));
444    }
445    for (TestCaseDependencyComponent ref : src.getDependency()) {
446      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");
447      tgt.addExtension(tgte);
448      convertTestPlanTestCaseDependency(ref, tgte);
449    }
450    for (TestPlanTestCaseTestRunComponent ref : src.getTestRun()) {
451      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");
452      tgt.addExtension(tgte);
453      convertTestPlanTestCaseTestRun(ref, tgte);
454    }
455    for (TestPlanTestCaseTestDataComponent ref : src.getTestData()) {
456      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");
457      tgt.addExtension(tgte);
458      convertTestPlanTestCaseTestData(ref, tgte);
459    }
460    for (TestPlanTestCaseAssertionComponent ref : src.getAssertion()) {
461      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");
462      tgt.addExtension(tgte);
463      convertTestPlanTestCaseAssertion(ref, tgte);
464    }
465  }
466
467  private static void convertTestPlanTestCaseDependency(TestCaseDependencyComponent src, Extension tgt) {
468    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
469    if (src.hasDescription()) {
470      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.description", MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
471    }
472    if (src.hasPredecessor()) {
473      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.dependency.predecessor", Reference40_50.convertReference(src.getPredecessor()));
474    }
475  }
476
477  private static void convertTestPlanTestCaseTestRun(TestPlanTestCaseTestRunComponent src, Extension tgt) {
478    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
479    if (src.hasNarrativeElement()) {
480      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.narrative", MarkDown40_50.convertMarkdown(src.getNarrativeElement()));
481    }
482    if (src.hasScript()) {
483      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");
484      tgt.addExtension(tgte);
485      convertTestPlanTestCaseTestRunScript(src.getScript(), tgte);
486    }
487  }
488
489  private static void convertTestPlanTestCaseTestRunScript(TestPlanTestCaseTestRunScriptComponent src, Extension tgt) {
490    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
491    if (src.hasLanguage()) {
492      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.language", CodeableConcept40_50.convertCodeableConcept(src.getLanguage()));
493    }
494    if (src.hasSourceStringType()) {
495      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceString", String40_50.convertString(src.getSourceStringType()));
496    }
497    if (src.hasSourceReference()) {
498     tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testRun.script.sourceReference", Reference40_50.convertReference(src.getSourceReference()));
499    }
500  }
501
502  private static void convertTestPlanTestCaseTestData(TestPlanTestCaseTestDataComponent src, Extension tgt) {
503    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
504    if (src.hasType()) {
505      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.type", Coding40_50.convertCoding(src.getType()));
506    }
507    if (src.hasContent()) {
508      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.content", Reference40_50.convertReference(src.getContent()));
509    }
510    if (src.hasSourceStringType()) {
511      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceString", String40_50.convertString(src.getSourceStringType()));
512    }
513    if (src.hasSourceReference()) {
514     tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testData.sourceReference", Reference40_50.convertReference(src.getSourceReference()));
515    }
516  }
517
518  private static void convertTestPlanTestCaseAssertion(TestPlanTestCaseAssertionComponent src, Extension tgt) {
519    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
520    for (CodeableConcept cc : src.getType()) {
521      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.assertion.type", CodeableConcept40_50.convertCodeableConcept(cc));
522    }
523    for (CodeableReference ref : src.getObject()) {
524      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");
525      tgt.addExtension(tgte);
526      convertTestPlanTestCaseAssertionObject(ref, tgte);
527    }
528    for (CodeableReference ref : src.getObject()) {
529      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");
530      tgt.addExtension(tgte);
531      convertTestPlanTestCaseAssertionResult(ref, tgte);
532    }
533  }
534
535  private static void convertTestPlanTestCaseAssertionObject(CodeableReference src, Extension tgt) {
536    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
537    if (src.hasConcept()) {
538      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.concept", CodeableConcept40_50.convertCodeableConcept(src.getConcept()));
539    }
540    if (src.hasReference()) {
541      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.object.reference", Reference40_50.convertReference(src.getReference()));
542    }
543  }
544
545  private static void convertTestPlanTestCaseAssertionResult(CodeableReference src, Extension tgt) {
546    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
547    if (src.hasConcept()) {
548      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.concept", CodeableConcept40_50.convertCodeableConcept(src.getConcept()));
549    }
550    if (src.hasReference()) {
551      tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-TestPlan.testCase.testCase.assertion.result.reference", Reference40_50.convertReference(src.getReference()));
552    }
553  }
554
555}