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