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