001package org.hl7.fhir.convertors.conv10_30;
002
003import org.hl7.fhir.convertors.VersionConvertor_10_30;
004import org.hl7.fhir.dstu3.model.UriType;
005import org.hl7.fhir.exceptions.FHIRException;
006
007public class ClinicalImpression10_30 {
008
009    public static org.hl7.fhir.dstu3.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.dstu2.model.ClinicalImpression src) throws FHIRException {
010        if (src == null || src.isEmpty())
011            return null;
012        org.hl7.fhir.dstu3.model.ClinicalImpression tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression();
013        VersionConvertor_10_30.copyDomainResource(src, tgt);
014        if (src.hasPatient())
015            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getPatient()));
016        if (src.hasAssessor())
017            tgt.setAssessor(VersionConvertor_10_30.convertReference(src.getAssessor()));
018        if (src.hasStatus())
019            tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement()));
020        if (src.hasDate())
021            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
022        if (src.hasDescriptionElement())
023            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
024        if (src.hasPrevious())
025            tgt.setPrevious(VersionConvertor_10_30.convertReference(src.getPrevious()));
026        for (org.hl7.fhir.dstu2.model.Reference t : src.getProblem()) tgt.addProblem(VersionConvertor_10_30.convertReference(t));
027        tgt.addProtocol(src.getProtocol());
028        if (src.hasSummaryElement())
029            tgt.setSummaryElement(VersionConvertor_10_30.convertString(src.getSummaryElement()));
030        for (org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding()) tgt.addFinding(convertClinicalImpressionFindingComponent(t));
031        if (src.hasPrognosis())
032            tgt.addPrognosisCodeableConcept().setText(src.getPrognosis());
033        for (org.hl7.fhir.dstu2.model.Reference t : src.getAction()) tgt.addAction(VersionConvertor_10_30.convertReference(t));
034        return tgt;
035    }
036
037    public static org.hl7.fhir.dstu2.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.dstu3.model.ClinicalImpression src) throws FHIRException {
038        if (src == null || src.isEmpty())
039            return null;
040        org.hl7.fhir.dstu2.model.ClinicalImpression tgt = new org.hl7.fhir.dstu2.model.ClinicalImpression();
041        VersionConvertor_10_30.copyDomainResource(src, tgt);
042        if (src.hasSubject())
043            tgt.setPatient(VersionConvertor_10_30.convertReference(src.getSubject()));
044        if (src.hasAssessor())
045            tgt.setAssessor(VersionConvertor_10_30.convertReference(src.getAssessor()));
046        if (src.hasStatus())
047            tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement()));
048        if (src.hasDate())
049            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
050        if (src.hasDescriptionElement())
051            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
052        if (src.hasPrevious())
053            tgt.setPrevious(VersionConvertor_10_30.convertReference(src.getPrevious()));
054        for (org.hl7.fhir.dstu3.model.Reference t : src.getProblem()) tgt.addProblem(VersionConvertor_10_30.convertReference(t));
055        for (UriType t : src.getProtocol()) tgt.setProtocol(t.asStringValue());
056        if (src.hasSummaryElement())
057            tgt.setSummaryElement(VersionConvertor_10_30.convertString(src.getSummaryElement()));
058        for (org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding()) tgt.addFinding(convertClinicalImpressionFindingComponent(t));
059        if (src.hasText())
060            tgt.setPrognosis(src.getPrognosisCodeableConceptFirstRep().getText());
061        for (org.hl7.fhir.dstu3.model.Reference t : src.getAction()) tgt.addAction(VersionConvertor_10_30.convertReference(t));
062        return tgt;
063    }
064
065    public static org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
066        if (src == null || src.isEmpty())
067            return null;
068        org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent();
069        VersionConvertor_10_30.copyElement(src, tgt);
070        if (src.hasItem())
071            tgt.setItem(VersionConvertor_10_30.convertCodeableConcept(src.getItem()));
072        return tgt;
073    }
074
075    public static org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
076        if (src == null || src.isEmpty())
077            return null;
078        org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionFindingComponent();
079        VersionConvertor_10_30.copyElement(src, tgt);
080        if (src.hasItemCodeableConcept())
081            try {
082                if (src.hasItemCodeableConcept())
083                    tgt.setItem(VersionConvertor_10_30.convertCodeableConcept(src.getItemCodeableConcept()));
084            } catch (org.hl7.fhir.exceptions.FHIRException e) {
085            }
086        return tgt;
087    }
088
089    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> convertClinicalImpressionStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus> src) throws FHIRException {
090        if (src == null || src.isEmpty())
091            return null;
092        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatusEnumFactory());
093        VersionConvertor_10_30.copyElement(src, tgt);
094        switch(src.getValue()) {
095            case INPROGRESS:
096                tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.DRAFT);
097                break;
098            case COMPLETED:
099                tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED);
100                break;
101            case ENTEREDINERROR:
102                tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR);
103                break;
104            default:
105                tgt.setValue(org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus.NULL);
106                break;
107        }
108        return tgt;
109    }
110
111    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus> convertClinicalImpressionStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.ClinicalImpression.ClinicalImpressionStatus> src) throws FHIRException {
112        if (src == null || src.isEmpty())
113            return null;
114        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatusEnumFactory());
115        VersionConvertor_10_30.copyElement(src, tgt);
116        switch(src.getValue()) {
117            case DRAFT:
118                tgt.setValue(org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus.INPROGRESS);
119                break;
120            case COMPLETED:
121                tgt.setValue(org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED);
122                break;
123            case ENTEREDINERROR:
124                tgt.setValue(org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR);
125                break;
126            default:
127                tgt.setValue(org.hl7.fhir.dstu2.model.ClinicalImpression.ClinicalImpressionStatus.NULL);
128                break;
129        }
130        return tgt;
131    }
132}