001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Annotation43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Date43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.model.CodeableReference;
012import org.hl7.fhir.r5.model.Enumeration;
013import org.hl7.fhir.r5.model.Goal;
014
015/*
016  Copyright (c) 2011+, HL7, Inc.
017  All rights reserved.
018  
019  Redistribution and use in source and binary forms, with or without modification, 
020  are permitted provided that the following conditions are met:
021  
022   * Redistributions of source code must retain the above copyright notice, this 
023     list of conditions and the following disclaimer.
024   * Redistributions in binary form must reproduce the above copyright notice, 
025     this list of conditions and the following disclaimer in the documentation 
026     and/or other materials provided with the distribution.
027   * Neither the name of HL7 nor the names of its contributors may be used to 
028     endorse or promote products derived from this software without specific 
029     prior written permission.
030  
031  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
032  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
033  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
034  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
035  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
036  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
037  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
038  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
039  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
040  POSSIBILITY OF SUCH DAMAGE.
041  
042*/
043// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
044public class Goal43_50 {
045
046  public static org.hl7.fhir.r5.model.Goal convertGoal(org.hl7.fhir.r4b.model.Goal src) throws FHIRException {
047    if (src == null)
048      return null;
049    org.hl7.fhir.r5.model.Goal tgt = new org.hl7.fhir.r5.model.Goal();
050    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
051    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
052      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
053    if (src.hasLifecycleStatus())
054      tgt.setLifecycleStatusElement(convertGoalLifecycleStatus(src.getLifecycleStatusElement()));
055    if (src.hasAchievementStatus())
056      tgt.setAchievementStatus(CodeableConcept43_50.convertCodeableConcept(src.getAchievementStatus()));
057    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCategory())
058      tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t));
059    if (src.hasPriority())
060      tgt.setPriority(CodeableConcept43_50.convertCodeableConcept(src.getPriority()));
061    if (src.hasDescription())
062      tgt.setDescription(CodeableConcept43_50.convertCodeableConcept(src.getDescription()));
063    if (src.hasSubject())
064      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
065    if (src.hasStart())
066      tgt.setStart(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getStart()));
067    for (org.hl7.fhir.r4b.model.Goal.GoalTargetComponent t : src.getTarget())
068      tgt.addTarget(convertGoalTargetComponent(t));
069    if (src.hasStatusDate())
070      tgt.setStatusDateElement(Date43_50.convertDate(src.getStatusDateElement()));
071    if (src.hasStatusReason())
072      tgt.setStatusReasonElement(String43_50.convertString(src.getStatusReasonElement()));
073    for (org.hl7.fhir.r4b.model.Reference t : src.getAddresses()) tgt.addAddresses(Reference43_50.convertReference(t));
074    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
075    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getOutcomeCode())
076      tgt.addOutcome(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t));
077    for (org.hl7.fhir.r4b.model.Reference t : src.getOutcomeReference())
078      tgt.addOutcome(Reference43_50.convertReferenceToCodeableReference(t));
079    return tgt;
080  }
081
082  public static org.hl7.fhir.r4b.model.Goal convertGoal(org.hl7.fhir.r5.model.Goal src) throws FHIRException {
083    if (src == null)
084      return null;
085    org.hl7.fhir.r4b.model.Goal tgt = new org.hl7.fhir.r4b.model.Goal();
086    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
087    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
088      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
089    if (src.hasLifecycleStatus())
090      tgt.setLifecycleStatusElement(convertGoalLifecycleStatus(src.getLifecycleStatusElement()));
091    if (src.hasAchievementStatus())
092      tgt.setAchievementStatus(CodeableConcept43_50.convertCodeableConcept(src.getAchievementStatus()));
093    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
094      tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t));
095    if (src.hasPriority())
096      tgt.setPriority(CodeableConcept43_50.convertCodeableConcept(src.getPriority()));
097    if (src.hasDescription())
098      tgt.setDescription(CodeableConcept43_50.convertCodeableConcept(src.getDescription()));
099    if (src.hasSubject())
100      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
101    if (src.hasStart())
102      tgt.setStart(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getStart()));
103    for (org.hl7.fhir.r5.model.Goal.GoalTargetComponent t : src.getTarget())
104      tgt.addTarget(convertGoalTargetComponent(t));
105    if (src.hasStatusDate())
106      tgt.setStatusDateElement(Date43_50.convertDate(src.getStatusDateElement()));
107    if (src.hasStatusReason())
108      tgt.setStatusReasonElement(String43_50.convertString(src.getStatusReasonElement()));
109    for (org.hl7.fhir.r5.model.Reference t : src.getAddresses()) tgt.addAddresses(Reference43_50.convertReference(t));
110    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
111    for (CodeableReference t : src.getOutcome())
112      if (t.hasConcept())
113        tgt.addOutcomeCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
114    for (CodeableReference t : src.getOutcome())
115      if (t.hasReference())
116        tgt.addOutcomeReference(Reference43_50.convertReference(t.getReference()));
117    return tgt;
118  }
119
120  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Goal.GoalLifecycleStatus> convertGoalLifecycleStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus> src) throws FHIRException {
121      if (src == null || src.isEmpty())
122          return null;
123      Enumeration<Goal.GoalLifecycleStatus> tgt = new Enumeration<>(new Goal.GoalLifecycleStatusEnumFactory());
124      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
125      if (src.getValue() == null) {
126          tgt.setValue(null);
127      } else {
128          switch (src.getValue()) {
129              case PROPOSED:
130                  tgt.setValue(Goal.GoalLifecycleStatus.PROPOSED);
131                  break;
132              case PLANNED:
133                  tgt.setValue(Goal.GoalLifecycleStatus.PLANNED);
134                  break;
135              case ACCEPTED:
136                  tgt.setValue(Goal.GoalLifecycleStatus.ACCEPTED);
137                  break;
138              case ACTIVE:
139                  tgt.setValue(Goal.GoalLifecycleStatus.ACTIVE);
140                  break;
141              case ONHOLD:
142                  tgt.setValue(Goal.GoalLifecycleStatus.ONHOLD);
143                  break;
144              case COMPLETED:
145                  tgt.setValue(Goal.GoalLifecycleStatus.COMPLETED);
146                  break;
147              case CANCELLED:
148                  tgt.setValue(Goal.GoalLifecycleStatus.CANCELLED);
149                  break;
150              case ENTEREDINERROR:
151                  tgt.setValue(Goal.GoalLifecycleStatus.ENTEREDINERROR);
152                  break;
153              case REJECTED:
154                  tgt.setValue(Goal.GoalLifecycleStatus.REJECTED);
155                  break;
156              default:
157                  tgt.setValue(Goal.GoalLifecycleStatus.NULL);
158                  break;
159          }
160      }
161      return tgt;
162  }
163
164  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus> convertGoalLifecycleStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Goal.GoalLifecycleStatus> src) throws FHIRException {
165      if (src == null || src.isEmpty())
166          return null;
167      org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatusEnumFactory());
168      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
169      if (src.getValue() == null) {
170          tgt.setValue(null);
171      } else {
172          switch (src.getValue()) {
173              case PROPOSED:
174                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.PROPOSED);
175                  break;
176              case PLANNED:
177                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.PLANNED);
178                  break;
179              case ACCEPTED:
180                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.ACCEPTED);
181                  break;
182              case ACTIVE:
183                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.ACTIVE);
184                  break;
185              case ONHOLD:
186                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.ONHOLD);
187                  break;
188              case COMPLETED:
189                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.COMPLETED);
190                  break;
191              case CANCELLED:
192                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.CANCELLED);
193                  break;
194              case ENTEREDINERROR:
195                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.ENTEREDINERROR);
196                  break;
197              case REJECTED:
198                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.REJECTED);
199                  break;
200              default:
201                  tgt.setValue(org.hl7.fhir.r4b.model.Goal.GoalLifecycleStatus.NULL);
202                  break;
203          }
204      }
205      return tgt;
206  }
207
208  public static org.hl7.fhir.r5.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.r4b.model.Goal.GoalTargetComponent src) throws FHIRException {
209    if (src == null)
210      return null;
211    org.hl7.fhir.r5.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.r5.model.Goal.GoalTargetComponent();
212    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
213    if (src.hasMeasure())
214      tgt.setMeasure(CodeableConcept43_50.convertCodeableConcept(src.getMeasure()));
215    if (src.hasDetail())
216      tgt.setDetail(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDetail()));
217    if (src.hasDue())
218      tgt.setDue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDue()));
219    return tgt;
220  }
221
222  public static org.hl7.fhir.r4b.model.Goal.GoalTargetComponent convertGoalTargetComponent(org.hl7.fhir.r5.model.Goal.GoalTargetComponent src) throws FHIRException {
223    if (src == null)
224      return null;
225    org.hl7.fhir.r4b.model.Goal.GoalTargetComponent tgt = new org.hl7.fhir.r4b.model.Goal.GoalTargetComponent();
226    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
227    if (src.hasMeasure())
228      tgt.setMeasure(CodeableConcept43_50.convertCodeableConcept(src.getMeasure()));
229    if (src.hasDetail())
230      tgt.setDetail(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDetail()));
231    if (src.hasDue())
232      tgt.setDue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDue()));
233    return tgt;
234  }
235}