001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Id40_50;
014import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Integer40_50;
015import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
016import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
017import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
018import org.hl7.fhir.exceptions.FHIRException;
019import org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode;
020import org.hl7.fhir.r4.utils.ToolingExtensions;
021import org.hl7.fhir.r5.model.BooleanType;
022import org.hl7.fhir.r5.model.DataType;
023import org.hl7.fhir.r5.model.DecimalType;
024import org.hl7.fhir.r5.model.IdType;
025import org.hl7.fhir.r5.model.IntegerType;
026import org.hl7.fhir.r5.model.StringType;
027import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent;
028import org.hl7.fhir.r5.utils.FHIRPathConstant;
029import org.hl7.fhir.utilities.Utilities;
030
031/*
032  Copyright (c) 2011+, HL7, Inc.
033  All rights reserved.
034  
035  Redistribution and use in source and binary forms, with or without modification, 
036  are permitted provided that the following conditions are met:
037  
038   * Redistributions of source code must retain the above copyright notice, this 
039     list of conditions and the following disclaimer.
040   * Redistributions in binary form must reproduce the above copyright notice, 
041     this list of conditions and the following disclaimer in the documentation 
042     and/or other materials provided with the distribution.
043   * Neither the name of HL7 nor the names of its contributors may be used to 
044     endorse or promote products derived from this software without specific 
045     prior written permission.
046  
047  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
048  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
049  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
050  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
051  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
052  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
053  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
054  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
055  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
056  POSSIBILITY OF SUCH DAMAGE.
057  
058*/
059// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
060public class StructureMap40_50 {
061
062  public static org.hl7.fhir.r5.model.StructureMap convertStructureMap(org.hl7.fhir.r4.model.StructureMap src) throws FHIRException {
063    if (src == null)
064      return null;
065    org.hl7.fhir.r5.model.StructureMap tgt = new org.hl7.fhir.r5.model.StructureMap();
066    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
067    if (src.hasUrl())
068      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
069    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
070      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
071    if (src.hasVersion())
072      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
073    if (src.hasName())
074      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
075    if (src.hasTitle())
076      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
077    if (src.hasStatus())
078      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
079    if (src.hasExperimental())
080      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
081    if (src.hasDate())
082      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
083    if (src.hasPublisher())
084      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
085    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
086      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
087    if (src.hasDescription())
088      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
089    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
090      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
091    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
092      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
093    if (src.hasPurpose())
094      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
095    if (src.hasCopyright())
096      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
097    for (org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
098      tgt.addStructure(convertStructureMapStructureComponent(t));
099    for (org.hl7.fhir.r4.model.CanonicalType t : src.getImport())
100      tgt.getImport().add(Canonical40_50.convertCanonical(t));
101    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
102      tgt.addGroup(convertStructureMapGroupComponent(t));
103    return tgt;
104  }
105
106  public static org.hl7.fhir.r4.model.StructureMap convertStructureMap(org.hl7.fhir.r5.model.StructureMap src) throws FHIRException {
107    if (src == null)
108      return null;
109    org.hl7.fhir.r4.model.StructureMap tgt = new org.hl7.fhir.r4.model.StructureMap();
110    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
111    if (src.hasUrl())
112      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
113    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
114      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
115    if (src.hasVersion())
116      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
117    if (src.hasName())
118      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
119    if (src.hasTitle())
120      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
121    if (src.hasStatus())
122      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
123    if (src.hasExperimental())
124      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
125    if (src.hasDate())
126      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
127    if (src.hasPublisher())
128      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
129    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
130      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
131    if (src.hasDescription())
132      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
133    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
134      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
135    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
136      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
137    if (src.hasPurpose())
138      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
139    if (src.hasCopyright())
140      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
141    for (org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
142      tgt.addStructure(convertStructureMapStructureComponent(t));
143    for (org.hl7.fhir.r5.model.CanonicalType t : src.getImport())
144      tgt.getImport().add(Canonical40_50.convertCanonical(t));
145    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
146      tgt.addGroup(convertStructureMapGroupComponent(t));
147    return tgt;
148  }
149
150  public static org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
151    if (src == null)
152      return null;
153    org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent();
154    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
155    if (src.hasUrl())
156      tgt.setUrlElement(Canonical40_50.convertCanonical(src.getUrlElement()));
157    if (src.hasMode())
158      tgt.setModeElement(convertStructureMapModelMode(src.getModeElement()));
159    if (src.hasAlias())
160      tgt.setAliasElement(String40_50.convertString(src.getAliasElement()));
161    if (src.hasDocumentation())
162      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
163    return tgt;
164  }
165
166  public static org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
167    if (src == null)
168      return null;
169    org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent();
170    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
171    if (src.hasUrl())
172      tgt.setUrlElement(Canonical40_50.convertCanonical(src.getUrlElement()));
173    if (src.hasMode())
174      tgt.setModeElement(convertStructureMapModelMode(src.getModeElement()));
175    if (src.hasAlias())
176      tgt.setAliasElement(String40_50.convertString(src.getAliasElement()));
177    if (src.hasDocumentation())
178      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
179    return tgt;
180  }
181
182  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode> convertStructureMapModelMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode> src) throws FHIRException {
183    if (src == null || src.isEmpty())
184      return null;
185    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapModelModeEnumFactory());
186    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
187    switch (src.getValue()) {
188      case SOURCE:
189        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.SOURCE);
190        break;
191      case QUERIED:
192        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.QUERIED);
193        break;
194      case TARGET:
195        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.TARGET);
196        break;
197      case PRODUCED:
198        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.PRODUCED);
199        break;
200      default:
201        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.NULL);
202        break;
203    }
204    return tgt;
205  }
206
207  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode> convertStructureMapModelMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode> src) throws FHIRException {
208    if (src == null || src.isEmpty())
209      return null;
210    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapModelModeEnumFactory());
211    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
212    switch (src.getValue()) {
213      case SOURCE:
214        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.SOURCE);
215        break;
216      case QUERIED:
217        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.QUERIED);
218        break;
219      case TARGET:
220        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.TARGET);
221        break;
222      case PRODUCED:
223        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.PRODUCED);
224        break;
225      default:
226        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode.NULL);
227        break;
228    }
229    return tgt;
230  }
231
232  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
233    if (src == null)
234      return null;
235    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent();
236    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
237    if (src.hasName())
238      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
239    if (src.hasExtends())
240      tgt.setExtendsElement(Id40_50.convertId(src.getExtendsElement()));
241    if (src.hasTypeMode())
242      tgt.setTypeModeElement(convertStructureMapGroupTypeMode(src.getTypeModeElement()));
243    if (src.hasDocumentation())
244      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
245    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
246      tgt.addInput(convertStructureMapGroupInputComponent(t));
247    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
248      tgt.addRule(convertStructureMapGroupRuleComponent(t));
249    return tgt;
250  }
251
252  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
253    if (src == null)
254      return null;
255    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent();
256    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
257    if (src.hasName())
258      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
259    if (src.hasExtends())
260      tgt.setExtendsElement(Id40_50.convertId(src.getExtendsElement()));
261    if (src.hasTypeMode()) {
262      tgt.setTypeModeElement(convertStructureMapGroupTypeMode(src.getTypeModeElement()));
263    } else {
264      tgt.setTypeMode(StructureMapGroupTypeMode.NONE);
265    }
266    if (src.hasDocumentation())
267      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
268    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
269      tgt.addInput(convertStructureMapGroupInputComponent(t));
270    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
271      tgt.addRule(convertStructureMapGroupRuleComponent(t));
272    return tgt;
273  }
274
275  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode> convertStructureMapGroupTypeMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode> src) throws FHIRException {
276    if (src == null || src.isEmpty())
277      return null;
278    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeModeEnumFactory());
279    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
280    switch (src.getValue()) {
281      case NONE:
282        return null;
283      case TYPES:
284        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode.TYPES);
285        break;
286      case TYPEANDTYPES:
287        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode.TYPEANDTYPES);
288        break;
289      default:
290        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode.NULL);
291        break;
292    }
293    return tgt;
294  }
295
296  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode> convertStructureMapGroupTypeMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapGroupTypeMode> src) throws FHIRException {
297    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeModeEnumFactory());
298    if (src == null || src.isEmpty()) {
299      tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.NONE);
300      return tgt;
301    }
302    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
303    switch (src.getValue()) {
304      case TYPES:
305        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.TYPES);
306        break;
307      case TYPEANDTYPES:
308        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.TYPEANDTYPES);
309        break;
310      default:
311        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupTypeMode.NULL);
312        break;
313    }
314    return tgt;
315  }
316
317  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
318    if (src == null)
319      return null;
320    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent();
321    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
322    if (src.hasName())
323      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
324    if (src.hasType())
325      tgt.setTypeElement(String40_50.convertString(src.getTypeElement()));
326    if (src.hasMode())
327      tgt.setModeElement(convertStructureMapInputMode(src.getModeElement()));
328    if (src.hasDocumentation())
329      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
330    return tgt;
331  }
332
333  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
334    if (src == null)
335      return null;
336    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupInputComponent();
337    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
338    if (src.hasName())
339      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
340    if (src.hasType())
341      tgt.setTypeElement(String40_50.convertString(src.getTypeElement()));
342    if (src.hasMode())
343      tgt.setModeElement(convertStructureMapInputMode(src.getModeElement()));
344    if (src.hasDocumentation())
345      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
346    return tgt;
347  }
348
349  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode> convertStructureMapInputMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode> src) throws FHIRException {
350    if (src == null || src.isEmpty())
351      return null;
352    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapInputModeEnumFactory());
353    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
354    switch (src.getValue()) {
355      case SOURCE:
356        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.SOURCE);
357        break;
358      case TARGET:
359        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.TARGET);
360        break;
361      default:
362        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.NULL);
363        break;
364    }
365    return tgt;
366  }
367
368  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode> convertStructureMapInputMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode> src) throws FHIRException {
369    if (src == null || src.isEmpty())
370      return null;
371    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapInputModeEnumFactory());
372    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
373    switch (src.getValue()) {
374      case SOURCE:
375        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.SOURCE);
376        break;
377      case TARGET:
378        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.TARGET);
379        break;
380      default:
381        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapInputMode.NULL);
382        break;
383    }
384    return tgt;
385  }
386
387  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
388    if (src == null)
389      return null;
390    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent();
391    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
392    if (src.hasName())
393      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
394    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
395      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
396    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
397      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
398    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
399      tgt.addRule(convertStructureMapGroupRuleComponent(t));
400    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
401      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
402    if (src.hasDocumentation())
403      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
404    return tgt;
405  }
406
407  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
408    if (src == null)
409      return null;
410    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleComponent();
411    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
412    if (src.hasName())
413      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
414    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
415      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
416    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
417      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
418    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
419      tgt.addRule(convertStructureMapGroupRuleComponent(t));
420    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
421      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
422    if (src.hasDocumentation())
423      tgt.setDocumentationElement(String40_50.convertString(src.getDocumentationElement()));
424    return tgt;
425  }
426
427  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
428    if (src == null)
429      return null;
430    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent();
431    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
432    if (src.hasContext())
433      tgt.setContextElement(Id40_50.convertId(src.getContextElement()));
434    if (src.hasMin())
435      tgt.setMinElement(Integer40_50.convertInteger(src.getMinElement()));
436    if (src.hasMax())
437      tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
438    if (src.hasType())
439      tgt.setTypeElement(String40_50.convertString(src.getTypeElement()));
440    if (src.hasDefaultValue())
441      tgt.setDefaultValueElement((StringType) ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDefaultValue()));
442    if (src.hasElement())
443      tgt.setElementElement(String40_50.convertString(src.getElementElement()));
444    if (src.hasListMode())
445      tgt.setListModeElement(convertStructureMapSourceListMode(src.getListModeElement()));
446    if (src.hasVariable())
447      tgt.setVariableElement(Id40_50.convertId(src.getVariableElement()));
448    if (src.hasCondition())
449      tgt.setConditionElement(String40_50.convertString(src.getConditionElement()));
450    if (src.hasCheck())
451      tgt.setCheckElement(String40_50.convertString(src.getCheckElement()));
452    if (src.hasLogMessage())
453      tgt.setLogMessageElement(String40_50.convertString(src.getLogMessageElement()));
454    return tgt;
455  }
456
457  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
458    if (src == null)
459      return null;
460    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent();
461    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
462    if (src.hasContext())
463      tgt.setContextElement(Id40_50.convertId(src.getContextElement()));
464    if (src.hasMin())
465      tgt.setMinElement(Integer40_50.convertInteger(src.getMinElement()));
466    if (src.hasMax())
467      tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
468    if (src.hasType())
469      tgt.setTypeElement(String40_50.convertString(src.getTypeElement()));
470    if (src.hasDefaultValue())
471      tgt.setDefaultValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDefaultValueElement()));
472    if (src.hasElement())
473      tgt.setElementElement(String40_50.convertString(src.getElementElement()));
474    if (src.hasListMode())
475      tgt.setListModeElement(convertStructureMapSourceListMode(src.getListModeElement()));
476    if (src.hasVariable())
477      tgt.setVariableElement(Id40_50.convertId(src.getVariableElement()));
478    if (src.hasCondition())
479      tgt.setConditionElement(String40_50.convertString(src.getConditionElement()));
480    if (src.hasCheck())
481      tgt.setCheckElement(String40_50.convertString(src.getCheckElement()));
482    if (src.hasLogMessage())
483      tgt.setLogMessageElement(String40_50.convertString(src.getLogMessageElement()));
484    return tgt;
485  }
486
487  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode> convertStructureMapSourceListMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode> src) throws FHIRException {
488    if (src == null || src.isEmpty())
489      return null;
490    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListModeEnumFactory());
491    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
492    switch (src.getValue()) {
493      case FIRST:
494        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.FIRST);
495        break;
496      case NOTFIRST:
497        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.NOTFIRST);
498        break;
499      case LAST:
500        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.LAST);
501        break;
502      case NOTLAST:
503        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.NOTLAST);
504        break;
505      case ONLYONE:
506        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.ONLYONE);
507        break;
508      default:
509        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.NULL);
510        break;
511    }
512    return tgt;
513  }
514
515  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode> convertStructureMapSourceListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode> src) throws FHIRException {
516    if (src == null || src.isEmpty())
517      return null;
518    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListModeEnumFactory());
519    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
520    switch (src.getValue()) {
521      case FIRST:
522        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.FIRST);
523        break;
524      case NOTFIRST:
525        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NOTFIRST);
526        break;
527      case LAST:
528        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.LAST);
529        break;
530      case NOTLAST:
531        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NOTLAST);
532        break;
533      case ONLYONE:
534        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.ONLYONE);
535        break;
536      default:
537        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapSourceListMode.NULL);
538        break;
539    }
540    return tgt;
541  }
542
543  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
544    if (src == null)
545      return null;
546    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent();
547    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
548    if (src.hasContext())
549      tgt.setContextElement(Id40_50.convertIdToString(src.getContextElement()));
550    if (src.hasContextType() && src.getContextType() != org.hl7.fhir.r4.model.StructureMap.StructureMapContextType.VARIABLE)
551      throw new Error("This conversion is not supported. Consult code maintainers"); // this should never happens - no one knows what the intent was here.
552    if (src.hasElement())
553      tgt.setElementElement(String40_50.convertString(src.getElementElement()));
554    if (src.hasVariable())
555      tgt.setVariableElement(Id40_50.convertId(src.getVariableElement()));
556    tgt.setListMode(src.getListMode().stream()
557      .map(StructureMap40_50::convertStructureMapTargetListMode)
558      .collect(Collectors.toList()));
559    if (src.hasListRuleId())
560      tgt.setListRuleIdElement(Id40_50.convertId(src.getListRuleIdElement()));
561    if (src.hasTransform())
562      tgt.setTransformElement(convertStructureMapTransform(src.getTransformElement()));
563    for (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
564      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
565    return tgt;
566  }
567
568  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
569    if (src == null)
570      return null;
571    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetComponent();
572    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
573    if (src.hasContext())
574      tgt.setContextElement(Id40_50.convertId(src.getContextElement()));
575    tgt.setContextType(org.hl7.fhir.r4.model.StructureMap.StructureMapContextType.VARIABLE);
576    if (src.hasElement())
577      tgt.setElementElement(String40_50.convertString(src.getElementElement()));
578    if (src.hasVariable())
579      tgt.setVariableElement(Id40_50.convertId(src.getVariableElement()));
580    tgt.setListMode(src.getListMode().stream()
581      .map(StructureMap40_50::convertStructureMapTargetListMode)
582      .collect(Collectors.toList()));
583    if (src.hasListRuleId())
584      tgt.setListRuleIdElement(Id40_50.convertId(src.getListRuleIdElement()));
585    if (src.hasTransform())
586      tgt.setTransformElement(convertStructureMapTransform(src.getTransformElement()));
587    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
588      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
589    return tgt;
590  }
591
592  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode> convertStructureMapTargetListMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode> src) throws FHIRException {
593    if (src == null || src.isEmpty())
594      return null;
595    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListModeEnumFactory());
596    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
597    switch (src.getValue()) {
598      case FIRST:
599        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.FIRST);
600        break;
601      case SHARE:
602        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.SHARE);
603        break;
604      case LAST:
605        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.LAST);
606        break;
607      case COLLATE:
608        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.SINGLE);
609        break;
610      default:
611        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.NULL);
612        break;
613    }
614    return tgt;
615  }
616
617  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode> convertStructureMapTargetListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode> src) throws FHIRException {
618    if (src == null || src.isEmpty())
619      return null;
620    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListModeEnumFactory());
621    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
622    switch (src.getValue()) {
623      case FIRST:
624        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.FIRST);
625        break;
626      case SHARE:
627        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.SHARE);
628        break;
629      case LAST:
630        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.LAST);
631        break;
632      case SINGLE:
633        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.COLLATE);
634        break;
635      default:
636        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTargetListMode.NULL);
637        break;
638    }
639    return tgt;
640  }
641
642  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTransform> convertStructureMapTransform(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTransform> src) throws FHIRException {
643    if (src == null || src.isEmpty())
644      return null;
645    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTransform> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureMap.StructureMapTransformEnumFactory());
646    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
647    switch (src.getValue()) {
648      case CREATE:
649        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CREATE);
650        break;
651      case COPY:
652        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.COPY);
653        break;
654      case TRUNCATE:
655        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.TRUNCATE);
656        break;
657      case ESCAPE:
658        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.ESCAPE);
659        break;
660      case CAST:
661        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CAST);
662        break;
663      case APPEND:
664        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.APPEND);
665        break;
666      case TRANSLATE:
667        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.TRANSLATE);
668        break;
669      case REFERENCE:
670        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.REFERENCE);
671        break;
672      case DATEOP:
673        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.DATEOP);
674        break;
675      case UUID:
676        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.UUID);
677        break;
678      case POINTER:
679        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.POINTER);
680        break;
681      case EVALUATE:
682        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.EVALUATE);
683        break;
684      case CC:
685        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CC);
686        break;
687      case C:
688        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.C);
689        break;
690      case QTY:
691        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.QTY);
692        break;
693      case ID:
694        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.ID);
695        break;
696      case CP:
697        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CP);
698        break;
699      default:
700        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.NULL);
701        break;
702    }
703    return tgt;
704  }
705
706  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTransform> convertStructureMapTransform(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTransform> src) throws FHIRException {
707    if (src == null || src.isEmpty())
708      return null;
709    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureMap.StructureMapTransform> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureMap.StructureMapTransformEnumFactory());
710    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
711    switch (src.getValue()) {
712      case CREATE:
713        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CREATE);
714        break;
715      case COPY:
716        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.COPY);
717        break;
718      case TRUNCATE:
719        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.TRUNCATE);
720        break;
721      case ESCAPE:
722        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.ESCAPE);
723        break;
724      case CAST:
725        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CAST);
726        break;
727      case APPEND:
728        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.APPEND);
729        break;
730      case TRANSLATE:
731        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.TRANSLATE);
732        break;
733      case REFERENCE:
734        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.REFERENCE);
735        break;
736      case DATEOP:
737        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.DATEOP);
738        break;
739      case UUID:
740        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.UUID);
741        break;
742      case POINTER:
743        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.POINTER);
744        break;
745      case EVALUATE:
746        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.EVALUATE);
747        break;
748      case CC:
749        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CC);
750        break;
751      case C:
752        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.C);
753        break;
754      case QTY:
755        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.QTY);
756        break;
757      case ID:
758        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.ID);
759        break;
760      case CP:
761        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.CP);
762        break;
763      default:
764        tgt.setValue(org.hl7.fhir.r4.model.StructureMap.StructureMapTransform.NULL);
765        break;
766    }
767    return tgt;
768  }
769
770  //DIRTY
771  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
772    if (src == null)
773      return null;
774    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
775    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
776    if (src.hasValue())
777      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
778    return tgt;
779  }
780
781
782  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
783    if (src == null)
784      return null;
785    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
786    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
787    if (src.hasValue())
788      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
789    return tgt;
790  }
791
792  //DIRTY
793  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
794    if (src == null)
795      return null;
796    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent();
797    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
798    if (src.hasName())
799      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
800    for (org.hl7.fhir.r4.model.StringType t : src.getVariable()) tgt.addParameter().setValue(convertVariableStringToParameterDataType(t));
801    return tgt;
802  }
803
804  public static org.hl7.fhir.r5.model.DataType convertVariableStringToParameterDataType(org.hl7.fhir.r4.model.StringType src) {
805    if (src.hasExtension(ToolingExtensions.EXT_ORIGINAL_VARIABLE_TYPE)) {
806      return ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getExtensionByUrl(ToolingExtensions.EXT_ORIGINAL_VARIABLE_TYPE).getValue()); 
807    } else {
808      org.hl7.fhir.r5.model.IdType tgt = new org.hl7.fhir.r5.model.IdType();
809      ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
810      if (src.hasValue()) {
811        tgt.setValueAsString(src.getValueAsString());
812      }
813      return tgt;
814    } 
815  }
816
817  public static org.hl7.fhir.r5.model.DataType convertVariableStringToGuessedParameterDataType(org.hl7.fhir.r4.model.StringType it) {
818    final String stringValue = it.asStringValue();
819    if (!FHIRPathConstant.isFHIRPathConstant(stringValue)) {
820      return new IdType(stringValue);
821    } else if (FHIRPathConstant.isFHIRPathStringConstant(stringValue))
822      return new StringType(stringValue);
823    else {
824      return convertVariableStringToGuessedParameterConstantType(stringValue);
825    }
826  }
827
828  public static DataType convertVariableStringToGuessedParameterConstantType(String stringValue) {
829    if (Utilities.isInteger(stringValue))
830      return new IntegerType(stringValue);
831    else if (Utilities.isDecimal(stringValue, false))
832      return new DecimalType(stringValue);
833    else if (Utilities.existsInList(stringValue, "true", "false"))
834      return new BooleanType(stringValue.equals("true"));
835    else
836      return new StringType(stringValue);
837  }
838
839  //DIRTY
840  public static org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
841    if (src == null)
842      return null;
843    org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleDependentComponent();
844    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
845    if (src.hasName())
846      tgt.setNameElement(Id40_50.convertId(src.getNameElement()));
847    for (StructureMapGroupRuleTargetParameterComponent t : src.getParameter()) {
848        tgt.getVariable().add(convertStructureMapGroupRuleTargetParameterComponentToString(t));
849    }
850    return tgt;
851  }
852
853  public static org.hl7.fhir.r4.model.StringType convertStructureMapGroupRuleTargetParameterComponentToString(StructureMapGroupRuleTargetParameterComponent src) {
854    org.hl7.fhir.r4.model.StringType tgt = new org.hl7.fhir.r4.model.StringType();
855    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
856    if (src.hasValueIdType()) {
857      tgt.setValueAsString(src.getValueIdType().getValueAsString());
858    } else if (src.hasValue()) {
859      tgt.addExtension(ToolingExtensions.EXT_ORIGINAL_VARIABLE_TYPE,ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue())); 
860    }
861    return tgt;
862  }
863}