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 DetectedIssue10_30 {
007
008    public static org.hl7.fhir.dstu2.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.dstu3.model.DetectedIssue src) throws FHIRException {
009        if (src == null || src.isEmpty())
010            return null;
011        org.hl7.fhir.dstu2.model.DetectedIssue tgt = new org.hl7.fhir.dstu2.model.DetectedIssue();
012        VersionConvertor_10_30.copyDomainResource(src, tgt);
013        if (src.hasPatient())
014            tgt.setPatient(VersionConvertor_10_30.convertReference(src.getPatient()));
015        if (src.hasCategory())
016            tgt.setCategory(VersionConvertor_10_30.convertCodeableConcept(src.getCategory()));
017        if (src.hasSeverity())
018            tgt.setSeverityElement(convertDetectedIssueSeverity(src.getSeverityElement()));
019        for (org.hl7.fhir.dstu3.model.Reference t : src.getImplicated()) tgt.addImplicated(VersionConvertor_10_30.convertReference(t));
020        if (src.hasDetailElement())
021            tgt.setDetailElement(VersionConvertor_10_30.convertString(src.getDetailElement()));
022        if (src.hasDate())
023            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
024        if (src.hasAuthor())
025            tgt.setAuthor(VersionConvertor_10_30.convertReference(src.getAuthor()));
026        if (src.hasIdentifier())
027            tgt.setIdentifier(VersionConvertor_10_30.convertIdentifier(src.getIdentifier()));
028        if (src.hasReferenceElement())
029            tgt.setReferenceElement(VersionConvertor_10_30.convertUri(src.getReferenceElement()));
030        for (org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation()) tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
031        return tgt;
032    }
033
034    public static org.hl7.fhir.dstu3.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.dstu2.model.DetectedIssue src) throws FHIRException {
035        if (src == null || src.isEmpty())
036            return null;
037        org.hl7.fhir.dstu3.model.DetectedIssue tgt = new org.hl7.fhir.dstu3.model.DetectedIssue();
038        VersionConvertor_10_30.copyDomainResource(src, tgt);
039        if (src.hasPatient())
040            tgt.setPatient(VersionConvertor_10_30.convertReference(src.getPatient()));
041        if (src.hasCategory())
042            tgt.setCategory(VersionConvertor_10_30.convertCodeableConcept(src.getCategory()));
043        if (src.hasSeverity())
044            tgt.setSeverityElement(convertDetectedIssueSeverity(src.getSeverityElement()));
045        for (org.hl7.fhir.dstu2.model.Reference t : src.getImplicated()) tgt.addImplicated(VersionConvertor_10_30.convertReference(t));
046        if (src.hasDetailElement())
047            tgt.setDetailElement(VersionConvertor_10_30.convertString(src.getDetailElement()));
048        if (src.hasDate())
049            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
050        if (src.hasAuthor())
051            tgt.setAuthor(VersionConvertor_10_30.convertReference(src.getAuthor()));
052        if (src.hasIdentifier())
053            tgt.setIdentifier(VersionConvertor_10_30.convertIdentifier(src.getIdentifier()));
054        if (src.hasReferenceElement())
055            tgt.setReferenceElement(VersionConvertor_10_30.convertUri(src.getReferenceElement()));
056        for (org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation()) tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
057        return tgt;
058    }
059
060    public static org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
061        if (src == null || src.isEmpty())
062            return null;
063        org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueMitigationComponent();
064        VersionConvertor_10_30.copyElement(src, tgt);
065        if (src.hasAction())
066            tgt.setAction(VersionConvertor_10_30.convertCodeableConcept(src.getAction()));
067        if (src.hasDate())
068            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
069        if (src.hasAuthor())
070            tgt.setAuthor(VersionConvertor_10_30.convertReference(src.getAuthor()));
071        return tgt;
072    }
073
074    public static org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
075        if (src == null || src.isEmpty())
076            return null;
077        org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueMitigationComponent();
078        VersionConvertor_10_30.copyElement(src, tgt);
079        if (src.hasAction())
080            tgt.setAction(VersionConvertor_10_30.convertCodeableConcept(src.getAction()));
081        if (src.hasDate())
082            tgt.setDateElement(VersionConvertor_10_30.convertDateTime(src.getDateElement()));
083        if (src.hasAuthor())
084            tgt.setAuthor(VersionConvertor_10_30.convertReference(src.getAuthor()));
085        return tgt;
086    }
087
088    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity> convertDetectedIssueSeverity(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity> src) throws FHIRException {
089        if (src == null || src.isEmpty())
090            return null;
091        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverityEnumFactory());
092        VersionConvertor_10_30.copyElement(src, tgt);
093        switch(src.getValue()) {
094            case HIGH:
095                tgt.setValue(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.HIGH);
096                break;
097            case MODERATE:
098                tgt.setValue(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.MODERATE);
099                break;
100            case LOW:
101                tgt.setValue(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.LOW);
102                break;
103            default:
104                tgt.setValue(org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity.NULL);
105                break;
106        }
107        return tgt;
108    }
109
110    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity> convertDetectedIssueSeverity(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DetectedIssue.DetectedIssueSeverity> src) throws FHIRException {
111        if (src == null || src.isEmpty())
112            return null;
113        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverityEnumFactory());
114        VersionConvertor_10_30.copyElement(src, tgt);
115        switch(src.getValue()) {
116            case HIGH:
117                tgt.setValue(org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity.HIGH);
118                break;
119            case MODERATE:
120                tgt.setValue(org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity.MODERATE);
121                break;
122            case LOW:
123                tgt.setValue(org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity.LOW);
124                break;
125            default:
126                tgt.setValue(org.hl7.fhir.dstu2.model.DetectedIssue.DetectedIssueSeverity.NULL);
127                break;
128        }
129        return tgt;
130    }
131}