001package org.hl7.fhir.convertors.conv40_50.resources40_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext40_50; 004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.*; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 008import org.hl7.fhir.exceptions.FHIRException; 009 010/* 011 Copyright (c) 2011+, HL7, Inc. 012 All rights reserved. 013 014 Redistribution and use in source and binary forms, with or without modification, 015 are permitted provided that the following conditions are met: 016 017 * Redistributions of source code must retain the above copyright notice, this 018 list of conditions and the following disclaimer. 019 * Redistributions in binary form must reproduce the above copyright notice, 020 this list of conditions and the following disclaimer in the documentation 021 and/or other materials provided with the distribution. 022 * Neither the name of HL7 nor the names of its contributors may be used to 023 endorse or promote products derived from this software without specific 024 prior written permission. 025 026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 027 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 028 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 029 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 030 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 031 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 032 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 033 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 034 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 035 POSSIBILITY OF SUCH DAMAGE. 036 037*/ 038// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 039public class Specimen40_50 { 040 041 public static org.hl7.fhir.r5.model.Specimen convertSpecimen(org.hl7.fhir.r4.model.Specimen src) throws FHIRException { 042 if (src == null) 043 return null; 044 org.hl7.fhir.r5.model.Specimen tgt = new org.hl7.fhir.r5.model.Specimen(); 045 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 046 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 047 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 048 if (src.hasAccessionIdentifier()) 049 tgt.setAccessionIdentifier(Identifier40_50.convertIdentifier(src.getAccessionIdentifier())); 050 if (src.hasStatus()) 051 tgt.setStatusElement(convertSpecimenStatus(src.getStatusElement())); 052 if (src.hasType()) 053 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 054 if (src.hasSubject()) 055 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 056 if (src.hasReceivedTime()) 057 tgt.setReceivedTimeElement(DateTime40_50.convertDateTime(src.getReceivedTimeElement())); 058 for (org.hl7.fhir.r4.model.Reference t : src.getParent()) tgt.addParent(Reference40_50.convertReference(t)); 059 for (org.hl7.fhir.r4.model.Reference t : src.getRequest()) tgt.addRequest(Reference40_50.convertReference(t)); 060 if (src.hasCollection()) 061 tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection())); 062 for (org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent t : src.getProcessing()) 063 tgt.addProcessing(convertSpecimenProcessingComponent(t)); 064 for (org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent t : src.getContainer()) 065 tgt.addContainer(convertSpecimenContainerComponent(t)); 066 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCondition()) 067 tgt.addCondition(CodeableConcept40_50.convertCodeableConcept(t)); 068 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 069 return tgt; 070 } 071 072 public static org.hl7.fhir.r4.model.Specimen convertSpecimen(org.hl7.fhir.r5.model.Specimen src) throws FHIRException { 073 if (src == null) 074 return null; 075 org.hl7.fhir.r4.model.Specimen tgt = new org.hl7.fhir.r4.model.Specimen(); 076 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 077 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 078 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 079 if (src.hasAccessionIdentifier()) 080 tgt.setAccessionIdentifier(Identifier40_50.convertIdentifier(src.getAccessionIdentifier())); 081 if (src.hasStatus()) 082 tgt.setStatusElement(convertSpecimenStatus(src.getStatusElement())); 083 if (src.hasType()) 084 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 085 if (src.hasSubject()) 086 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 087 if (src.hasReceivedTime()) 088 tgt.setReceivedTimeElement(DateTime40_50.convertDateTime(src.getReceivedTimeElement())); 089 for (org.hl7.fhir.r5.model.Reference t : src.getParent()) tgt.addParent(Reference40_50.convertReference(t)); 090 for (org.hl7.fhir.r5.model.Reference t : src.getRequest()) tgt.addRequest(Reference40_50.convertReference(t)); 091 if (src.hasCollection()) 092 tgt.setCollection(convertSpecimenCollectionComponent(src.getCollection())); 093 for (org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent t : src.getProcessing()) 094 tgt.addProcessing(convertSpecimenProcessingComponent(t)); 095 for (org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent t : src.getContainer()) 096 tgt.addContainer(convertSpecimenContainerComponent(t)); 097 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCondition()) 098 tgt.addCondition(CodeableConcept40_50.convertCodeableConcept(t)); 099 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 100 return tgt; 101 } 102 103 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> convertSpecimenStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Specimen.SpecimenStatus> src) throws FHIRException { 104 if (src == null || src.isEmpty()) 105 return null; 106 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Specimen.SpecimenStatusEnumFactory()); 107 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 108 switch (src.getValue()) { 109 case AVAILABLE: 110 tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.AVAILABLE); 111 break; 112 case UNAVAILABLE: 113 tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.UNAVAILABLE); 114 break; 115 case UNSATISFACTORY: 116 tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.UNSATISFACTORY); 117 break; 118 case ENTEREDINERROR: 119 tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.ENTEREDINERROR); 120 break; 121 default: 122 tgt.setValue(org.hl7.fhir.r5.model.Specimen.SpecimenStatus.NULL); 123 break; 124 } 125 return tgt; 126 } 127 128 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Specimen.SpecimenStatus> convertSpecimenStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Specimen.SpecimenStatus> src) throws FHIRException { 129 if (src == null || src.isEmpty()) 130 return null; 131 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Specimen.SpecimenStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Specimen.SpecimenStatusEnumFactory()); 132 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 133 switch (src.getValue()) { 134 case AVAILABLE: 135 tgt.setValue(org.hl7.fhir.r4.model.Specimen.SpecimenStatus.AVAILABLE); 136 break; 137 case UNAVAILABLE: 138 tgt.setValue(org.hl7.fhir.r4.model.Specimen.SpecimenStatus.UNAVAILABLE); 139 break; 140 case UNSATISFACTORY: 141 tgt.setValue(org.hl7.fhir.r4.model.Specimen.SpecimenStatus.UNSATISFACTORY); 142 break; 143 case ENTEREDINERROR: 144 tgt.setValue(org.hl7.fhir.r4.model.Specimen.SpecimenStatus.ENTEREDINERROR); 145 break; 146 default: 147 tgt.setValue(org.hl7.fhir.r4.model.Specimen.SpecimenStatus.NULL); 148 break; 149 } 150 return tgt; 151 } 152 153 public static org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent src) throws FHIRException { 154 if (src == null) 155 return null; 156 org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent(); 157 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 158 if (src.hasCollector()) 159 tgt.setCollector(Reference40_50.convertReference(src.getCollector())); 160 if (src.hasCollected()) 161 tgt.setCollected(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getCollected())); 162 if (src.hasDuration()) 163 tgt.setDuration(Duration40_50.convertDuration(src.getDuration())); 164 if (src.hasQuantity()) 165 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 166 if (src.hasMethod()) 167 tgt.setMethod(CodeableConcept40_50.convertCodeableConcept(src.getMethod())); 168 if (src.hasBodySite()) 169 tgt.getBodySite().setConcept(CodeableConcept40_50.convertCodeableConcept(src.getBodySite())); 170 if (src.hasFastingStatus()) 171 tgt.setFastingStatus(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getFastingStatus())); 172 return tgt; 173 } 174 175 public static org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent convertSpecimenCollectionComponent(org.hl7.fhir.r5.model.Specimen.SpecimenCollectionComponent src) throws FHIRException { 176 if (src == null) 177 return null; 178 org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenCollectionComponent(); 179 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 180 if (src.hasCollector()) 181 tgt.setCollector(Reference40_50.convertReference(src.getCollector())); 182 if (src.hasCollected()) 183 tgt.setCollected(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getCollected())); 184 if (src.hasDuration()) 185 tgt.setDuration(Duration40_50.convertDuration(src.getDuration())); 186 if (src.hasQuantity()) 187 tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity())); 188 if (src.hasMethod()) 189 tgt.setMethod(CodeableConcept40_50.convertCodeableConcept(src.getMethod())); 190 if (src.getBodySite().hasConcept()) 191 tgt.setBodySite(CodeableConcept40_50.convertCodeableConcept(src.getBodySite().getConcept())); 192 if (src.hasFastingStatus()) 193 tgt.setFastingStatus(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getFastingStatus())); 194 return tgt; 195 } 196 197 public static org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent src) throws FHIRException { 198 if (src == null) 199 return null; 200 org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent(); 201 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 202 if (src.hasDescription()) 203 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 204// if (src.hasProcedure()) 205// tgt.setProcedure(CodeableConcept40_50.convertCodeableConcept(src.getProcedure())); 206 for (org.hl7.fhir.r4.model.Reference t : src.getAdditive()) tgt.addAdditive(Reference40_50.convertReference(t)); 207 if (src.hasTime()) 208 tgt.setTime(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getTime())); 209 return tgt; 210 } 211 212 public static org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent convertSpecimenProcessingComponent(org.hl7.fhir.r5.model.Specimen.SpecimenProcessingComponent src) throws FHIRException { 213 if (src == null) 214 return null; 215 org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenProcessingComponent(); 216 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 217 if (src.hasDescription()) 218 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 219// if (src.hasProcedure()) 220// tgt.setProcedure(CodeableConcept40_50.convertCodeableConcept(src.getProcedure())); 221 for (org.hl7.fhir.r5.model.Reference t : src.getAdditive()) tgt.addAdditive(Reference40_50.convertReference(t)); 222 if (src.hasTime()) 223 tgt.setTime(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getTime())); 224 return tgt; 225 } 226 227 public static org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent src) throws FHIRException { 228 if (src == null) 229 return null; 230 org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent(); 231 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 232 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 233 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 234 if (src.hasDescription()) 235 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 236 if (src.hasType()) 237 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 238 if (src.hasCapacity()) 239 tgt.setCapacity(SimpleQuantity40_50.convertSimpleQuantity(src.getCapacity())); 240 if (src.hasSpecimenQuantity()) 241 tgt.setSpecimenQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getSpecimenQuantity())); 242 if (src.hasAdditive()) 243 tgt.setAdditive(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAdditive())); 244 return tgt; 245 } 246 247 public static org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent convertSpecimenContainerComponent(org.hl7.fhir.r5.model.Specimen.SpecimenContainerComponent src) throws FHIRException { 248 if (src == null) 249 return null; 250 org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent tgt = new org.hl7.fhir.r4.model.Specimen.SpecimenContainerComponent(); 251 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 252 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 253 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 254 if (src.hasDescription()) 255 tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement())); 256 if (src.hasType()) 257 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 258 if (src.hasCapacity()) 259 tgt.setCapacity(SimpleQuantity40_50.convertSimpleQuantity(src.getCapacity())); 260 if (src.hasSpecimenQuantity()) 261 tgt.setSpecimenQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getSpecimenQuantity())); 262 if (src.hasAdditive()) 263 tgt.setAdditive(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAdditive())); 264 return tgt; 265 } 266}