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