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