001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import java.util.stream.Collectors;
004
005import org.hl7.fhir.convertors.context.ConversionContext30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class AllergyIntolerance30_40 {
015
016  public static org.hl7.fhir.dstu3.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance src) throws FHIRException {
017    if (src == null)
018      return null;
019    org.hl7.fhir.dstu3.model.AllergyIntolerance tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance();
020    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
021    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
023    if (src.hasClinicalStatus())
024      tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus()));
025    if (src.hasVerificationStatus())
026      tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus()));
027    if (src.hasType())
028      tgt.setTypeElement(convertAllergyIntoleranceType(src.getTypeElement()));
029    tgt.setCategory(src.getCategory().stream()
030      .map(AllergyIntolerance30_40::convertAllergyIntoleranceCategory)
031      .collect(Collectors.toList()));
032    if (src.hasCriticality())
033      tgt.setCriticalityElement(convertAllergyIntoleranceCriticality(src.getCriticalityElement()));
034    if (src.hasCode())
035      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
036    if (src.hasPatient())
037      tgt.setPatient(Reference30_40.convertReference(src.getPatient()));
038    if (src.hasOnset())
039      tgt.setOnset(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOnset()));
040    if (src.hasRecordedDate())
041      tgt.setAssertedDateElement(DateTime30_40.convertDateTime(src.getRecordedDateElement()));
042    if (src.hasRecorder())
043      tgt.setRecorder(Reference30_40.convertReference(src.getRecorder()));
044    if (src.hasAsserter())
045      tgt.setAsserter(Reference30_40.convertReference(src.getAsserter()));
046    if (src.hasLastOccurrence())
047      tgt.setLastOccurrenceElement(DateTime30_40.convertDateTime(src.getLastOccurrenceElement()));
048    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
049    for (org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction())
050      tgt.addReaction(convertAllergyIntoleranceReactionComponent(t));
051    return tgt;
052  }
053
054  public static org.hl7.fhir.r4.model.AllergyIntolerance convertAllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance src) throws FHIRException {
055    if (src == null)
056      return null;
057    org.hl7.fhir.r4.model.AllergyIntolerance tgt = new org.hl7.fhir.r4.model.AllergyIntolerance();
058    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
059    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
060      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
061    if (src.hasClinicalStatus())
062      tgt.setClinicalStatus(convertAllergyIntoleranceClinicalStatus(src.getClinicalStatus()));
063    if (src.hasVerificationStatus())
064      tgt.setVerificationStatus(convertAllergyIntoleranceVerificationStatus(src.getVerificationStatus()));
065    if (src.hasType())
066      tgt.setTypeElement(convertAllergyIntoleranceType(src.getTypeElement()));
067    tgt.setCategory(src.getCategory().stream()
068      .map(AllergyIntolerance30_40::convertAllergyIntoleranceCategory)
069      .collect(Collectors.toList()));
070    if (src.hasCriticality())
071      tgt.setCriticalityElement(convertAllergyIntoleranceCriticality(src.getCriticalityElement()));
072    if (src.hasCode())
073      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
074    if (src.hasPatient())
075      tgt.setPatient(Reference30_40.convertReference(src.getPatient()));
076    if (src.hasOnset())
077      tgt.setOnset(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getOnset()));
078    if (src.hasAssertedDate())
079      tgt.setRecordedDateElement(DateTime30_40.convertDateTime(src.getAssertedDateElement()));
080    if (src.hasRecorder())
081      tgt.setRecorder(Reference30_40.convertReference(src.getRecorder()));
082    if (src.hasAsserter())
083      tgt.setAsserter(Reference30_40.convertReference(src.getAsserter()));
084    if (src.hasLastOccurrence())
085      tgt.setLastOccurrenceElement(DateTime30_40.convertDateTime(src.getLastOccurrenceElement()));
086    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
087    for (org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent t : src.getReaction())
088      tgt.addReaction(convertAllergyIntoleranceReactionComponent(t));
089    return tgt;
090  }
091
092  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory> convertAllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> src) throws FHIRException {
093    if (src == null || src.isEmpty())
094      return null;
095    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
096    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
097    switch (src.getValue()) {
098      case FOOD:
099        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.FOOD);
100        break;
101      case MEDICATION:
102        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION);
103        break;
104      case ENVIRONMENT:
105        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
106        break;
107      case BIOLOGIC:
108        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC);
109        break;
110      default:
111        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory.NULL);
112        break;
113    }
114    return tgt;
115  }
116
117  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> convertAllergyIntoleranceCategory(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory> src) throws FHIRException {
118    if (src == null || src.isEmpty())
119      return null;
120    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategoryEnumFactory());
121    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
122    switch (src.getValue()) {
123      case FOOD:
124        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.FOOD);
125        break;
126      case MEDICATION:
127        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.MEDICATION);
128        break;
129      case ENVIRONMENT:
130        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.ENVIRONMENT);
131        break;
132      case BIOLOGIC:
133        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.BIOLOGIC);
134        break;
135      default:
136        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory.NULL);
137        break;
138    }
139    return tgt;
140  }
141
142  static public org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
143    if (src == null)
144      return null;
145    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "active"))
146      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE;
147    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "inactive"))
148      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.INACTIVE;
149    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical", "resolved"))
150      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.RESOLVED;
151    return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus.NULL;
152  }
153
154  static public org.hl7.fhir.r4.model.CodeableConcept convertAllergyIntoleranceClinicalStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus src) throws FHIRException {
155    if (src == null)
156      return null;
157    switch (src) {
158      case ACTIVE:
159        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("active"));
160      case INACTIVE:
161        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("inactive"));
162      case RESOLVED:
163        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical").setCode("resolved"));
164      default:
165        return null;
166    }
167  }
168
169  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality> convertAllergyIntoleranceCriticality(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> src) throws FHIRException {
170    if (src == null || src.isEmpty())
171      return null;
172    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticalityEnumFactory());
173    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
174    switch (src.getValue()) {
175      case LOW:
176        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW);
177        break;
178      case HIGH:
179        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH);
180        break;
181      case UNABLETOASSESS:
182        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS);
183        break;
184      default:
185        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL);
186        break;
187    }
188    return tgt;
189  }
190
191  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> convertAllergyIntoleranceCriticality(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality> src) throws FHIRException {
192    if (src == null || src.isEmpty())
193      return null;
194    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticalityEnumFactory());
195    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
196    switch (src.getValue()) {
197      case LOW:
198        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.LOW);
199        break;
200      case HIGH:
201        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.HIGH);
202        break;
203      case UNABLETOASSESS:
204        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.UNABLETOASSESS);
205        break;
206      default:
207        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality.NULL);
208        break;
209    }
210    return tgt;
211  }
212
213  public static org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException {
214    if (src == null)
215      return null;
216    org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent();
217    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
218    if (src.hasSubstance())
219      tgt.setSubstance(CodeableConcept30_40.convertCodeableConcept(src.getSubstance()));
220    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getManifestation())
221      tgt.addManifestation(CodeableConcept30_40.convertCodeableConcept(t));
222    if (src.hasDescription())
223      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
224    if (src.hasOnset())
225      tgt.setOnsetElement(DateTime30_40.convertDateTime(src.getOnsetElement()));
226    if (src.hasSeverity())
227      tgt.setSeverityElement(convertAllergyIntoleranceSeverity(src.getSeverityElement()));
228    if (src.hasExposureRoute())
229      tgt.setExposureRoute(CodeableConcept30_40.convertCodeableConcept(src.getExposureRoute()));
230    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
231    return tgt;
232  }
233
234  public static org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent convertAllergyIntoleranceReactionComponent(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceReactionComponent src) throws FHIRException {
235    if (src == null)
236      return null;
237    org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent tgt = new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent();
238    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
239    if (src.hasSubstance())
240      tgt.setSubstance(CodeableConcept30_40.convertCodeableConcept(src.getSubstance()));
241    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getManifestation())
242      tgt.addManifestation(CodeableConcept30_40.convertCodeableConcept(t));
243    if (src.hasDescription())
244      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
245    if (src.hasOnset())
246      tgt.setOnsetElement(DateTime30_40.convertDateTime(src.getOnsetElement()));
247    if (src.hasSeverity())
248      tgt.setSeverityElement(convertAllergyIntoleranceSeverity(src.getSeverityElement()));
249    if (src.hasExposureRoute())
250      tgt.setExposureRoute(CodeableConcept30_40.convertCodeableConcept(src.getExposureRoute()));
251    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
252    return tgt;
253  }
254
255  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> convertAllergyIntoleranceSeverity(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity> src) throws FHIRException {
256    if (src == null || src.isEmpty())
257      return null;
258    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverityEnumFactory());
259    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
260    switch (src.getValue()) {
261      case MILD:
262        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MILD);
263        break;
264      case MODERATE:
265        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE);
266        break;
267      case SEVERE:
268        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE);
269        break;
270      default:
271        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity.NULL);
272        break;
273    }
274    return tgt;
275  }
276
277  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity> convertAllergyIntoleranceSeverity(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceSeverity> src) throws FHIRException {
278    if (src == null || src.isEmpty())
279      return null;
280    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverityEnumFactory());
281    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
282    switch (src.getValue()) {
283      case MILD:
284        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.MILD);
285        break;
286      case MODERATE:
287        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.MODERATE);
288        break;
289      case SEVERE:
290        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.SEVERE);
291        break;
292      default:
293        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceSeverity.NULL);
294        break;
295    }
296    return tgt;
297  }
298
299  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> convertAllergyIntoleranceType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType> src) throws FHIRException {
300    if (src == null || src.isEmpty())
301      return null;
302    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceTypeEnumFactory());
303    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
304    switch (src.getValue()) {
305      case ALLERGY:
306        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.ALLERGY);
307        break;
308      case INTOLERANCE:
309        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.INTOLERANCE);
310        break;
311      default:
312        tgt.setValue(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType.NULL);
313        break;
314    }
315    return tgt;
316  }
317
318  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType> convertAllergyIntoleranceType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType> src) throws FHIRException {
319    if (src == null || src.isEmpty())
320      return null;
321    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceTypeEnumFactory());
322    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
323    switch (src.getValue()) {
324      case ALLERGY:
325        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.ALLERGY);
326        break;
327      case INTOLERANCE:
328        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.INTOLERANCE);
329        break;
330      default:
331        tgt.setValue(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType.NULL);
332        break;
333    }
334    return tgt;
335  }
336
337  static public org.hl7.fhir.r4.model.CodeableConcept convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus src) throws FHIRException {
338    if (src == null)
339      return null;
340    switch (src) {
341      case UNCONFIRMED:
342        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("unconfirmed"));
343      case CONFIRMED:
344        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("confirmed"));
345      case REFUTED:
346        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("refuted"));
347      case ENTEREDINERROR:
348        return new org.hl7.fhir.r4.model.CodeableConcept(new org.hl7.fhir.r4.model.Coding().setSystem("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification").setCode("entered-in-error"));
349      default:
350        return null;
351    }
352  }
353
354  static public org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus convertAllergyIntoleranceVerificationStatus(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
355    if (src == null)
356      return null;
357    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "unconfirmed"))
358      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.UNCONFIRMED;
359    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "confirmed"))
360      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.CONFIRMED;
361    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "refuted"))
362      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.REFUTED;
363    if (src.hasCoding("http://terminology.hl7.org/CodeSystem/allergyintolerance-verification", "entered-in-error"))
364      return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.ENTEREDINERROR;
365    return org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus.NULL;
366  }
367}