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