001package org.hl7.fhir.convertors.conv10_30;
002
003import org.hl7.fhir.convertors.VersionConvertor_10_30;
004import org.hl7.fhir.exceptions.FHIRException;
005
006public class Condition10_30 {
007
008    public static org.hl7.fhir.dstu3.model.Condition convertCondition(org.hl7.fhir.dstu2.model.Condition src) throws FHIRException {
009        if (src == null || src.isEmpty())
010            return null;
011        org.hl7.fhir.dstu3.model.Condition tgt = new org.hl7.fhir.dstu3.model.Condition();
012        VersionConvertor_10_30.copyDomainResource(src, tgt);
013        for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(t));
014        if (src.hasPatient())
015            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getPatient()));
016        if (src.hasEncounter())
017            tgt.setContext(VersionConvertor_10_30.convertReference(src.getEncounter()));
018        if (src.hasAsserter())
019            tgt.setAsserter(VersionConvertor_10_30.convertReference(src.getAsserter()));
020        if (src.hasDateRecorded())
021            tgt.setAssertedDate(src.getDateRecorded());
022        if (src.hasCode())
023            tgt.setCode(VersionConvertor_10_30.convertCodeableConcept(src.getCode()));
024        if (src.hasCategory())
025            tgt.addCategory(VersionConvertor_10_30.convertCodeableConcept(src.getCategory()));
026        try {
027            if (src.hasClinicalStatus())
028                tgt.setClinicalStatus(org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus.fromCode(src.getClinicalStatus()));
029        } catch (org.hl7.fhir.exceptions.FHIRException e) {
030            throw new FHIRException(e);
031        }
032        if (src.hasVerificationStatus())
033            tgt.setVerificationStatusElement(convertConditionVerificationStatus(src.getVerificationStatusElement()));
034        if (src.hasSeverity())
035            tgt.setSeverity(VersionConvertor_10_30.convertCodeableConcept(src.getSeverity()));
036        if (src.hasOnset())
037            tgt.setOnset(VersionConvertor_10_30.convertType(src.getOnset()));
038        if (src.hasAbatement())
039            tgt.setAbatement(VersionConvertor_10_30.convertType(src.getAbatement()));
040        if (src.hasStage())
041            tgt.setStage(convertConditionStageComponent(src.getStage()));
042        for (org.hl7.fhir.dstu2.model.Condition.ConditionEvidenceComponent t : src.getEvidence()) tgt.addEvidence(convertConditionEvidenceComponent(t));
043        for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getBodySite()) tgt.addBodySite(VersionConvertor_10_30.convertCodeableConcept(t));
044        return tgt;
045    }
046
047    public static org.hl7.fhir.dstu2.model.Condition convertCondition(org.hl7.fhir.dstu3.model.Condition src) throws FHIRException {
048        if (src == null || src.isEmpty())
049            return null;
050        org.hl7.fhir.dstu2.model.Condition tgt = new org.hl7.fhir.dstu2.model.Condition();
051        VersionConvertor_10_30.copyDomainResource(src, tgt);
052        for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(t));
053        if (src.hasSubject())
054            tgt.setPatient(VersionConvertor_10_30.convertReference(src.getSubject()));
055        if (src.hasContext())
056            tgt.setEncounter(VersionConvertor_10_30.convertReference(src.getContext()));
057        if (src.hasAsserter())
058            tgt.setAsserter(VersionConvertor_10_30.convertReference(src.getAsserter()));
059        if (src.hasAssertedDate())
060            tgt.setDateRecorded(src.getAssertedDate());
061        if (src.hasCode())
062            tgt.setCode(VersionConvertor_10_30.convertCodeableConcept(src.getCode()));
063        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory()) tgt.setCategory(VersionConvertor_10_30.convertCodeableConcept(t));
064        tgt.setClinicalStatus(src.getClinicalStatus().toCode());
065        if (src.hasVerificationStatus())
066            tgt.setVerificationStatusElement(convertConditionVerificationStatus(src.getVerificationStatusElement()));
067        if (src.hasSeverity())
068            tgt.setSeverity(VersionConvertor_10_30.convertCodeableConcept(src.getSeverity()));
069        if (src.hasOnset())
070            tgt.setOnset(VersionConvertor_10_30.convertType(src.getOnset()));
071        if (src.hasAbatement())
072            tgt.setAbatement(VersionConvertor_10_30.convertType(src.getAbatement()));
073        if (src.hasStage())
074            tgt.setStage(convertConditionStageComponent(src.getStage()));
075        for (org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent t : src.getEvidence()) tgt.addEvidence(convertConditionEvidenceComponent(t));
076        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getBodySite()) tgt.addBodySite(VersionConvertor_10_30.convertCodeableConcept(t));
077        return tgt;
078    }
079
080    public static org.hl7.fhir.dstu2.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
081        if (src == null || src.isEmpty())
082            return null;
083        org.hl7.fhir.dstu2.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.dstu2.model.Condition.ConditionEvidenceComponent();
084        VersionConvertor_10_30.copyElement(src, tgt);
085        for (org.hl7.fhir.dstu3.model.CodeableConcept cc : src.getCode()) tgt.setCode(VersionConvertor_10_30.convertCodeableConcept(cc));
086        for (org.hl7.fhir.dstu3.model.Reference t : src.getDetail()) tgt.addDetail(VersionConvertor_10_30.convertReference(t));
087        return tgt;
088    }
089
090    public static org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.dstu2.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
091        if (src == null || src.isEmpty())
092            return null;
093        org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.dstu3.model.Condition.ConditionEvidenceComponent();
094        VersionConvertor_10_30.copyElement(src, tgt);
095        if (src.hasCode())
096            tgt.addCode(VersionConvertor_10_30.convertCodeableConcept(src.getCode()));
097        for (org.hl7.fhir.dstu2.model.Reference t : src.getDetail()) tgt.addDetail(VersionConvertor_10_30.convertReference(t));
098        return tgt;
099    }
100
101    public static org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.dstu2.model.Condition.ConditionStageComponent src) throws FHIRException {
102        if (src == null || src.isEmpty())
103            return null;
104        org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent();
105        VersionConvertor_10_30.copyElement(src, tgt);
106        if (src.hasSummary())
107            tgt.setSummary(VersionConvertor_10_30.convertCodeableConcept(src.getSummary()));
108        for (org.hl7.fhir.dstu2.model.Reference t : src.getAssessment()) tgt.addAssessment(VersionConvertor_10_30.convertReference(t));
109        return tgt;
110    }
111
112    public static org.hl7.fhir.dstu2.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.dstu3.model.Condition.ConditionStageComponent src) throws FHIRException {
113        if (src == null || src.isEmpty())
114            return null;
115        org.hl7.fhir.dstu2.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.dstu2.model.Condition.ConditionStageComponent();
116        VersionConvertor_10_30.copyElement(src, tgt);
117        if (src.hasSummary())
118            tgt.setSummary(VersionConvertor_10_30.convertCodeableConcept(src.getSummary()));
119        for (org.hl7.fhir.dstu3.model.Reference t : src.getAssessment()) tgt.addAssessment(VersionConvertor_10_30.convertReference(t));
120        return tgt;
121    }
122
123    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus> convertConditionVerificationStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus> src) throws FHIRException {
124        if (src == null || src.isEmpty())
125            return null;
126        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatusEnumFactory());
127        VersionConvertor_10_30.copyElement(src, tgt);
128        switch(src.getValue()) {
129            case PROVISIONAL:
130                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.PROVISIONAL);
131                break;
132            case DIFFERENTIAL:
133                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.DIFFERENTIAL);
134                break;
135            case CONFIRMED:
136                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.CONFIRMED);
137                break;
138            case REFUTED:
139                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.REFUTED);
140                break;
141            case ENTEREDINERROR:
142                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.ENTEREDINERROR);
143                break;
144            case UNKNOWN:
145                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.UNKNOWN);
146                break;
147            default:
148                tgt.setValue(org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus.NULL);
149                break;
150        }
151        return tgt;
152    }
153
154    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus> convertConditionVerificationStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Condition.ConditionVerificationStatus> src) throws FHIRException {
155        if (src == null || src.isEmpty())
156            return null;
157        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatusEnumFactory());
158        VersionConvertor_10_30.copyElement(src, tgt);
159        switch(src.getValue()) {
160            case PROVISIONAL:
161                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.PROVISIONAL);
162                break;
163            case DIFFERENTIAL:
164                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.DIFFERENTIAL);
165                break;
166            case CONFIRMED:
167                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.CONFIRMED);
168                break;
169            case REFUTED:
170                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.REFUTED);
171                break;
172            case ENTEREDINERROR:
173                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.ENTEREDINERROR);
174                break;
175            case UNKNOWN:
176                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.UNKNOWN);
177                break;
178            default:
179                tgt.setValue(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus.NULL);
180                break;
181        }
182        return tgt;
183    }
184}