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.Attachment40_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.Identifier40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Instant40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012/* 013 Copyright (c) 2011+, HL7, Inc. 014 All rights reserved. 015 016 Redistribution and use in source and binary forms, with or without modification, 017 are permitted provided that the following conditions are met: 018 019 * Redistributions of source code must retain the above copyright notice, this 020 list of conditions and the following disclaimer. 021 * Redistributions in binary form must reproduce the above copyright notice, 022 this list of conditions and the following disclaimer in the documentation 023 and/or other materials provided with the distribution. 024 * Neither the name of HL7 nor the names of its contributors may be used to 025 endorse or promote products derived from this software without specific 026 prior written permission. 027 028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 029 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 030 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 031 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 032 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 033 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 034 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 035 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 036 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 037 POSSIBILITY OF SUCH DAMAGE. 038 039*/ 040// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 041public class DiagnosticReport40_50 { 042 043 public static org.hl7.fhir.r5.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.DiagnosticReport tgt = new org.hl7.fhir.r5.model.DiagnosticReport(); 047 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 050 for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 051 if (src.hasStatus()) 052 tgt.setStatusElement(convertDiagnosticReportStatus(src.getStatusElement())); 053 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) 054 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 055 if (src.hasCode()) 056 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 057 if (src.hasSubject()) 058 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 059 if (src.hasEncounter()) 060 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 061 if (src.hasEffective()) 062 tgt.setEffective(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEffective())); 063 if (src.hasIssued()) 064 tgt.setIssuedElement(Instant40_50.convertInstant(src.getIssuedElement())); 065 for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t)); 066 for (org.hl7.fhir.r4.model.Reference t : src.getResultsInterpreter()) 067 tgt.addResultsInterpreter(Reference40_50.convertReference(t)); 068 for (org.hl7.fhir.r4.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference40_50.convertReference(t)); 069 for (org.hl7.fhir.r4.model.Reference t : src.getResult()) tgt.addResult(Reference40_50.convertReference(t)); 070 for (org.hl7.fhir.r4.model.Reference t : src.getImagingStudy()) 071 tgt.addImagingStudy(Reference40_50.convertReference(t)); 072 for (org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportMediaComponent t : src.getMedia()) 073 tgt.addMedia(convertDiagnosticReportMediaComponent(t)); 074 if (src.hasConclusion()) 075 tgt.setConclusionElement(String40_50.convertString(src.getConclusionElement())); 076 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getConclusionCode()) 077 tgt.addConclusionCode(CodeableConcept40_50.convertCodeableConcept(t)); 078 for (org.hl7.fhir.r4.model.Attachment t : src.getPresentedForm()) 079 tgt.addPresentedForm(Attachment40_50.convertAttachment(t)); 080 return tgt; 081 } 082 083 public static org.hl7.fhir.r4.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.r5.model.DiagnosticReport src) throws FHIRException { 084 if (src == null) 085 return null; 086 org.hl7.fhir.r4.model.DiagnosticReport tgt = new org.hl7.fhir.r4.model.DiagnosticReport(); 087 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 088 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 089 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 090 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t)); 091 if (src.hasStatus()) 092 tgt.setStatusElement(convertDiagnosticReportStatus(src.getStatusElement())); 093 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 094 tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t)); 095 if (src.hasCode()) 096 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 097 if (src.hasSubject()) 098 tgt.setSubject(Reference40_50.convertReference(src.getSubject())); 099 if (src.hasEncounter()) 100 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 101 if (src.hasEffective()) 102 tgt.setEffective(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEffective())); 103 if (src.hasIssued()) 104 tgt.setIssuedElement(Instant40_50.convertInstant(src.getIssuedElement())); 105 for (org.hl7.fhir.r5.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t)); 106 for (org.hl7.fhir.r5.model.Reference t : src.getResultsInterpreter()) 107 tgt.addResultsInterpreter(Reference40_50.convertReference(t)); 108 for (org.hl7.fhir.r5.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference40_50.convertReference(t)); 109 for (org.hl7.fhir.r5.model.Reference t : src.getResult()) tgt.addResult(Reference40_50.convertReference(t)); 110 for (org.hl7.fhir.r5.model.Reference t : src.getImagingStudy()) 111 tgt.addImagingStudy(Reference40_50.convertReference(t)); 112 for (org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent t : src.getMedia()) 113 tgt.addMedia(convertDiagnosticReportMediaComponent(t)); 114 if (src.hasConclusion()) 115 tgt.setConclusionElement(String40_50.convertString(src.getConclusionElement())); 116 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getConclusionCode()) 117 tgt.addConclusionCode(CodeableConcept40_50.convertCodeableConcept(t)); 118 for (org.hl7.fhir.r5.model.Attachment t : src.getPresentedForm()) 119 tgt.addPresentedForm(Attachment40_50.convertAttachment(t)); 120 return tgt; 121 } 122 123 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus> convertDiagnosticReportStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus> src) throws FHIRException { 124 if (src == null || src.isEmpty()) 125 return null; 126 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatusEnumFactory()); 127 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 128 switch (src.getValue()) { 129 case REGISTERED: 130 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED); 131 break; 132 case PARTIAL: 133 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL); 134 break; 135 case PRELIMINARY: 136 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY); 137 break; 138 case FINAL: 139 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.FINAL); 140 break; 141 case AMENDED: 142 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.AMENDED); 143 break; 144 case CORRECTED: 145 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED); 146 break; 147 case APPENDED: 148 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.APPENDED); 149 break; 150 case CANCELLED: 151 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED); 152 break; 153 case ENTEREDINERROR: 154 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR); 155 break; 156 case UNKNOWN: 157 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN); 158 break; 159 default: 160 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.NULL); 161 break; 162 } 163 return tgt; 164 } 165 166 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus> convertDiagnosticReportStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus> src) throws FHIRException { 167 if (src == null || src.isEmpty()) 168 return null; 169 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatusEnumFactory()); 170 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 171 switch (src.getValue()) { 172 case REGISTERED: 173 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED); 174 break; 175 case PARTIAL: 176 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL); 177 break; 178 case PRELIMINARY: 179 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY); 180 break; 181 case FINAL: 182 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.FINAL); 183 break; 184 case AMENDED: 185 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.AMENDED); 186 break; 187 case CORRECTED: 188 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED); 189 break; 190 case APPENDED: 191 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.APPENDED); 192 break; 193 case CANCELLED: 194 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED); 195 break; 196 case ENTEREDINERROR: 197 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR); 198 break; 199 case UNKNOWN: 200 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN); 201 break; 202 default: 203 tgt.setValue(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.NULL); 204 break; 205 } 206 return tgt; 207 } 208 209 public static org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent convertDiagnosticReportMediaComponent(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportMediaComponent src) throws FHIRException { 210 if (src == null) 211 return null; 212 org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent tgt = new org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent(); 213 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 214 if (src.hasComment()) 215 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 216 if (src.hasLink()) 217 tgt.setLink(Reference40_50.convertReference(src.getLink())); 218 return tgt; 219 } 220 221 public static org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportMediaComponent convertDiagnosticReportMediaComponent(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent src) throws FHIRException { 222 if (src == null) 223 return null; 224 org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportMediaComponent tgt = new org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportMediaComponent(); 225 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 226 if (src.hasComment()) 227 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 228 if (src.hasLink()) 229 tgt.setLink(Reference40_50.convertReference(src.getLink())); 230 return tgt; 231 } 232}