001package org.hl7.fhir.convertors.conv14_50.resources14_50;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext14_50;
006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.CodeableConcept14_50;
007import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.ContactPoint14_50;
008import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.Identifier14_50;
009import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Boolean14_50;
010import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.DateTime14_50;
011import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Id14_50;
012import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50;
013import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Uri14_50;
014import org.hl7.fhir.dstu2016may.model.StructureMap;
015import org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContextType;
016import org.hl7.fhir.exceptions.FHIRException;
017import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent;
018
019public class StructureMap14_50 {
020
021  public static org.hl7.fhir.r5.model.StructureMap convertStructureMap(org.hl7.fhir.dstu2016may.model.StructureMap src) throws FHIRException {
022    if (src == null || src.isEmpty())
023      return null;
024    org.hl7.fhir.r5.model.StructureMap tgt = new org.hl7.fhir.r5.model.StructureMap();
025    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
026    if (src.hasUrlElement())
027      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
028    if (src.hasVersion())
029      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
030    if (src.hasNameElement())
031      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
032    if (src.hasStatus())
033      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
034    for (org.hl7.fhir.dstu2016may.model.Identifier t : src.getIdentifier())
035      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
036    if (src.hasExperimental())
037      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
038    if (src.hasPublisher())
039      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
040    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContactComponent t : src.getContact())
041      tgt.addContact(convertStructureMapContactComponent(t));
042    if (src.hasDate())
043      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
044    if (src.hasDescription())
045      tgt.setDescription(src.getDescription());
046    for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext())
047      if (CodeableConcept14_50.isJurisdiction(t))
048        tgt.addJurisdiction(CodeableConcept14_50.convertCodeableConcept(t));
049      else
050        tgt.addUseContext(CodeableConcept14_50.convertCodeableConceptToUsageContext(t));
051    if (src.hasRequirements())
052      tgt.setPurpose(src.getRequirements());
053    if (src.hasCopyright())
054      tgt.setCopyright(src.getCopyright());
055    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
056      tgt.addStructure(convertStructureMapStructureComponent(t));
057    for (org.hl7.fhir.dstu2016may.model.UriType t : src.getImport()) tgt.addImport(t.getValue());
058    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
059      tgt.addGroup(convertStructureMapGroupComponent(t));
060    return tgt;
061  }
062
063  public static org.hl7.fhir.dstu2016may.model.StructureMap convertStructureMap(org.hl7.fhir.r5.model.StructureMap src) throws FHIRException {
064    if (src == null || src.isEmpty())
065      return null;
066    org.hl7.fhir.dstu2016may.model.StructureMap tgt = new org.hl7.fhir.dstu2016may.model.StructureMap();
067    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
068    if (src.hasUrlElement())
069      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
070    if (src.hasVersion())
071      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
072    if (src.hasNameElement())
073      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
074    if (src.hasStatus())
075      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
076    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
077      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
078    if (src.hasExperimental())
079      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
080    if (src.hasPublisher())
081      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
082    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
083      tgt.addContact(convertStructureMapContactComponent(t));
084    if (src.hasDate())
085      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
086    if (src.hasDescription())
087      tgt.setDescription(src.getDescription());
088    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
089      if (t.hasValueCodeableConcept())
090        tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept()));
091    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
092      tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t));
093    if (src.hasPurpose())
094      tgt.setRequirements(src.getPurpose());
095    if (src.hasCopyright())
096      tgt.setCopyright(src.getCopyright());
097    for (org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent t : src.getStructure())
098      tgt.addStructure(convertStructureMapStructureComponent(t));
099    for (org.hl7.fhir.r5.model.UriType t : src.getImport()) tgt.addImport(t.getValue());
100    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent t : src.getGroup())
101      tgt.addGroup(convertStructureMapGroupComponent(t));
102    return tgt;
103  }
104
105  public static org.hl7.fhir.r5.model.ContactDetail convertStructureMapContactComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContactComponent src) throws FHIRException {
106    if (src == null || src.isEmpty())
107      return null;
108    org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail();
109    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
110    if (src.hasName())
111      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
112    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom())
113      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
114    return tgt;
115  }
116
117  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContactComponent convertStructureMapContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException {
118    if (src == null || src.isEmpty())
119      return null;
120    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContactComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContactComponent();
121    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
122    if (src.hasName())
123      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
124    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
125      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
126    return tgt;
127  }
128
129  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
130    if (src == null || src.isEmpty())
131      return null;
132    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent();
133    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
134    if (src.hasNameElement())
135      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
136    if (src.hasExtends())
137      tgt.setExtendsElement(Id14_50.convertId(src.getExtendsElement()));
138    if (src.hasDocumentation())
139      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
140    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
141      tgt.addInput(convertStructureMapGroupInputComponent(t));
142    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
143      tgt.addRule(convertStructureMapGroupRuleComponent(t));
144    return tgt;
145  }
146
147  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent convertStructureMapGroupComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupComponent src) throws FHIRException {
148    if (src == null || src.isEmpty())
149      return null;
150    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent();
151    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
152    if (src.hasNameElement())
153      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
154    if (src.hasExtends())
155      tgt.setExtendsElement(Id14_50.convertId(src.getExtendsElement()));
156    if (src.hasTypeMode())
157      throw new FHIRException("Unable to downgrade structure map with group.typeMode other than 'None': " + src.getTypeMode().getDisplay());
158    if (src.hasDocumentation())
159      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
160    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent t : src.getInput())
161      tgt.addInput(convertStructureMapGroupInputComponent(t));
162    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
163      tgt.addRule(convertStructureMapGroupRuleComponent(t));
164    return tgt;
165  }
166
167  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
168    if (src == null || src.isEmpty())
169      return null;
170    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent();
171    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
172    if (src.hasNameElement())
173      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
174    if (src.hasType())
175      tgt.setTypeElement(String14_50.convertString(src.getTypeElement()));
176    if (src.hasMode())
177      tgt.setModeElement(convertStructureMapInputMode(src.getModeElement()));
178    if (src.hasDocumentation())
179      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
180    return tgt;
181  }
182
183  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent convertStructureMapGroupInputComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent src) throws FHIRException {
184    if (src == null || src.isEmpty())
185      return null;
186    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupInputComponent();
187    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
188    if (src.hasNameElement())
189      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
190    if (src.hasType())
191      tgt.setTypeElement(String14_50.convertString(src.getTypeElement()));
192    if (src.hasMode())
193      tgt.setModeElement(convertStructureMapInputMode(src.getModeElement()));
194    if (src.hasDocumentation())
195      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
196    return tgt;
197  }
198
199  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
200    if (src == null || src.isEmpty())
201      return null;
202    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent();
203    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
204    if (src.hasNameElement())
205      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
206    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
207      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
208    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
209      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
210    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
211      tgt.addRule(convertStructureMapGroupRuleComponent(t));
212    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
213      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
214    if (src.hasDocumentation())
215      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
216    return tgt;
217  }
218
219  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent convertStructureMapGroupRuleComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent src) throws FHIRException {
220    if (src == null || src.isEmpty())
221      return null;
222    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleComponent();
223    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
224    if (src.hasNameElement())
225      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
226    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent t : src.getSource())
227      tgt.addSource(convertStructureMapGroupRuleSourceComponent(t));
228    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent t : src.getTarget())
229      tgt.addTarget(convertStructureMapGroupRuleTargetComponent(t));
230    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleComponent t : src.getRule())
231      tgt.addRule(convertStructureMapGroupRuleComponent(t));
232    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent t : src.getDependent())
233      tgt.addDependent(convertStructureMapGroupRuleDependentComponent(t));
234    if (src.hasDocumentation())
235      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
236    return tgt;
237  }
238
239  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
240    if (src == null || src.isEmpty())
241      return null;
242    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent();
243    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
244    if (src.hasNameElement())
245      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
246    for (StructureMapGroupRuleTargetParameterComponent t : src.getParameter()) tgt.addVariable(t.getValue().primitiveValue());
247    return tgt;
248  }
249
250  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent convertStructureMapGroupRuleDependentComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent src) throws FHIRException {
251    if (src == null || src.isEmpty())
252      return null;
253    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleDependentComponent();
254    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
255    if (src.hasNameElement())
256      tgt.setNameElement(Id14_50.convertId(src.getNameElement()));
257    for (org.hl7.fhir.dstu2016may.model.StringType t : src.getVariable()) tgt.addParameter().setValue(String14_50.convertString(t));
258    return tgt;
259  }
260
261  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
262    if (src == null || src.isEmpty())
263      return null;
264    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent();
265    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
266    tgt.setContextType(StructureMapContextType.TYPE);
267    if (src.hasContextElement())
268      tgt.setContextElement(Id14_50.convertId(src.getContextElement()));
269    if (src.hasElement())
270      tgt.setElementElement(String14_50.convertString(src.getElementElement()));
271    if (src.hasListMode())
272      tgt.setListModeElement(convertStructureMapSourceListMode(src.getListModeElement()));
273    if (src.hasVariable())
274      tgt.setVariableElement(Id14_50.convertId(src.getVariableElement()));
275    if (src.hasCondition())
276      tgt.setConditionElement(String14_50.convertString(src.getConditionElement()));
277    if (src.hasCheck())
278      tgt.setCheckElement(String14_50.convertString(src.getCheckElement()));
279    return tgt;
280  }
281
282  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent convertStructureMapGroupRuleSourceComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent src) throws FHIRException {
283    if (src == null || src.isEmpty())
284      return null;
285    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleSourceComponent();
286    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
287    tgt.setMin(src.getRequired() ? 1 : 0);
288    if (src.getContextType().equals(StructureMap.StructureMapContextType.TYPE))
289      tgt.setType(src.getContext());
290    if (src.hasElement())
291      tgt.setElementElement(String14_50.convertString(src.getElementElement()));
292    if (src.hasListMode())
293      tgt.setListModeElement(convertStructureMapSourceListMode(src.getListModeElement()));
294    if (src.hasVariable())
295      tgt.setVariableElement(Id14_50.convertId(src.getVariableElement()));
296    if (src.hasCondition())
297      tgt.setConditionElement(String14_50.convertString(src.getConditionElement()));
298    if (src.hasCheck())
299      tgt.setCheckElement(String14_50.convertString(src.getCheckElement()));
300    return tgt;
301  }
302
303  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
304    if (src == null || src.isEmpty())
305      return null;
306    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent();
307    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
308    if (src.hasContext())
309      tgt.setContextElement(Id14_50.convertId(src.getContextElement()));
310    tgt.setContextType(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContextType.VARIABLE);
311    if (src.hasElement())
312      tgt.setElementElement(String14_50.convertString(src.getElementElement()));
313    if (src.hasVariable())
314      tgt.setVariableElement(Id14_50.convertId(src.getVariableElement()));
315    tgt.setListMode(src.getListMode().stream()
316      .map(StructureMap14_50::convertStructureMapTargetListMode)
317      .collect(Collectors.toList()));
318    if (src.hasListRuleId())
319      tgt.setListRuleIdElement(Id14_50.convertId(src.getListRuleIdElement()));
320    if (src.hasTransform())
321      tgt.setTransformElement(convertStructureMapTransform(src.getTransformElement()));
322    for (org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
323      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
324    return tgt;
325  }
326
327  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent convertStructureMapGroupRuleTargetComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent src) throws FHIRException {
328    if (src == null || src.isEmpty())
329      return null;
330    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent();
331    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
332    if (src.hasContext())
333      tgt.setContextElement(Id14_50.convertIdToString(src.getContextElement()));
334    if (src.hasContextType() && src.getContextType() == org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapContextType.VARIABLE)
335      throw new Error("This conversion is not supported. Consult code maintainers"); // this should never happens - no one knows what the intent was here.
336    if (src.hasElement())
337      tgt.setElementElement(String14_50.convertString(src.getElementElement()));
338    if (src.hasVariable())
339      tgt.setVariableElement(Id14_50.convertId(src.getVariableElement()));
340    tgt.setListMode(src.getListMode().stream()
341      .map(StructureMap14_50::convertStructureMapTargetListMode)
342      .collect(Collectors.toList()));
343    if (src.hasListRuleId())
344      tgt.setListRuleIdElement(Id14_50.convertId(src.getListRuleIdElement()));
345    if (src.hasTransform())
346      tgt.setTransformElement(convertStructureMapTransform(src.getTransformElement()));
347    for (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetParameterComponent t : src.getParameter())
348      tgt.addParameter(convertStructureMapGroupRuleTargetParameterComponent(t));
349    return tgt;
350  }
351
352  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
353    if (src == null || src.isEmpty())
354      return null;
355    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
356    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
357    if (src.hasValue())
358      tgt.setValue(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getValue()));
359    return tgt;
360  }
361
362  public static org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent convertStructureMapGroupRuleTargetParameterComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetParameterComponent src) throws FHIRException {
363    if (src == null || src.isEmpty())
364      return null;
365    org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetParameterComponent();
366    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
367    if (src.hasValue())
368      tgt.setValue(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getValue()));
369    return tgt;
370  }
371
372  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode> convertStructureMapInputMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode> src) throws FHIRException {
373    if (src == null || src.isEmpty())
374      return null;
375    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputModeEnumFactory());
376    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
377    switch (src.getValue()) {
378      case SOURCE:
379        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode.SOURCE);
380        break;
381      case TARGET:
382        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode.TARGET);
383        break;
384      default:
385        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode.NULL);
386        break;
387    }
388    return tgt;
389  }
390
391  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode> convertStructureMapInputMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapInputMode> src) throws FHIRException {
392    if (src == null || src.isEmpty())
393      return null;
394    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());
395    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
396    switch (src.getValue()) {
397      case SOURCE:
398        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.SOURCE);
399        break;
400      case TARGET:
401        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.TARGET);
402        break;
403      default:
404        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapInputMode.NULL);
405        break;
406    }
407    return tgt;
408  }
409
410  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> convertStructureMapSourceListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode> src) throws FHIRException {
411    if (src == null || src.isEmpty())
412      return null;
413    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListModeEnumFactory());
414    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
415    switch (src.getValue()) {
416      case FIRST:
417        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.FIRST);
418        break;
419      case LAST:
420        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.LAST);
421        break;
422      default:
423        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.NULL);
424        break;
425    }
426    return tgt;
427  }
428
429  public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode> convertStructureMapSourceListMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> src) throws FHIRException {
430    if (src == null || src.isEmpty())
431      return null;
432    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());
433    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
434    switch (src.getValue()) {
435      case FIRST:
436        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.FIRST);
437        break;
438      case LAST:
439        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.LAST);
440        break;
441      default:
442        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapSourceListMode.NULL);
443        break;
444    }
445    return tgt;
446  }
447
448  public static org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
449    if (src == null || src.isEmpty())
450      return null;
451    org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent();
452    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
453    if (src.hasUrl())
454      tgt.setUrl(src.getUrl());
455    if (src.hasMode())
456      tgt.setModeElement(convertStructureMapStructureMode(src.getModeElement()));
457    if (src.hasDocumentation())
458      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
459    return tgt;
460  }
461
462  public static org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent convertStructureMapStructureComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent src) throws FHIRException {
463    if (src == null || src.isEmpty())
464      return null;
465    org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent tgt = new org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent();
466    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt);
467    if (src.hasUrl())
468      tgt.setUrl(src.getUrl());
469    if (src.hasMode())
470      tgt.setModeElement(convertStructureMapStructureMode(src.getModeElement()));
471    if (src.hasDocumentation())
472      tgt.setDocumentationElement(String14_50.convertString(src.getDocumentationElement()));
473    return tgt;
474  }
475
476  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode> convertStructureMapStructureMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode> src) throws FHIRException {
477    if (src == null || src.isEmpty())
478      return null;
479    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelModeEnumFactory());
480    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
481    switch (src.getValue()) {
482      case PRODUCED:
483        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode.PRODUCED);
484        break;
485      case QUERIED:
486        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode.QUERIED);
487        break;
488      case SOURCE:
489        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode.SOURCE);
490        break;
491      case TARGET:
492        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode.TARGET);
493        break;
494      default:
495        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode.NULL);
496        break;
497    }
498    return tgt;
499  }
500
501  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode> convertStructureMapStructureMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapModelMode> src) throws FHIRException {
502    if (src == null || src.isEmpty())
503      return null;
504    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());
505    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
506    switch (src.getValue()) {
507      case PRODUCED:
508        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.PRODUCED);
509        break;
510      case QUERIED:
511        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.QUERIED);
512        break;
513      case SOURCE:
514        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.SOURCE);
515        break;
516      case TARGET:
517        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.TARGET);
518        break;
519      default:
520        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode.NULL);
521        break;
522    }
523    return tgt;
524  }
525
526  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> convertStructureMapTargetListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode> src) throws FHIRException {
527    if (src == null || src.isEmpty())
528      return null;
529    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListModeEnumFactory());
530    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
531    switch (src.getValue()) {
532      case FIRST:
533        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.FIRST);
534        break;
535      case LAST:
536        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.LAST);
537        break;
538      case SHARE:
539        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.SHARE);
540        break;
541      default:
542        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode.NULL);
543        break;
544    }
545    return tgt;
546  }
547
548  public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode> convertStructureMapTargetListMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapListMode> src) throws FHIRException {
549    if (src == null || src.isEmpty())
550      return null;
551    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());
552    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
553    switch (src.getValue()) {
554      case FIRST:
555        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.FIRST);
556        break;
557      case LAST:
558        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.LAST);
559        break;
560      case SHARE:
561        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.SHARE);
562        break;
563      default:
564        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTargetListMode.NULL);
565        break;
566    }
567    return tgt;
568  }
569
570  public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTransform> convertStructureMapTransform(org.hl7.fhir.dstu2016may.model.Enumeration<StructureMap.StructureMapTransform> src) throws FHIRException {
571    if (src == null || src.isEmpty())
572      return null;
573    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());
574    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
575    switch (src.getValue()) {
576      case APPEND:
577        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.APPEND);
578      case CAST:
579        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CAST);
580      case COPY:
581        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.COPY);
582      case CREATE:
583        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.CREATE);
584      case DATEOP:
585        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.DATEOP);
586      case ESCAPE:
587        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.ESCAPE);
588      case EVALUATE:
589        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.EVALUATE);
590      case POINTER:
591        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.POINTER);
592      case REFERENCE:
593        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.REFERENCE);
594      case TRANSLATE:
595        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.TRANSLATE);
596      case TRUNCATE:
597        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.TRUNCATE);
598      case UUID:
599        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.UUID);
600      default:
601        tgt.setValue(org.hl7.fhir.r5.model.StructureMap.StructureMapTransform.NULL);
602    }
603    return tgt;
604  }
605
606  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform> convertStructureMapTransform(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureMap.StructureMapTransform> src) throws FHIRException {
607    if (src == null || src.isEmpty())
608      return null;
609    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransformEnumFactory());
610    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
611    switch (src.getValue()) {
612      case APPEND:
613        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.APPEND);
614        break;
615      case CAST:
616        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.CAST);
617        break;
618      case COPY:
619        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.COPY);
620        break;
621      case CREATE:
622        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.CREATE);
623        break;
624      case DATEOP:
625        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.DATEOP);
626        break;
627      case ESCAPE:
628        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.ESCAPE);
629        break;
630      case EVALUATE:
631        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.EVALUATE);
632        break;
633      case POINTER:
634        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.POINTER);
635        break;
636      case REFERENCE:
637        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.REFERENCE);
638        break;
639      case TRANSLATE:
640        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.TRANSLATE);
641        break;
642      case TRUNCATE:
643        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.TRUNCATE);
644        break;
645      case UUID:
646        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.UUID);
647        break;
648      default:
649        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapTransform.NULL);
650        break;
651    }
652    return tgt;
653  }
654}