001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.ContactDetail30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.ElementDefinition30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Coding30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Timing30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.*;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.utilities.Utilities;
013
014public class StructureDefinition30_40 {
015
016  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> convertExtensionContext(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> src) throws FHIRException {
017    if (src == null || src.isEmpty())
018      return null;
019    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextTypeEnumFactory());
020    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
021    switch (src.getValue()) {
022      case RESOURCE:
023        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.ELEMENT);
024        break;
025      case DATATYPE:
026        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.ELEMENT);
027        break;
028      case EXTENSION:
029        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.EXTENSION);
030        break;
031      default:
032        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType.NULL);
033        break;
034    }
035    return tgt;
036  }
037
038  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> convertExtensionContext(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.ExtensionContextType> src, String expression) throws FHIRException {
039    if (src == null || src.isEmpty())
040      return null;
041    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContextEnumFactory());
042    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
043    switch (src.getValue()) {
044      case FHIRPATH:
045        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.RESOURCE);
046        break;
047      case ELEMENT:
048        String tn = expression.contains(".") ? expression.substring(0, expression.indexOf(".")) : expression;
049        if (isResource300(tn)) {
050          tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.RESOURCE);
051        } else {
052          tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.DATATYPE);
053        }
054        break;
055      case EXTENSION:
056        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.EXTENSION);
057        break;
058      default:
059        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.ExtensionContext.NULL);
060        break;
061    }
062    return tgt;
063  }
064
065  public static org.hl7.fhir.dstu3.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.r4.model.StructureDefinition src) throws FHIRException {
066    if (src == null)
067      return null;
068    org.hl7.fhir.dstu3.model.StructureDefinition tgt = new org.hl7.fhir.dstu3.model.StructureDefinition();
069    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
070    if (src.hasUrl())
071      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
072    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
073      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
074    if (src.hasVersion())
075      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
076    if (src.hasName())
077      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
078    if (src.hasTitle())
079      tgt.setTitleElement(String30_40.convertString(src.getTitleElement()));
080    if (src.hasStatus())
081      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
082    if (src.hasExperimental())
083      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
084    if (src.hasDateElement())
085      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
086    if (src.hasPublisher())
087      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
088    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
089      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
090    if (src.hasDescription())
091      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
092    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
093      tgt.addUseContext(Timing30_40.convertUsageContext(t));
094    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
095      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
096    if (src.hasPurpose())
097      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
098    if (src.hasCopyright())
099      tgt.setCopyrightElement(MarkDown30_40.convertMarkdown(src.getCopyrightElement()));
100    for (org.hl7.fhir.r4.model.Coding t : src.getKeyword()) tgt.addKeyword(Coding30_40.convertCoding(t));
101    if (src.hasFhirVersion())
102      tgt.setFhirVersion(src.getFhirVersion().toCode());
103    for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
104      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
105    if (src.hasKind())
106      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement()));
107    if (src.hasAbstract())
108      tgt.setAbstractElement(Boolean30_40.convertBoolean(src.getAbstractElement()));
109    for (org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent t : src.getContext()) {
110      if (!tgt.hasContextType())
111        tgt.setContextTypeElement(convertExtensionContext(t.getTypeElement(), t.getExpression()));
112      tgt.addContext("Element".equals(t.getExpression()) ? "*" : t.getExpression());
113    }
114    for (org.hl7.fhir.r4.model.StringType t : src.getContextInvariant()) tgt.addContextInvariant(t.getValue());
115    if (src.hasType())
116      tgt.setType(src.getType());
117    if (src.hasBaseDefinition())
118      tgt.setBaseDefinition(src.getBaseDefinition());
119    if (src.hasDerivation())
120      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
121    if (src.hasSnapshot())
122      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
123    if (src.hasDifferential())
124      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
125    return tgt;
126  }
127
128  public static org.hl7.fhir.r4.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition src) throws FHIRException {
129    if (src == null)
130      return null;
131    org.hl7.fhir.r4.model.StructureDefinition tgt = new org.hl7.fhir.r4.model.StructureDefinition();
132    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
133    if (src.hasUrl())
134      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
135    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
136      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
137    if (src.hasVersion())
138      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
139    if (src.hasName())
140      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
141    if (src.hasTitle())
142      tgt.setTitleElement(String30_40.convertString(src.getTitleElement()));
143    if (src.hasStatus())
144      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
145    if (src.hasExperimental())
146      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
147    if (src.hasDateElement())
148      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
149    if (src.hasPublisher())
150      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
151    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
152      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
153    if (src.hasDescription())
154      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
155    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
156      tgt.addUseContext(Timing30_40.convertUsageContext(t));
157    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
158      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
159    if (src.hasPurpose())
160      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
161    if (src.hasCopyright())
162      tgt.setCopyrightElement(MarkDown30_40.convertMarkdown(src.getCopyrightElement()));
163    for (org.hl7.fhir.dstu3.model.Coding t : src.getKeyword()) tgt.addKeyword(Coding30_40.convertCoding(t));
164    if (src.hasFhirVersion())
165      tgt.setFhirVersion(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
166    for (org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())
167      tgt.addMapping(convertStructureDefinitionMappingComponent(t));
168    if (src.hasKind())
169      tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement()));
170    if (src.hasAbstract())
171      tgt.setAbstractElement(Boolean30_40.convertBoolean(src.getAbstractElement()));
172    for (org.hl7.fhir.dstu3.model.StringType t : src.getContext()) {
173      org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext();
174      ec.setTypeElement(convertExtensionContext(src.getContextTypeElement()));
175      ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue());
176    }
177    for (org.hl7.fhir.dstu3.model.StringType t : src.getContextInvariant()) tgt.addContextInvariant(t.getValue());
178    if (src.hasType())
179      tgt.setType(src.getType());
180    if (src.hasBaseDefinition())
181      tgt.setBaseDefinition(src.getBaseDefinition());
182    if (src.hasDerivation())
183      tgt.setDerivationElement(convertTypeDerivationRule(src.getDerivationElement()));
184    if (src.hasSnapshot())
185      tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
186    if (src.hasDifferential())
187      tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
188    if (tgt.getDerivation() == org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION) {
189      for (org.hl7.fhir.r4.model.ElementDefinition ed : tgt.getSnapshot().getElement()) {
190        if (!ed.hasBase()) {
191          ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
192        }
193      }
194    }
195    return tgt;
196  }
197
198  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
199    if (src == null)
200      return null;
201    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent();
202    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
203    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
204      tgt.addElement(ElementDefinition30_40.convertElementDefinition(t));
205    return tgt;
206  }
207
208  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent convertStructureDefinitionDifferentialComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionDifferentialComponent src) throws FHIRException {
209    if (src == null)
210      return null;
211    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionDifferentialComponent();
212    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
213    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
214      tgt.addElement(ElementDefinition30_40.convertElementDefinition(t));
215    return tgt;
216  }
217
218  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException {
219    if (src == null || src.isEmpty())
220      return null;
221    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKindEnumFactory());
222    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
223    switch (src.getValue()) {
224      case PRIMITIVETYPE:
225        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE);
226        break;
227      case COMPLEXTYPE:
228        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
229        break;
230      case RESOURCE:
231        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
232        break;
233      case LOGICAL:
234        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
235        break;
236      default:
237        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind.NULL);
238        break;
239    }
240    return tgt;
241  }
242
243  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> convertStructureDefinitionKind(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind> src) throws FHIRException {
244    if (src == null || src.isEmpty())
245      return null;
246    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKindEnumFactory());
247    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
248    switch (src.getValue()) {
249      case PRIMITIVETYPE:
250        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE);
251        break;
252      case COMPLEXTYPE:
253        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
254        break;
255      case RESOURCE:
256        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.RESOURCE);
257        break;
258      case LOGICAL:
259        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.LOGICAL);
260        break;
261      default:
262        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind.NULL);
263        break;
264    }
265    return tgt;
266  }
267
268  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
269    if (src == null)
270      return null;
271    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent();
272    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
273    if (src.hasIdentity())
274      tgt.setIdentityElement(Id30_40.convertId(src.getIdentityElement()));
275    if (src.hasUri())
276      tgt.setUriElement(Uri30_40.convertUri(src.getUriElement()));
277    if (src.hasName())
278      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
279    if (src.hasComment())
280      tgt.setCommentElement(String30_40.convertString(src.getCommentElement()));
281    return tgt;
282  }
283
284  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent convertStructureDefinitionMappingComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent src) throws FHIRException {
285    if (src == null)
286      return null;
287    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent();
288    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
289    if (src.hasIdentity())
290      tgt.setIdentityElement(Id30_40.convertId(src.getIdentityElement()));
291    if (src.hasUri())
292      tgt.setUriElement(Uri30_40.convertUri(src.getUriElement()));
293    if (src.hasName())
294      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
295    if (src.hasComment())
296      tgt.setCommentElement(String30_40.convertString(src.getCommentElement()));
297    return tgt;
298  }
299
300  public static org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
301    if (src == null)
302      return null;
303    org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent();
304    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
305    for (org.hl7.fhir.r4.model.ElementDefinition t : src.getElement())
306      tgt.addElement(ElementDefinition30_40.convertElementDefinition(t));
307    return tgt;
308  }
309
310  public static org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent convertStructureDefinitionSnapshotComponent(org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionSnapshotComponent src) throws FHIRException {
311    if (src == null)
312      return null;
313    org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent tgt = new org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionSnapshotComponent();
314    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
315    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
316      tgt.addElement(ElementDefinition30_40.convertElementDefinition(t));
317    return tgt;
318  }
319
320  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
321    if (src == null || src.isEmpty())
322      return null;
323    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRuleEnumFactory());
324    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
325    switch (src.getValue()) {
326      case SPECIALIZATION:
327        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
328        break;
329      case CONSTRAINT:
330        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.CONSTRAINT);
331        break;
332      default:
333        tgt.setValue(org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule.NULL);
334        break;
335    }
336    return tgt;
337  }
338
339  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule> convertTypeDerivationRule(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.StructureDefinition.TypeDerivationRule> src) throws FHIRException {
340    if (src == null || src.isEmpty())
341      return null;
342    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRuleEnumFactory());
343    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
344    switch (src.getValue()) {
345      case SPECIALIZATION:
346        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
347        break;
348      case CONSTRAINT:
349        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.CONSTRAINT);
350        break;
351      default:
352        tgt.setValue(org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule.NULL);
353        break;
354    }
355    return tgt;
356  }
357
358  static public boolean isResource300(String tn) {
359    return Utilities.existsInList(tn, "Account", "ActivityDefinition", "AllergyIntolerance", "AdverseEvent", "Appointment", "AppointmentResponse", "AuditEvent", "Basic", "Binary", "BodySite", "Bundle", "CapabilityStatement", "CarePlan", "CareTeam", "ChargeItem", "Claim", "ClaimResponse", "ClinicalImpression", "CodeSystem", "Communication", "CommunicationRequest", "CompartmentDefinition", "Composition", "ConceptMap", "Condition", "Consent", "Contract", "Coverage", "DataElement", "DetectedIssue", "Device", "DeviceComponent", "DeviceMetric", "DeviceRequest", "DeviceUseStatement", "DiagnosticReport", "DocumentManifest", "DocumentReference", "EligibilityRequest", "EligibilityResponse", "Encounter", "Endpoint", "EnrollmentRequest", "EnrollmentResponse", "EpisodeOfCare", "ExpansionProfile", "ExplanationOfBenefit", "FamilyMemberHistory", "Flag", "Goal", "GraphDefinition", "Group", "GuidanceResponse", "HealthcareService", "ImagingManifest", "ImagingStudy", "Immunization", "ImmunizationRecommendation", "ImplementationGuide", "Library", "Linkage", "List", "Location", "Measure", "MeasureReport", "Media", "Medication", "MedicationAdministration", "MedicationDispense", "MedicationRequest", "MedicationStatement", "MessageDefinition", "MessageHeader", "NamingSystem", "NutritionOrder", "Observation", "OperationDefinition", "OperationOutcome", "Organization", "Parameters", "Patient", "PaymentNotice", "PaymentReconciliation", "Person", "PlanDefinition", "Practitioner", "PractitionerRole", "Procedure", "ProcedureRequest", "ProcessRequest", "ProcessResponse", "Provenance", "Questionnaire", "QuestionnaireResponse", "ReferralRequest", "RelatedPerson", "RequestGroup", "ResearchStudy", "ResearchSubject", "RiskAssessment", "Schedule", "SearchParameter", "Sequence", "ServiceDefinition", "Slot", "Specimen", "StructureDefinition", "StructureMap", "Subscription", "Substance", "SupplyDelivery", "SupplyRequest", "Task", "TestScript", "TestReport", "ValueSet", "VisionPrescription");
360  }
361}