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