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