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 CarePlan10_30 {
007
008    public static org.hl7.fhir.dstu3.model.CarePlan convertCarePlan(org.hl7.fhir.dstu2.model.CarePlan src) throws FHIRException {
009        if (src == null || src.isEmpty())
010            return null;
011        org.hl7.fhir.dstu3.model.CarePlan tgt = new org.hl7.fhir.dstu3.model.CarePlan();
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.hasSubject())
015            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getSubject()));
016        if (src.hasStatus())
017            tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement()));
018        if (src.hasContext())
019            tgt.setContext(VersionConvertor_10_30.convertReference(src.getContext()));
020        if (src.hasPeriod())
021            tgt.setPeriod(VersionConvertor_10_30.convertPeriod(src.getPeriod()));
022        for (org.hl7.fhir.dstu2.model.Reference t : src.getAuthor()) tgt.addAuthor(VersionConvertor_10_30.convertReference(t));
023        for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getCategory()) tgt.addCategory(VersionConvertor_10_30.convertCodeableConcept(t));
024        if (src.hasDescriptionElement())
025            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
026        for (org.hl7.fhir.dstu2.model.Reference t : src.getAddresses()) tgt.addAddresses(VersionConvertor_10_30.convertReference(t));
027        for (org.hl7.fhir.dstu2.model.Reference t : src.getGoal()) tgt.addGoal(VersionConvertor_10_30.convertReference(t));
028        for (org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent t : src.getActivity()) tgt.addActivity(convertCarePlanActivityComponent(t));
029        return tgt;
030    }
031
032    public static org.hl7.fhir.dstu2.model.CarePlan convertCarePlan(org.hl7.fhir.dstu3.model.CarePlan src) throws FHIRException {
033        if (src == null || src.isEmpty())
034            return null;
035        org.hl7.fhir.dstu2.model.CarePlan tgt = new org.hl7.fhir.dstu2.model.CarePlan();
036        VersionConvertor_10_30.copyDomainResource(src, tgt);
037        for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(t));
038        if (src.hasSubject())
039            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getSubject()));
040        if (src.hasStatus())
041            tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement()));
042        if (src.hasContext())
043            tgt.setContext(VersionConvertor_10_30.convertReference(src.getContext()));
044        if (src.hasPeriod())
045            tgt.setPeriod(VersionConvertor_10_30.convertPeriod(src.getPeriod()));
046        for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthor()) tgt.addAuthor(VersionConvertor_10_30.convertReference(t));
047        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory()) tgt.addCategory(VersionConvertor_10_30.convertCodeableConcept(t));
048        if (src.hasDescriptionElement())
049            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
050        for (org.hl7.fhir.dstu3.model.Reference t : src.getAddresses()) tgt.addAddresses(VersionConvertor_10_30.convertReference(t));
051        for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal()) tgt.addGoal(VersionConvertor_10_30.convertReference(t));
052        for (org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent t : src.getActivity()) tgt.addActivity(convertCarePlanActivityComponent(t));
053        return tgt;
054    }
055
056    public static org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
057        if (src == null || src.isEmpty())
058            return null;
059        org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent();
060        VersionConvertor_10_30.copyElement(src, tgt);
061        for (org.hl7.fhir.dstu3.model.Annotation t : src.getProgress()) tgt.addProgress(VersionConvertor_10_30.convertAnnotation(t));
062        if (src.hasReference())
063            tgt.setReference(VersionConvertor_10_30.convertReference(src.getReference()));
064        if (src.hasDetail())
065            tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail()));
066        return tgt;
067    }
068
069    public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
070        if (src == null || src.isEmpty())
071            return null;
072        org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent();
073        VersionConvertor_10_30.copyElement(src, tgt);
074        for (org.hl7.fhir.dstu2.model.Annotation t : src.getProgress()) tgt.addProgress(VersionConvertor_10_30.convertAnnotation(t));
075        if (src.hasReference())
076            tgt.setReference(VersionConvertor_10_30.convertReference(src.getReference()));
077        if (src.hasDetail())
078            tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail()));
079        return tgt;
080    }
081
082    public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException {
083        if (src == null || src.isEmpty())
084            return null;
085        org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent();
086        VersionConvertor_10_30.copyElement(src, tgt);
087        if (src.hasCategory())
088            tgt.setCategory(VersionConvertor_10_30.convertCodeableConcept(src.getCategory()));
089        if (src.hasCode())
090            tgt.setCode(VersionConvertor_10_30.convertCodeableConcept(src.getCode()));
091        for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReasonCode()) tgt.addReasonCode(VersionConvertor_10_30.convertCodeableConcept(t));
092        for (org.hl7.fhir.dstu2.model.Reference t : src.getReasonReference()) tgt.addReasonReference(VersionConvertor_10_30.convertReference(t));
093        for (org.hl7.fhir.dstu2.model.Reference t : src.getGoal()) tgt.addGoal(VersionConvertor_10_30.convertReference(t));
094        if (src.hasStatus())
095            tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement()));
096        if (src.hasProhibitedElement())
097            tgt.setProhibitedElement(VersionConvertor_10_30.convertBoolean(src.getProhibitedElement()));
098        if (src.hasScheduled())
099            tgt.setScheduled(VersionConvertor_10_30.convertType(src.getScheduled()));
100        if (src.hasLocation())
101            tgt.setLocation(VersionConvertor_10_30.convertReference(src.getLocation()));
102        for (org.hl7.fhir.dstu2.model.Reference t : src.getPerformer()) tgt.addPerformer(VersionConvertor_10_30.convertReference(t));
103        if (src.hasProduct())
104            tgt.setProduct(VersionConvertor_10_30.convertType(src.getProduct()));
105        if (src.hasDailyAmount())
106            tgt.setDailyAmount(VersionConvertor_10_30.convertSimpleQuantity(src.getDailyAmount()));
107        if (src.hasQuantity())
108            tgt.setQuantity(VersionConvertor_10_30.convertSimpleQuantity(src.getQuantity()));
109        if (src.hasDescriptionElement())
110            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
111        return tgt;
112    }
113
114    public static org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException {
115        if (src == null || src.isEmpty())
116            return null;
117        org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent();
118        VersionConvertor_10_30.copyElement(src, tgt);
119        if (src.hasCategory())
120            tgt.setCategory(VersionConvertor_10_30.convertCodeableConcept(src.getCategory()));
121        if (src.hasCode())
122            tgt.setCode(VersionConvertor_10_30.convertCodeableConcept(src.getCode()));
123        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode()) tgt.addReasonCode(VersionConvertor_10_30.convertCodeableConcept(t));
124        for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference()) tgt.addReasonReference(VersionConvertor_10_30.convertReference(t));
125        for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal()) tgt.addGoal(VersionConvertor_10_30.convertReference(t));
126        if (src.hasStatus())
127            tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement()));
128        if (src.hasProhibitedElement())
129            tgt.setProhibitedElement(VersionConvertor_10_30.convertBoolean(src.getProhibitedElement()));
130        if (src.hasScheduled())
131            tgt.setScheduled(VersionConvertor_10_30.convertType(src.getScheduled()));
132        if (src.hasLocation())
133            tgt.setLocation(VersionConvertor_10_30.convertReference(src.getLocation()));
134        for (org.hl7.fhir.dstu3.model.Reference t : src.getPerformer()) tgt.addPerformer(VersionConvertor_10_30.convertReference(t));
135        if (src.hasProduct())
136            tgt.setProduct(VersionConvertor_10_30.convertType(src.getProduct()));
137        if (src.hasDailyAmount())
138            tgt.setDailyAmount(VersionConvertor_10_30.convertSimpleQuantity(src.getDailyAmount()));
139        if (src.hasQuantity())
140            tgt.setQuantity(VersionConvertor_10_30.convertSimpleQuantity(src.getQuantity()));
141        if (src.hasDescriptionElement())
142            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
143        return tgt;
144    }
145
146    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException {
147        if (src == null || src.isEmpty())
148            return null;
149        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatusEnumFactory());
150        VersionConvertor_10_30.copyElement(src, tgt);
151        switch(src.getValue()) {
152            case NOTSTARTED:
153                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.NOTSTARTED);
154                break;
155            case SCHEDULED:
156                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.SCHEDULED);
157                break;
158            case INPROGRESS:
159                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.INPROGRESS);
160                break;
161            case ONHOLD:
162                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.ONHOLD);
163                break;
164            case COMPLETED:
165                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.COMPLETED);
166                break;
167            case CANCELLED:
168                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.CANCELLED);
169                break;
170            default:
171                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.NULL);
172                break;
173        }
174        return tgt;
175    }
176
177    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException {
178        if (src == null || src.isEmpty())
179            return null;
180        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatusEnumFactory());
181        VersionConvertor_10_30.copyElement(src, tgt);
182        switch(src.getValue()) {
183            case NOTSTARTED:
184                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NOTSTARTED);
185                break;
186            case SCHEDULED:
187                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.SCHEDULED);
188                break;
189            case INPROGRESS:
190                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.INPROGRESS);
191                break;
192            case ONHOLD:
193                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.ONHOLD);
194                break;
195            case COMPLETED:
196                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.COMPLETED);
197                break;
198            case CANCELLED:
199                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.CANCELLED);
200                break;
201            default:
202                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NULL);
203                break;
204        }
205        return tgt;
206    }
207
208    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> convertCarePlanStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> src) throws FHIRException {
209        if (src == null || src.isEmpty())
210            return null;
211        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatusEnumFactory());
212        VersionConvertor_10_30.copyElement(src, tgt);
213        switch(src.getValue()) {
214            case DRAFT:
215                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.DRAFT);
216                break;
217            case ACTIVE:
218                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.ACTIVE);
219                break;
220            case COMPLETED:
221                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.COMPLETED);
222                break;
223            case CANCELLED:
224                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.CANCELLED);
225                break;
226            default:
227                tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.NULL);
228                break;
229        }
230        return tgt;
231    }
232
233    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> convertCarePlanStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> src) throws FHIRException {
234        if (src == null || src.isEmpty())
235            return null;
236        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatusEnumFactory());
237        VersionConvertor_10_30.copyElement(src, tgt);
238        switch(src.getValue()) {
239            case PROPOSED:
240                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.DRAFT);
241                break;
242            case DRAFT:
243                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.DRAFT);
244                break;
245            case ACTIVE:
246                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.ACTIVE);
247                break;
248            case COMPLETED:
249                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.COMPLETED);
250                break;
251            case CANCELLED:
252                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.CANCELLED);
253                break;
254            default:
255                tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.NULL);
256                break;
257        }
258        return tgt;
259    }
260}