001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.VersionConvertorConstants;
004import org.hl7.fhir.convertors.context.ConversionContext40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Period40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*;
012import org.hl7.fhir.exceptions.FHIRException;
013import org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType;
014import org.hl7.fhir.r5.model.CodeType;
015import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireAnswerConstraint;
016
017/*
018  Copyright (c) 2011+, HL7, Inc.
019  All rights reserved.
020  
021  Redistribution and use in source and binary forms, with or without modification, 
022  are permitted provided that the following conditions are met:
023  
024   * Redistributions of source code must retain the above copyright notice, this 
025     list of conditions and the following disclaimer.
026   * Redistributions in binary form must reproduce the above copyright notice, 
027     this list of conditions and the following disclaimer in the documentation 
028     and/or other materials provided with the distribution.
029   * Neither the name of HL7 nor the names of its contributors may be used to 
030     endorse or promote products derived from this software without specific 
031     prior written permission.
032  
033  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
034  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
035  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
036  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
037  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
038  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
039  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
040  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
041  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
042  POSSIBILITY OF SUCH DAMAGE.
043  
044*/
045// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
046public class Questionnaire40_50 {
047
048  public static org.hl7.fhir.r5.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException {
049    if (src == null)
050      return null;
051    org.hl7.fhir.r5.model.Questionnaire tgt = new org.hl7.fhir.r5.model.Questionnaire();
052    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
053    if (src.hasUrl())
054      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
055    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
056      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
057    if (src.hasVersion())
058      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
059    if (src.hasName())
060      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
061    if (src.hasTitle())
062      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
063    for (org.hl7.fhir.r4.model.CanonicalType t : src.getDerivedFrom())
064      tgt.getDerivedFrom().add(Canonical40_50.convertCanonical(t));
065    if (src.hasStatus())
066      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
067    if (src.hasExperimental())
068      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
069    for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType())
070      tgt.getSubjectType().add(Code40_50.convertResourceEnum(t));
071    if (src.hasDate())
072      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
073    if (src.hasPublisher())
074      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
075    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
076      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
077    if (src.hasDescription())
078      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
079    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
080      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
081    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
082      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
083    if (src.hasPurpose())
084      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
085    if (src.hasCopyright())
086      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
087    if (src.hasApprovalDate())
088      tgt.setApprovalDateElement(Date40_50.convertDate(src.getApprovalDateElement()));
089    if (src.hasLastReviewDate())
090      tgt.setLastReviewDateElement(Date40_50.convertDate(src.getLastReviewDateElement()));
091    if (src.hasEffectivePeriod())
092      tgt.setEffectivePeriod(Period40_50.convertPeriod(src.getEffectivePeriod()));
093    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
094    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
095      tgt.addItem(convertQuestionnaireItemComponent(t));
096    return tgt;
097  }
098
099  public static org.hl7.fhir.r4.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r5.model.Questionnaire src) throws FHIRException {
100    if (src == null)
101      return null;
102    org.hl7.fhir.r4.model.Questionnaire tgt = new org.hl7.fhir.r4.model.Questionnaire();
103    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
104    if (src.hasUrl())
105      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
106    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
107      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
108    if (src.hasVersion())
109      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
110    if (src.hasName())
111      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
112    if (src.hasTitle())
113      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
114    for (org.hl7.fhir.r5.model.CanonicalType t : src.getDerivedFrom())
115      tgt.getDerivedFrom().add(Canonical40_50.convertCanonical(t));
116    if (src.hasStatus())
117      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
118    if (src.hasExperimental())
119      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
120    for (CodeType t : src.getSubjectType()) tgt.getSubjectType().add(Code40_50.convertResourceEnum(t));
121    if (src.hasDate())
122      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
123    if (src.hasPublisher())
124      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
125    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
126      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
127    if (src.hasDescription())
128      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
129    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
130      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
131    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
132      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
133    if (src.hasPurpose())
134      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
135    if (src.hasCopyright())
136      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
137    if (src.hasApprovalDate())
138      tgt.setApprovalDateElement(Date40_50.convertDate(src.getApprovalDateElement()));
139    if (src.hasLastReviewDate())
140      tgt.setLastReviewDateElement(Date40_50.convertDate(src.getLastReviewDateElement()));
141    if (src.hasEffectivePeriod())
142      tgt.setEffectivePeriod(Period40_50.convertPeriod(src.getEffectivePeriod()));
143    for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
144    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
145      tgt.addItem(convertQuestionnaireItemComponent(t));
146    return tgt;
147  }
148
149  public static org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireItemComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
150    if (src == null)
151      return null;
152    org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent();
153    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
154    if (src.hasLinkId())
155      tgt.setLinkIdElement(String40_50.convertString(src.getLinkIdElement()));
156    if (src.hasDefinition())
157      tgt.setDefinitionElement(Uri40_50.convertUri(src.getDefinitionElement()));
158    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
159    if (src.hasPrefix())
160      tgt.setPrefixElement(String40_50.convertString(src.getPrefixElement()));
161    if (src.hasText())
162      tgt.setTextElement(MarkDown40_50.convertStringToMarkdown(src.getTextElement()));
163    if (src.hasType()) {
164      tgt.setTypeElement(convertQuestionnaireItemType(src.getTypeElement()));
165      if (src.getType() == QuestionnaireItemType.CHOICE) {
166        tgt.setAnswerConstraint(QuestionnaireAnswerConstraint.OPTIONSONLY);
167      } else if (src.getType() == QuestionnaireItemType.OPENCHOICE) {
168        tgt.setAnswerConstraint(QuestionnaireAnswerConstraint.OPTIONSORSTRING);
169      }
170    }
171    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen())
172      tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t));
173    if (src.hasEnableBehavior())
174      tgt.setEnableBehaviorElement(convertEnableWhenBehavior(src.getEnableBehaviorElement()));
175    if (src.hasRequired())
176      tgt.setRequiredElement(Boolean40_50.convertBoolean(src.getRequiredElement()));
177    if (src.hasRepeats())
178      tgt.setRepeatsElement(Boolean40_50.convertBoolean(src.getRepeatsElement()));
179    if (src.hasReadOnly())
180      tgt.setReadOnlyElement(Boolean40_50.convertBoolean(src.getReadOnlyElement()));
181    if (src.hasMaxLength())
182      tgt.setMaxLengthElement(Integer40_50.convertInteger(src.getMaxLengthElement()));
183    if (src.hasAnswerValueSet())
184      tgt.setAnswerValueSetElement(Canonical40_50.convertCanonical(src.getAnswerValueSetElement()));
185    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption())
186      tgt.addAnswerOption(convertQuestionnaireItemAnswerOptionComponent(t));
187    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemInitialComponent t : src.getInitial())
188      tgt.addInitial(convertQuestionnaireItemInitialComponent(t));
189    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
190      tgt.addItem(convertQuestionnaireItemComponent(t));
191    return tgt;
192  }
193
194  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent convertQuestionnaireItemComponent(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent src) throws FHIRException {
195    if (src == null)
196      return null;
197    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent();
198    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
199    if (src.hasLinkId())
200      tgt.setLinkIdElement(String40_50.convertString(src.getLinkIdElement()));
201    if (src.hasDefinition())
202      tgt.setDefinitionElement(Uri40_50.convertUri(src.getDefinitionElement()));
203    for (org.hl7.fhir.r5.model.Coding t : src.getCode()) tgt.addCode(Coding40_50.convertCoding(t));
204    if (src.hasPrefix())
205      tgt.setPrefixElement(String40_50.convertString(src.getPrefixElement()));
206    if (src.hasText())
207      tgt.setTextElement(String40_50.convertString(src.getTextElement()));
208    if (src.hasType())
209      tgt.setTypeElement(convertQuestionnaireItemType(src.getTypeElement(), src.getAnswerConstraint()));
210    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen())
211      tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t));
212    if (src.hasEnableBehavior())
213      tgt.setEnableBehaviorElement(convertEnableWhenBehavior(src.getEnableBehaviorElement()));
214    if (src.hasRequired())
215      tgt.setRequiredElement(Boolean40_50.convertBoolean(src.getRequiredElement()));
216    if (src.hasRepeats())
217      tgt.setRepeatsElement(Boolean40_50.convertBoolean(src.getRepeatsElement()));
218    if (src.hasReadOnly())
219      tgt.setReadOnlyElement(Boolean40_50.convertBoolean(src.getReadOnlyElement()));
220    if (src.hasMaxLength())
221      tgt.setMaxLengthElement(Integer40_50.convertInteger(src.getMaxLengthElement()));
222    if (src.hasAnswerValueSet())
223      tgt.setAnswerValueSetElement(Canonical40_50.convertCanonical(src.getAnswerValueSetElement()));
224    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent t : src.getAnswerOption())
225      tgt.addAnswerOption(convertQuestionnaireItemAnswerOptionComponent(t));
226    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent t : src.getInitial())
227      tgt.addInitial(convertQuestionnaireItemInitialComponent(t));
228    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent t : src.getItem())
229      tgt.addItem(convertQuestionnaireItemComponent(t));
230    return tgt;
231  }
232
233  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireItemType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> src) throws FHIRException {
234    if (src == null || src.isEmpty())
235      return null;
236    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
237    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
238    tgt.addExtension(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL, new CodeType(src.getValueAsString()));
239    switch (src.getValue()) {
240      case GROUP:
241        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.GROUP);
242        break;
243      case DISPLAY:
244        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DISPLAY);
245        break;
246      case QUESTION:
247        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.GROUP);
248        break;
249      case BOOLEAN:
250        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
251        break;
252      case DECIMAL:
253        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DECIMAL);
254        break;
255      case INTEGER:
256        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.INTEGER);
257        break;
258      case DATE:
259        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATE);
260        break;
261      case DATETIME:
262        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
263        break;
264      case TIME:
265        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TIME);
266        break;
267      case STRING:
268        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.STRING);
269        break;
270      case TEXT:
271        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TEXT);
272        break;
273      case URL:
274        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.URL);
275        break;
276      case CHOICE:
277        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
278        break;
279      case OPENCHOICE:
280        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
281        break;
282      case ATTACHMENT:
283        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
284        break;
285      case REFERENCE:
286        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.REFERENCE);
287        break;
288      case QUANTITY:
289        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.QUANTITY);
290        break;
291      default:
292        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.NULL);
293        break;
294    }
295    return tgt;
296  }
297
298  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireItemType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> src, QuestionnaireAnswerConstraint constraint) throws FHIRException {
299    if (src == null || src.isEmpty())
300      return null;
301    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
302    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL);
303    if (src.hasExtension(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL)) {
304      tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL));
305    } else {
306      switch (src.getValue()) {
307        case GROUP:
308          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.GROUP);
309          break;
310        case DISPLAY:
311          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DISPLAY);
312          break;
313        // case QUESTION: return org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUESTION;
314        case BOOLEAN:
315          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
316          break;
317        case DECIMAL:
318          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DECIMAL);
319          break;
320        case INTEGER:
321          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.INTEGER);
322          break;
323        case DATE:
324          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATE);
325          break;
326        case DATETIME:
327          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.DATETIME);
328          break;
329        case TIME:
330          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TIME);
331          break;
332        case STRING:
333          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.STRING);
334          break;
335        case TEXT:
336          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.TEXT);
337          break;
338        case URL:
339          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.URL);
340          break;
341        case CODING:
342          if (constraint == QuestionnaireAnswerConstraint.OPTIONSORSTRING)
343            tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.OPENCHOICE);
344          else
345            tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.CHOICE);
346          break;
347        case ATTACHMENT:
348          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
349          break;
350        case REFERENCE:
351          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.REFERENCE);
352          break;
353        case QUANTITY:
354          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.QUANTITY);
355          break;
356        default:
357          tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemType.NULL);
358          break;
359      }
360    }
361    return tgt;
362  }
363
364  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior> convertEnableWhenBehavior(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior> src) throws FHIRException {
365    if (src == null || src.isEmpty())
366      return null;
367    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehaviorEnumFactory());
368    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
369    switch (src.getValue()) {
370      case ALL:
371        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior.ALL);
372        break;
373      case ANY:
374        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior.ANY);
375        break;
376      default:
377        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior.NULL);
378        break;
379    }
380    return tgt;
381  }
382
383  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior> convertEnableWhenBehavior(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.EnableWhenBehavior> src) throws FHIRException {
384    if (src == null || src.isEmpty())
385      return null;
386    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehaviorEnumFactory());
387    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
388    switch (src.getValue()) {
389      case ALL:
390        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior.ALL);
391        break;
392      case ANY:
393        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior.ANY);
394        break;
395      default:
396        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior.NULL);
397        break;
398    }
399    return tgt;
400  }
401
402  public static org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent convertQuestionnaireItemEnableWhenComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent src) throws FHIRException {
403    if (src == null)
404      return null;
405    org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent tgt = new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent();
406    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
407    if (src.hasQuestion())
408      tgt.setQuestionElement(String40_50.convertString(src.getQuestionElement()));
409    if (src.hasOperator())
410      tgt.setOperatorElement(convertQuestionnaireItemOperator(src.getOperatorElement()));
411    if (src.hasAnswer())
412      tgt.setAnswer(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAnswer()));
413    return tgt;
414  }
415
416  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent convertQuestionnaireItemEnableWhenComponent(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemEnableWhenComponent src) throws FHIRException {
417    if (src == null)
418      return null;
419    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent();
420    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
421    if (src.hasQuestion())
422      tgt.setQuestionElement(String40_50.convertString(src.getQuestionElement()));
423    if (src.hasOperator())
424      tgt.setOperatorElement(convertQuestionnaireItemOperator(src.getOperatorElement()));
425    if (src.hasAnswer())
426      tgt.setAnswer(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAnswer()));
427    return tgt;
428  }
429
430  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator> convertQuestionnaireItemOperator(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator> src) throws FHIRException {
431    if (src == null || src.isEmpty())
432      return null;
433    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperatorEnumFactory());
434    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
435    switch (src.getValue()) {
436      case EXISTS:
437        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.EXISTS);
438        break;
439      case EQUAL:
440        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.EQUAL);
441        break;
442      case NOT_EQUAL:
443        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.NOT_EQUAL);
444        break;
445      case GREATER_THAN:
446        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.GREATER_THAN);
447        break;
448      case LESS_THAN:
449        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.LESS_THAN);
450        break;
451      case GREATER_OR_EQUAL:
452        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.GREATER_OR_EQUAL);
453        break;
454      case LESS_OR_EQUAL:
455        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.LESS_OR_EQUAL);
456        break;
457      default:
458        tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator.NULL);
459        break;
460    }
461    return tgt;
462  }
463
464  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator> convertQuestionnaireItemOperator(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemOperator> src) throws FHIRException {
465    if (src == null || src.isEmpty())
466      return null;
467    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperatorEnumFactory());
468    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
469    switch (src.getValue()) {
470      case EXISTS:
471        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.EXISTS);
472        break;
473      case EQUAL:
474        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.EQUAL);
475        break;
476      case NOT_EQUAL:
477        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.NOT_EQUAL);
478        break;
479      case GREATER_THAN:
480        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.GREATER_THAN);
481        break;
482      case LESS_THAN:
483        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.LESS_THAN);
484        break;
485      case GREATER_OR_EQUAL:
486        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.GREATER_OR_EQUAL);
487        break;
488      case LESS_OR_EQUAL:
489        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.LESS_OR_EQUAL);
490        break;
491      default:
492        tgt.setValue(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemOperator.NULL);
493        break;
494    }
495    return tgt;
496  }
497
498  public static org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent convertQuestionnaireItemAnswerOptionComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent src) throws FHIRException {
499    if (src == null)
500      return null;
501    org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent tgt = new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent();
502    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
503    if (src.hasValue())
504      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
505    if (src.hasInitialSelected())
506      tgt.setInitialSelectedElement(Boolean40_50.convertBoolean(src.getInitialSelectedElement()));
507    return tgt;
508  }
509
510  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent convertQuestionnaireItemAnswerOptionComponent(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemAnswerOptionComponent src) throws FHIRException {
511    if (src == null)
512      return null;
513    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemAnswerOptionComponent();
514    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
515    if (src.hasValue())
516      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
517    if (src.hasInitialSelected())
518      tgt.setInitialSelectedElement(Boolean40_50.convertBoolean(src.getInitialSelectedElement()));
519    return tgt;
520  }
521
522  public static org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent convertQuestionnaireItemInitialComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemInitialComponent src) throws FHIRException {
523    if (src == null)
524      return null;
525    org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent tgt = new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent();
526    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
527    if (src.hasValue())
528      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
529    return tgt;
530  }
531
532  public static org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemInitialComponent convertQuestionnaireItemInitialComponent(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent src) throws FHIRException {
533    if (src == null)
534      return null;
535    org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemInitialComponent tgt = new org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemInitialComponent();
536    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
537    if (src.hasValue())
538      tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue()));
539    return tgt;
540  }
541}