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