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