
001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Date30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 010import org.hl7.fhir.exceptions.FHIRException; 011import org.hl7.fhir.r4.model.Enumeration; 012import org.hl7.fhir.r4.model.Goal; 013 014public class Goal30_40 { 015 016 public static org.hl7.fhir.dstu3.model.Goal convertGoal(org.hl7.fhir.r4.model.Goal src) throws FHIRException { 017 if (src == null) 018 return null; 019 org.hl7.fhir.dstu3.model.Goal tgt = new org.hl7.fhir.dstu3.model.Goal(); 020 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 021 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 022 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 023 if (src.hasLifecycleStatus()) 024 tgt.setStatusElement(convertGoalStatus(src.getLifecycleStatusElement())); 025 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory()) 026 tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t)); 027 if (src.hasPriority()) 028 tgt.setPriority(CodeableConcept30_40.convertCodeableConcept(src.getPriority())); 029 if (src.hasDescription()) 030 tgt.setDescription(CodeableConcept30_40.convertCodeableConcept(src.getDescription())); 031 if (src.hasSubject()) 032 tgt.setSubject(Reference30_40.convertReference(src.getSubject())); 033 if (src.hasStart()) 034 tgt.setStart(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getStart())); 035 if (src.hasTarget()) 036 tgt.setTarget(convertGoalTargetComponent(src.getTargetFirstRep())); 037 if (src.hasStatusDate()) 038 tgt.setStatusDateElement(Date30_40.convertDate(src.getStatusDateElement())); 039 if (src.hasStatusReason()) 040 tgt.setStatusReasonElement(String30_40.convertString(src.getStatusReasonElement())); 041 if (src.hasExpressedBy()) 042 tgt.setExpressedBy(Reference30_40.convertReference(src.getExpressedBy())); 043 for (org.hl7.fhir.r4.model.Reference t : src.getAddresses()) tgt.addAddresses(Reference30_40.convertReference(t)); 044 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t)); 045 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOutcomeCode()) 046 tgt.addOutcomeCode(CodeableConcept30_40.convertCodeableConcept(t)); 047 for (org.hl7.fhir.r4.model.Reference t : src.getOutcomeReference()) 048 tgt.addOutcomeReference(Reference30_40.convertReference(t)); 049 return tgt; 050 } 051 052 public static org.hl7.fhir.r4.model.Goal convertGoal(org.hl7.fhir.dstu3.model.Goal src) throws FHIRException { 053 if (src == null) 054 return null; 055 org.hl7.fhir.r4.model.Goal tgt = new org.hl7.fhir.r4.model.Goal(); 056 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 057 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 058 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 059 if (src.hasStatus()) 060 tgt.setLifecycleStatusElement(convertGoalStatus(src.getStatusElement())); 061 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory()) 062 tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t)); 063 if (src.hasPriority()) 064 tgt.setPriority(CodeableConcept30_40.convertCodeableConcept(src.getPriority())); 065 if (src.hasDescription()) 066 tgt.setDescription(CodeableConcept30_40.convertCodeableConcept(src.getDescription())); 067 if (src.hasSubject()) 068 tgt.setSubject(Reference30_40.convertReference(src.getSubject())); 069 if (src.hasStart()) 070 tgt.setStart(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getStart())); 071 if (src.hasTarget()) 072 tgt.addTarget(convertGoalTargetComponent(src.getTarget())); 073 if (src.hasStatusDate()) 074 tgt.setStatusDateElement(Date30_40.convertDate(src.getStatusDateElement())); 075 if (src.hasStatusReason()) 076 tgt.setStatusReasonElement(String30_40.convertString(src.getStatusReasonElement())); 077 if (src.hasExpressedBy()) 078 tgt.setExpressedBy(Reference30_40.convertReference(src.getExpressedBy())); 079 for (org.hl7.fhir.dstu3.model.Reference t : src.getAddresses()) 080 tgt.addAddresses(Reference30_40.convertReference(t)); 081 for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t)); 082 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getOutcomeCode()) 083 tgt.addOutcomeCode(CodeableConcept30_40.convertCodeableConcept(t)); 084 for (org.hl7.fhir.dstu3.model.Reference t : src.getOutcomeReference()) 085 tgt.addOutcomeReference(Reference30_40.convertReference(t)); 086 return tgt; 087 } 088 089 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Goal.GoalLifecycleStatus> convertGoalStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Goal.GoalStatus> src) throws FHIRException { 090 if (src == null || src.isEmpty()) 091 return null; 092 Enumeration<Goal.GoalLifecycleStatus> tgt = new Enumeration<>(new Goal.GoalLifecycleStatusEnumFactory()); 093 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 094 if (src.getValue() == null) { 095 tgt.setValue(null); 096 } else { 097 switch (src.getValue()) { 098 case PROPOSED: 099 tgt.setValue(Goal.GoalLifecycleStatus.PROPOSED); 100 break; 101 case ACCEPTED: 102 tgt.setValue(Goal.GoalLifecycleStatus.ACCEPTED); 103 break; 104 case PLANNED: 105 tgt.setValue(Goal.GoalLifecycleStatus.PLANNED); 106 break; 107 case INPROGRESS: 108 tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE); 109 break; 110 case ONTARGET: 111 tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE); 112 break; 113 case AHEADOFTARGET: 114 tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE); 115 break; 116 case BEHINDTARGET: 117 tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE); 118 break; 119 case SUSTAINING: 120 tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE); 121 break; 122 case ACHIEVED: 123 tgt.setValue(Goal.GoalLifecycleStatus.COMPLETED); 124 break; 125 case ONHOLD: 126 tgt.setValue(Goal.GoalLifecycleStatus.ONHOLD); 127 break; 128 case CANCELLED: 129 tgt.setValue(Goal.GoalLifecycleStatus.CANCELLED); 130 break; 131 case ENTEREDINERROR: 132 tgt.setValue(Goal.GoalLifecycleStatus.ENTEREDINERROR); 133 break; 134 case REJECTED: 135 tgt.setValue(Goal.GoalLifecycleStatus.REJECTED); 136 break; 137 default: 138 tgt.setValue(Goal.GoalLifecycleStatus.NULL); 139 break; 140 } 141 } 142 return tgt; 143 } 144 145 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Goal.GoalStatus> convertGoalStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Goal.GoalLifecycleStatus> src) throws FHIRException { 146 if (src == null || src.isEmpty()) 147 return null; 148 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Goal.GoalStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Goal.GoalStatusEnumFactory()); 149 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 150 if (src.getValue() == null) { 151 tgt.setValue(null); 152 } else { 153 switch (src.getValue()) { 154 case PROPOSED: 155 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.PROPOSED); 156 break; 157 case ACCEPTED: 158 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.ACCEPTED); 159 break; 160 case PLANNED: 161 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.PLANNED); 162 break; 163 case ACTIVE: 164 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.INPROGRESS); 165 break; 166 case COMPLETED: 167 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.ACHIEVED); 168 break; 169 case ONHOLD: 170 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.ONHOLD); 171 break; 172 case CANCELLED: 173 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.CANCELLED); 174 break; 175 case ENTEREDINERROR: 176 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.ENTEREDINERROR); 177 break; 178 case REJECTED: 179 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.REJECTED); 180 break; 181 default: 182 tgt.setValue(org.hl7.fhir.dstu3.model.Goal.GoalStatus.NULL); 183 break; 184 } 185 } 186 return tgt; 187 } 188 189 public static org.hl7.fhir.r4.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent src) throws FHIRException { 190 if (src == null) 191 return null; 192 org.hl7.fhir.r4.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.r4.model.Goal.GoalTargetComponent(); 193 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 194 if (src.hasMeasure()) 195 tgt.setMeasure(CodeableConcept30_40.convertCodeableConcept(src.getMeasure())); 196 if (src.hasDetail()) 197 tgt.setDetail(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDetail())); 198 if (src.hasDue()) 199 tgt.setDue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDue())); 200 return tgt; 201 } 202 203 public static org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.r4.model.Goal.GoalTargetComponent src) throws FHIRException { 204 if (src == null) 205 return null; 206 org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.dstu3.model.Goal.GoalTargetComponent(); 207 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 208 if (src.hasMeasure()) 209 tgt.setMeasure(CodeableConcept30_40.convertCodeableConcept(src.getMeasure())); 210 if (src.hasDetail()) 211 tgt.setDetail(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDetail())); 212 if (src.hasDue()) 213 tgt.setDue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDue())); 214 return tgt; 215 } 216}