001package org.hl7.fhir.convertors.conv14_50.resources14_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext14_50;
004import org.hl7.fhir.convertors.conv14_50.datatypes14_50.ElementDefinition14_50;
005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.CodeableConcept14_50;
006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.Coding14_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.*;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.model.ElementDefinition;
012import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
013import org.hl7.fhir.utilities.Utilities;
014
015public class StructureDefinition14_50 {
016
017  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> convertExtensionContext(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> src) throws FHIRException {
018    if (src == null || src.isEmpty())
019      return null;
020    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextTypeEnumFactory());
021    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
022    switch (src.getValue()) {
023      case RESOURCE:
024        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType.ELEMENT);
025        break;
026      case DATATYPE:
027        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType.ELEMENT);
028        break;
029      case EXTENSION:
030        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType.EXTENSION);
031        break;
032      default:
033        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType.NULL);
034        break;
035    }
036    return tgt;
037  }
038
039  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.ExtensionContextType> src, String expression) throws FHIRException {
040    if (src == null || src.isEmpty())
041      return null;
042    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContextEnumFactory());
043    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
044    switch (src.getValue()) {
045      case FHIRPATH:
046        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.RESOURCE);
047        break;
048      case ELEMENT:
049        String tn = expression.contains(".") ? expression.substring(0, expression.indexOf(".")) : expression;
050        if (isResource140(tn)) {
051          tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.RESOURCE);
052        } else {
053          tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.DATATYPE);
054        }
055        break;
056      case EXTENSION:
057        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.EXTENSION);
058        break;
059      default:
060        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.ExtensionContext.NULL);
061        break;
062    }
063    return tgt;
064  }
065
066  public static org.hl7.fhir.dstu2016may.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r5.model.StructureDefinition src) throws FHIRException {
067    if (src == null || src.isEmpty())
068      return null;
069    org.hl7.fhir.dstu2016may.model.StructureDefinition tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition();
070    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
071    if (src.hasUrl())
072      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
073    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
074      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
075    if (src.hasVersion())
076      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
077    if (src.hasNameElement())
078      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
079    if (src.hasTitle())
080      tgt.setDisplayElement(String14_50.convertString(src.getTitleElement()));
081    if (src.hasStatus())
082      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
083    if (src.hasExperimental())
084      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
085    if (src.hasPublisher())
086      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
087    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
088      tgt.addContact(convertStructureDefinitionContactComponent(t));
089    if (src.hasDate())
090      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
091    if (src.hasDescription())
092      tgt.setDescription(src.getDescription());
093    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
094      if (t.hasValueCodeableConcept())
095        tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept()));
096    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
097      tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t));
098    if (src.hasPurpose())
099      tgt.setRequirements(src.getPurpose());
100    if (src.hasCopyright())
101      tgt.setCopyright(src.getCopyright());
102    for (org.hl7.fhir.r5.model.Coding t : src.getKeyword()) tgt.addCode(Coding14_50.convertCoding(t));
103    if (src.hasFhirVersion())
104      tgt.setFhirVersion(src.getFhirVersion().toCode());
105    for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
106      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
107    if (src.hasKind())
108      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement()));
109    if (src.hasAbstractElement())
110      tgt.setAbstractElement(Boolean14_50.convertBoolean(src.getAbstractElement()));
111    for (org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent t : src.getContext()) {
112      if (!tgt.hasContextType())
113        tgt.setContextTypeElement(convertExtensionContext(t.getTypeElement(), t.getExpression()));
114      tgt.addContext("Element".equals(t.getExpression()) ? "*" : t.getExpression());
115    }
116    if (src.hasBaseDefinition())
117      tgt.setBaseDefinition(src.getBaseDefinition());
118    if (src.hasType() && src.getDerivation() == org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.CONSTRAINT)
119      tgt.setBaseType(src.getType());
120    if (src.hasDerivation())
121      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
122    if (src.hasSnapshot())
123      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
124    if (src.hasDifferential())
125      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
126    return tgt;
127  }
128
129  public static org.hl7.fhir.r5.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2016may.model.StructureDefinition src) throws FHIRException {
130    if (src == null || src.isEmpty())
131      return null;
132    org.hl7.fhir.r5.model.StructureDefinition tgt = new org.hl7.fhir.r5.model.StructureDefinition();
133    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
134    if (src.hasUrl())
135      tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
136    for (org.hl7.fhir.dstu2016may.model.Identifier t : src.getIdentifier())
137      tgt.addIdentifier(Identifier14_50.convertIdentifier(t));
138    if (src.hasVersion())
139      tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
140    if (src.hasNameElement())
141      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
142    if (src.hasDisplay())
143      tgt.setTitleElement(String14_50.convertString(src.getDisplayElement()));
144    if (src.hasStatus())
145      tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
146    if (src.hasExperimental())
147      tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
148    if (src.hasPublisher())
149      tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
150    for (org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact())
151      tgt.addContact(convertStructureDefinitionContactComponent(t));
152    if (src.hasDate())
153      tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
154    if (src.hasDescription())
155      tgt.setDescription(src.getDescription());
156    for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext())
157      if (CodeableConcept14_50.isJurisdiction(t))
158        tgt.addJurisdiction(CodeableConcept14_50.convertCodeableConcept(t));
159      else
160        tgt.addUseContext(CodeableConcept14_50.convertCodeableConceptToUsageContext(t));
161    if (src.hasRequirements())
162      tgt.setPurpose(src.getRequirements());
163    if (src.hasCopyright())
164      tgt.setCopyright(src.getCopyright());
165    for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addKeyword(Coding14_50.convertCoding(t));
166    if (src.hasFhirVersion())
167      tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
168    for (org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
169      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
170    if (src.hasKind())
171      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), src.getName()));
172    if (src.hasAbstractElement())
173      tgt.setAbstractElement(Boolean14_50.convertBoolean(src.getAbstractElement()));
174    for (org.hl7.fhir.dstu2016may.model.StringType t : src.getContext()) {
175      org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext();
176      ec.setTypeElement(convertExtensionContext(src.getContextTypeElement()));
177      ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue());
178    }
179    if (src.getDerivation() == org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.CONSTRAINT)
180      tgt.setType(src.getBaseType());
181    else
182      tgt.setType(src.getId());
183    if (src.hasBaseDefinition())
184      tgt.setBaseDefinition(src.getBaseDefinition());
185    if (src.hasDerivation())
186      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
187    if (src.hasSnapshot()) {
188      if (src.hasSnapshot())
189        tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
190      tgt.getSnapshot().getElementFirstRep().getType().clear();
191    }
192    if (src.hasDifferential()) {
193      if (src.hasDifferential())
194        tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
195      if (!tgt.getDifferential().getElementFirstRep().getPath().contains(".")) {
196        tgt.getDifferential().getElementFirstRep().getType().clear();
197      }
198    }
199    if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
200      for (ElementDefinition ed : tgt.getSnapshot().getElement()) {
201        if (!ed.hasBase()) {
202          ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
203        }
204      }
205    }
206    return tgt;
207  }
208
209  public static org.hl7.fhir.r5.model.ContactDetail convertStructureDefinitionContactComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent src) throws FHIRException {
210    if (src == null || src.isEmpty())
211      return null;
212    org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail();
213    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
214    if (src.hasName())
215      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
216    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom())
217      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
218    return tgt;
219  }
220
221  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent convertStructureDefinitionContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException {
222    if (src == null || src.isEmpty())
223      return null;
224    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionContactComponent();
225    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
226    if (src.hasName())
227      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
228    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
229      tgt.addTelecom(ContactPoint14_50.convertContactPoint(t));
230    return tgt;
231  }
232
233  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
234    if (src == null || src.isEmpty())
235      return null;
236    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent();
237    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
238    for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement())
239      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t));
240    return tgt;
241  }
242
243  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
244    if (src == null || src.isEmpty())
245      return null;
246    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent();
247    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
248    for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement())
249      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t, src.getElement(), src.getElement().indexOf(t)));
250    return tgt;
251  }
252
253  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException {
254    if (src == null || src.isEmpty())
255      return null;
256    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKindEnumFactory());
257    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
258    switch (src.getValue()) {
259      case PRIMITIVETYPE:
260        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
261        break;
262      case COMPLEXTYPE:
263        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.DATATYPE);
264        break;
265      case RESOURCE:
266        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
267        break;
268      case LOGICAL:
269        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
270        break;
271      default:
272        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind.NULL);
273        break;
274    }
275    return tgt;
276  }
277
278  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionKind> src, String name) throws FHIRException {
279    if (src == null || src.isEmpty())
280      return null;
281    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKindEnumFactory());
282    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
283    switch (src.getValue()) {
284      case DATATYPE:
285        if (name.substring(0, 1).toLowerCase().equals(name.substring(0, 1))) {
286          tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE);
287        } else {
288          tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
289        }
290        break;
291      case RESOURCE:
292        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
293        break;
294      case LOGICAL:
295        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
296        break;
297      default:
298        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.NULL);
299        break;
300    }
301    return tgt;
302  }
303
304  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
305    if (src == null || src.isEmpty())
306      return null;
307    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent();
308    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
309    if (src.hasIdentityElement())
310      tgt.setIdentityElement(Id14_50.convertId(src.getIdentityElement()));
311    if (src.hasUri())
312      tgt.setUriElement(Uri14_50.convertUri(src.getUriElement()));
313    if (src.hasName())
314      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
315    if (src.hasComments())
316      tgt.setCommentElement(String14_50.convertString(src.getCommentsElement()));
317    return tgt;
318  }
319
320  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
321    if (src == null || src.isEmpty())
322      return null;
323    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionMappingComponent();
324    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
325    if (src.hasIdentityElement())
326      tgt.setIdentityElement(Id14_50.convertId(src.getIdentityElement()));
327    if (src.hasUri())
328      tgt.setUriElement(Uri14_50.convertUri(src.getUriElement()));
329    if (src.hasName())
330      tgt.setNameElement(String14_50.convertString(src.getNameElement()));
331    if (src.hasComment())
332      tgt.setCommentsElement(String14_50.convertString(src.getCommentElement()));
333    return tgt;
334  }
335
336  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
337    if (src == null || src.isEmpty())
338      return null;
339    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent();
340    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
341    for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement())
342      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t, src.getElement(), src.getElement().indexOf(t)));
343    return tgt;
344  }
345
346  public static org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
347    if (src == null || src.isEmpty())
348      return null;
349    org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu2016may.model.StructureDefinition.StructureDefinitionSnapshotComponent();
350    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
351    for (org.hl7.fhir.r5.model.ElementDefinition t : src.getElement())
352      tgt.addElement(ElementDefinition14_50.convertElementDefinition(t));
353    return tgt;
354  }
355
356  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
357    if (src == null || src.isEmpty())
358      return null;
359    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRuleEnumFactory());
360    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
361    switch (src.getValue()) {
362      case SPECIALIZATION:
363        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
364        break;
365      case CONSTRAINT:
366        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.CONSTRAINT);
367        break;
368      default:
369        tgt.setValue(org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule.NULL);
370        break;
371    }
372    return tgt;
373  }
374
375  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
376    if (src == null || src.isEmpty())
377      return null;
378    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRuleEnumFactory());
379    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
380    switch (src.getValue()) {
381      case SPECIALIZATION:
382        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
383        break;
384      case CONSTRAINT:
385        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.CONSTRAINT);
386        break;
387      default:
388        tgt.setValue(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.NULL);
389        break;
390    }
391    return tgt;
392  }
393
394  static public boolean isResource140(String tn) {
395    return Utilities.existsInList(tn, "Account", "AllergyIntolerance", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodySite", "Bundle", "CarePlan", "CareTeam", "Claim", "ClaimResponse", "ClinicalImpression", "CodeSystem", "Communication", "CommunicationRequest", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Conformance", "Contract", "Coverage", "DataElement", "DecisionSupportRule", "DecisionSupportServiceModule", "DetectedIssue", "Device", "DeviceComponent", "DeviceMetric", "DeviceUseRequest", "DeviceUseStatement", "DiagnosticOrder", "DiagnosticReport", "DocumentManifest", "DocumentReference", "EligibilityRequest", "EligibilityResponse", "Encounter", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "ExpansionProfile", "ExplanationOfBenefit", "FamilyMemberHistory", "Flag", "Goal", "Group", "GuidanceResponse", "HealthcareService", "ImagingExcerpt", "ImagingObjectSelection", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "Library", "Linkage", "List", "Location", "Measure", "MeasureReport", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationOrder", "MedicationStatement", "MessageHeader", "ModuleDefinition", "NamingSystem", "NutritionOrder", "Observation", "OperationDefinition", "OperationOutcome", "Order", "OrderResponse", "OrderSet", "Organization", "Parameters", "Patient", "PaymentNotice", "PaymentReconciliation", "Person", "Practitioner", "PractitionerRole", "Procedure", "ProcedureRequest", "ProcessRequest", "ProcessResponse", "Protocol", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "Slot", "Sequence", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "Task", "TestScript", "ValueSet", "VisionPrescription");
396  }
397}