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