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