![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.convertors.conv40_50.resources40_50; 002 003import java.util.stream.Collectors; 004 005import org.hl7.fhir.convertors.context.ConversionContext40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 011import org.hl7.fhir.exceptions.FHIRException; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 040*/ 041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 042public class ObservationDefinition40_50 { 043 044 public static org.hl7.fhir.r5.model.ObservationDefinition convertObservationDefinition(org.hl7.fhir.r4.model.ObservationDefinition src) throws FHIRException { 045 if (src == null) 046 return null; 047 org.hl7.fhir.r5.model.ObservationDefinition tgt = new org.hl7.fhir.r5.model.ObservationDefinition(); 048 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 049 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) 050 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 051 if (src.hasCode()) 052 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 053 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 054 tgt.setIdentifier(Identifier40_50.convertIdentifier(t)); 055 tgt.setPermittedDataType(src.getPermittedDataType().stream() 056 .map(ObservationDefinition40_50::convertObservationDataType) 057 .collect(Collectors.toList())); 058 if (src.hasMultipleResultsAllowed()) 059 tgt.setMultipleResultsAllowedElement(Boolean40_50.convertBoolean(src.getMultipleResultsAllowedElement())); 060 if (src.hasMethod()) 061 tgt.setMethod(CodeableConcept40_50.convertCodeableConcept(src.getMethod())); 062 if (src.hasPreferredReportName()) 063 tgt.setPreferredReportNameElement(String40_50.convertString(src.getPreferredReportNameElement())); 064 if (src.hasQuantitativeDetails()) { 065 for (org.hl7.fhir.r4.model.Coding c : src.getQuantitativeDetails().getUnit().getCoding()) { 066 tgt.addPermittedUnit(Coding40_50.convertCoding(c)); 067 } 068 } 069 070// for (org.hl7.fhir.r4.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent t : src.getQualifiedInterval()) tgt.addQualifiedInterval(convertObservationDefinitionQualifiedIntervalComponent(t)); 071// if (src.hasValidCodedValueSet()) 072// tgt.setValidCodedValueSet(convertReference(src.getValidCodedValueSet())); 073// if (src.hasNormalCodedValueSet()) 074// tgt.setNormalCodedValueSet(convertReference(src.getNormalCodedValueSet())); 075// if (src.hasAbnormalCodedValueSet()) 076// tgt.setAbnormalCodedValueSet(convertReference(src.getAbnormalCodedValueSet())); 077// if (src.hasCriticalCodedValueSet()) 078// tgt.setCriticalCodedValueSet(convertReference(src.getCriticalCodedValueSet())); 079 return tgt; 080 } 081 082 public static org.hl7.fhir.r4.model.ObservationDefinition convertObservationDefinition(org.hl7.fhir.r5.model.ObservationDefinition src) throws FHIRException { 083 if (src == null) 084 return null; 085 org.hl7.fhir.r4.model.ObservationDefinition tgt = new org.hl7.fhir.r4.model.ObservationDefinition(); 086 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 087 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 088 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 089 if (src.hasCode()) 090 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 091 if (src.hasIdentifier()) 092 tgt.addIdentifier(Identifier40_50.convertIdentifier(src.getIdentifier())); 093 tgt.setPermittedDataType(src.getPermittedDataType().stream() 094 .map(ObservationDefinition40_50::convertObservationDataType) 095 .collect(Collectors.toList())); 096 if (src.hasMultipleResultsAllowed()) 097 tgt.setMultipleResultsAllowedElement(Boolean40_50.convertBoolean(src.getMultipleResultsAllowedElement())); 098 if (src.hasMethod()) 099 tgt.setMethod(CodeableConcept40_50.convertCodeableConcept(src.getMethod())); 100 if (src.hasPreferredReportName()) 101 tgt.setPreferredReportNameElement(String40_50.convertString(src.getPreferredReportNameElement())); 102 for (org.hl7.fhir.r5.model.Coding c : src.getPermittedUnit()) { 103 tgt.getQuantitativeDetails().getUnit().addCoding(Coding40_50.convertCoding(c)); 104 } 105// for (org.hl7.fhir.r5.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent t : src.getQualifiedInterval()) tgt.addQualifiedInterval(convertObservationDefinitionQualifiedIntervalComponent(t)); 106// if (src.hasValidCodedValueSet()) 107// tgt.setValidCodedValueSet(convertReference(src.getValidCodedValueSet())); 108// if (src.hasNormalCodedValueSet()) 109// tgt.setNormalCodedValueSet(convertReference(src.getNormalCodedValueSet())); 110// if (src.hasAbnormalCodedValueSet()) 111// tgt.setAbnormalCodedValueSet(convertReference(src.getAbnormalCodedValueSet())); 112// if (src.hasCriticalCodedValueSet()) 113// tgt.setCriticalCodedValueSet(convertReference(src.getCriticalCodedValueSet())); 114 return tgt; 115 } 116 117 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType> convertObservationDataType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType> src) throws FHIRException { 118 if (src == null || src.isEmpty()) 119 return null; 120 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataTypeEnumFactory()); 121 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 122 switch (src.getValue()) { 123 case QUANTITY: 124 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.QUANTITY); 125 break; 126 case CODEABLECONCEPT: 127 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.CODEABLECONCEPT); 128 break; 129 case STRING: 130 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.STRING); 131 break; 132 case BOOLEAN: 133 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.BOOLEAN); 134 break; 135 case INTEGER: 136 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.INTEGER); 137 break; 138 case RANGE: 139 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.RANGE); 140 break; 141 case RATIO: 142 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.RATIO); 143 break; 144 case SAMPLEDDATA: 145 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.SAMPLEDDATA); 146 break; 147 case TIME: 148 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.TIME); 149 break; 150 case DATETIME: 151 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.DATETIME); 152 break; 153 case PERIOD: 154 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.PERIOD); 155 break; 156 default: 157 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType.NULL); 158 break; 159 } 160 return tgt; 161 } 162 163 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType> convertObservationDataType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationDataType> src) throws FHIRException { 164 if (src == null || src.isEmpty()) 165 return null; 166 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataTypeEnumFactory()); 167 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 168 switch (src.getValue()) { 169 case QUANTITY: 170 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.QUANTITY); 171 break; 172 case CODEABLECONCEPT: 173 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.CODEABLECONCEPT); 174 break; 175 case STRING: 176 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.STRING); 177 break; 178 case BOOLEAN: 179 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.BOOLEAN); 180 break; 181 case INTEGER: 182 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.INTEGER); 183 break; 184 case RANGE: 185 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.RANGE); 186 break; 187 case RATIO: 188 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.RATIO); 189 break; 190 case SAMPLEDDATA: 191 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.SAMPLEDDATA); 192 break; 193 case TIME: 194 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.TIME); 195 break; 196 case DATETIME: 197 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.DATETIME); 198 break; 199 case PERIOD: 200 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.PERIOD); 201 break; 202 default: 203 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDataType.NULL); 204 break; 205 } 206 return tgt; 207 } 208 209 210// public static org.hl7.fhir.r5.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent convertObservationDefinitionQualifiedIntervalComponent(org.hl7.fhir.r4.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent src) throws FHIRException { 211// if (src == null) 212// return null; 213// org.hl7.fhir.r5.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent tgt = new org.hl7.fhir.r5.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent(); 214// copyElement(src, tgt); 215// if (src.hasCategory()) 216// tgt.setCategoryElement(convertObservationRangeCategory(src.getCategoryElement())); 217// if (src.hasRange()) 218// tgt.setRange(convertRange(src.getRange())); 219// if (src.hasContext()) 220// tgt.setContext(convertCodeableConcept(src.getContext())); 221// for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAppliesTo()) tgt.addAppliesTo(convertCodeableConcept(t)); 222// if (src.hasGender()) 223// tgt.setGenderElement(Enumerations40_50.convertAdministrativeGender(src.getGenderElement())); 224// if (src.hasAge()) 225// tgt.setAge(convertRange(src.getAge())); 226// if (src.hasGestationalAge()) 227// tgt.setGestationalAge(convertRange(src.getGestationalAge())); 228// if (src.hasCondition()) 229// tgt.setConditionElement(convertString(src.getConditionElement())); 230// return tgt; 231// } 232// 233// public static org.hl7.fhir.r4.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent convertObservationDefinitionQualifiedIntervalComponent(org.hl7.fhir.r5.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent src) throws FHIRException { 234// if (src == null) 235// return null; 236// org.hl7.fhir.r4.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent tgt = new org.hl7.fhir.r4.model.ObservationDefinition.ObservationDefinitionQualifiedIntervalComponent(); 237// copyElement(src, tgt); 238// if (src.hasCategory()) 239// tgt.setCategoryElement(convertObservationRangeCategory(src.getCategoryElement())); 240// if (src.hasRange()) 241// tgt.setRange(convertRange(src.getRange())); 242// if (src.hasContext()) 243// tgt.setContext(convertCodeableConcept(src.getContext())); 244// for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAppliesTo()) tgt.addAppliesTo(convertCodeableConcept(t)); 245// if (src.hasGender()) 246// tgt.setGenderElement(Enumerations40_50.convertAdministrativeGender(src.getGenderElement())); 247// if (src.hasAge()) 248// tgt.setAge(convertRange(src.getAge())); 249// if (src.hasGestationalAge()) 250// tgt.setGestationalAge(convertRange(src.getGestationalAge())); 251// if (src.hasCondition()) 252// tgt.setConditionElement(convertString(src.getConditionElement())); 253// return tgt; 254// } 255 256 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory> convertObservationRangeCategory(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory> src) throws FHIRException { 257 if (src == null || src.isEmpty()) 258 return null; 259 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategoryEnumFactory()); 260 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 261 switch (src.getValue()) { 262 case REFERENCE: 263 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory.REFERENCE); 264 break; 265 case CRITICAL: 266 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory.CRITICAL); 267 break; 268 case ABSOLUTE: 269 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory.ABSOLUTE); 270 break; 271 default: 272 tgt.setValue(org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory.NULL); 273 break; 274 } 275 return tgt; 276 } 277 278 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory> convertObservationRangeCategory(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ObservationDefinition.ObservationRangeCategory> src) throws FHIRException { 279 if (src == null || src.isEmpty()) 280 return null; 281 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategoryEnumFactory()); 282 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 283 switch (src.getValue()) { 284 case REFERENCE: 285 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory.REFERENCE); 286 break; 287 case CRITICAL: 288 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory.CRITICAL); 289 break; 290 case ABSOLUTE: 291 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory.ABSOLUTE); 292 break; 293 default: 294 tgt.setValue(org.hl7.fhir.r4.model.ObservationDefinition.ObservationRangeCategory.NULL); 295 break; 296 } 297 return tgt; 298 } 299}