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