001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Instant30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012public class DiagnosticReport30_50 { 013 014 public static org.hl7.fhir.r5.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport src) throws FHIRException { 015 if (src == null) 016 return null; 017 org.hl7.fhir.r5.model.DiagnosticReport tgt = new org.hl7.fhir.r5.model.DiagnosticReport(); 018 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 019 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 020 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 021 for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_50.convertReference(t)); 022 if (src.hasStatus()) 023 tgt.setStatusElement(convertDiagnosticReportStatus(src.getStatusElement())); 024 if (src.hasCategory()) 025 tgt.addCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategory())); 026 if (src.hasCode()) 027 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 028 if (src.hasSubject()) 029 tgt.setSubject(Reference30_50.convertReference(src.getSubject())); 030 if (src.hasContext()) 031 tgt.setEncounter(Reference30_50.convertReference(src.getContext())); 032 if (src.hasEffective()) 033 tgt.setEffective(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getEffective())); 034 if (src.hasIssued()) 035 tgt.setIssuedElement(Instant30_50.convertInstant(src.getIssuedElement())); 036 for (org.hl7.fhir.dstu3.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference30_50.convertReference(t)); 037 for (org.hl7.fhir.dstu3.model.Reference t : src.getResult()) tgt.addResult(Reference30_50.convertReference(t)); 038 for (org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent t : src.getImage()) 039 tgt.addMedia(convertDiagnosticReportImageComponent(t)); 040 if (src.hasConclusion()) 041 tgt.setConclusionElement(String30_50.convertStringToMarkdown(src.getConclusionElement())); 042 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCodedDiagnosis()) 043 tgt.addConclusionCode(CodeableConcept30_50.convertCodeableConcept(t)); 044 for (org.hl7.fhir.dstu3.model.Attachment t : src.getPresentedForm()) 045 tgt.addPresentedForm(Attachment30_50.convertAttachment(t)); 046 return tgt; 047 } 048 049 public static org.hl7.fhir.dstu3.model.DiagnosticReport convertDiagnosticReport(org.hl7.fhir.r5.model.DiagnosticReport src) throws FHIRException { 050 if (src == null) 051 return null; 052 org.hl7.fhir.dstu3.model.DiagnosticReport tgt = new org.hl7.fhir.dstu3.model.DiagnosticReport(); 053 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 054 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 055 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 056 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_50.convertReference(t)); 057 if (src.hasStatus()) 058 tgt.setStatusElement(convertDiagnosticReportStatus(src.getStatusElement())); 059 if (src.hasCategory()) 060 tgt.setCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategoryFirstRep())); 061 if (src.hasCode()) 062 tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 063 if (src.hasSubject()) 064 tgt.setSubject(Reference30_50.convertReference(src.getSubject())); 065 if (src.hasEncounter()) 066 tgt.setContext(Reference30_50.convertReference(src.getEncounter())); 067 if (src.hasEffective()) 068 tgt.setEffective(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getEffective())); 069 if (src.hasIssued()) 070 tgt.setIssuedElement(Instant30_50.convertInstant(src.getIssuedElement())); 071 for (org.hl7.fhir.r5.model.Reference t : src.getSpecimen()) tgt.addSpecimen(Reference30_50.convertReference(t)); 072 for (org.hl7.fhir.r5.model.Reference t : src.getResult()) tgt.addResult(Reference30_50.convertReference(t)); 073 for (org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent t : src.getMedia()) 074 tgt.addImage(convertDiagnosticReportImageComponent(t)); 075 if (src.hasConclusion()) 076 tgt.setConclusionElement(String30_50.convertString(src.getConclusionElement())); 077 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getConclusionCode()) 078 tgt.addCodedDiagnosis(CodeableConcept30_50.convertCodeableConcept(t)); 079 for (org.hl7.fhir.r5.model.Attachment t : src.getPresentedForm()) 080 tgt.addPresentedForm(Attachment30_50.convertAttachment(t)); 081 return tgt; 082 } 083 084 public static org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent convertDiagnosticReportImageComponent(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent src) throws FHIRException { 085 if (src == null) 086 return null; 087 org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent tgt = new org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent(); 088 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 089 if (src.hasComment()) 090 tgt.setCommentElement(String30_50.convertString(src.getCommentElement())); 091 if (src.hasLink()) 092 tgt.setLink(Reference30_50.convertReference(src.getLink())); 093 return tgt; 094 } 095 096 public static org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent convertDiagnosticReportImageComponent(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportImageComponent src) throws FHIRException { 097 if (src == null) 098 return null; 099 org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent tgt = new org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportMediaComponent(); 100 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 101 if (src.hasComment()) 102 tgt.setCommentElement(String30_50.convertString(src.getCommentElement())); 103 if (src.hasLink()) 104 tgt.setLink(Reference30_50.convertReference(src.getLink())); 105 return tgt; 106 } 107 108 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus> convertDiagnosticReportStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus> src) throws FHIRException { 109 if (src == null || src.isEmpty()) 110 return null; 111 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()); 112 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 113 switch (src.getValue()) { 114 case REGISTERED: 115 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED); 116 break; 117 case PARTIAL: 118 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL); 119 break; 120 case PRELIMINARY: 121 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY); 122 break; 123 case FINAL: 124 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.FINAL); 125 break; 126 case AMENDED: 127 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.AMENDED); 128 break; 129 case CORRECTED: 130 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED); 131 break; 132 case APPENDED: 133 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.APPENDED); 134 break; 135 case CANCELLED: 136 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED); 137 break; 138 case ENTEREDINERROR: 139 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR); 140 break; 141 case UNKNOWN: 142 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN); 143 break; 144 default: 145 tgt.setValue(org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus.NULL); 146 break; 147 } 148 return tgt; 149 } 150 151 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus> convertDiagnosticReportStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DiagnosticReport.DiagnosticReportStatus> src) throws FHIRException { 152 if (src == null || src.isEmpty()) 153 return null; 154 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatusEnumFactory()); 155 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 156 switch (src.getValue()) { 157 case REGISTERED: 158 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.REGISTERED); 159 break; 160 case PARTIAL: 161 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.PARTIAL); 162 break; 163 case PRELIMINARY: 164 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.PRELIMINARY); 165 break; 166 case FINAL: 167 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.FINAL); 168 break; 169 case AMENDED: 170 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.AMENDED); 171 break; 172 case CORRECTED: 173 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.CORRECTED); 174 break; 175 case APPENDED: 176 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.APPENDED); 177 break; 178 case CANCELLED: 179 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED); 180 break; 181 case ENTEREDINERROR: 182 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.ENTEREDINERROR); 183 break; 184 case UNKNOWN: 185 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.UNKNOWN); 186 break; 187 default: 188 tgt.setValue(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus.NULL); 189 break; 190 } 191 return tgt; 192 } 193}