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.Canonical43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_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;
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 Procedure43_50 {
043
044  public static org.hl7.fhir.r5.model.Procedure convertProcedure(org.hl7.fhir.r4b.model.Procedure src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Procedure tgt = new org.hl7.fhir.r5.model.Procedure();
048    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
051    for (org.hl7.fhir.r4b.model.CanonicalType t : src.getInstantiatesCanonical())
052      tgt.getInstantiatesCanonical().add(Canonical43_50.convertCanonical(t));
053    for (org.hl7.fhir.r4b.model.UriType t : src.getInstantiatesUri())
054      tgt.getInstantiatesUri().add(Uri43_50.convertUri(t));
055    for (org.hl7.fhir.r4b.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t));
056    for (org.hl7.fhir.r4b.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t));
057    if (src.hasStatus())
058      tgt.setStatusElement(convertProcedureStatus(src.getStatusElement()));
059    if (src.hasStatusReason())
060      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
061    if (src.hasCategory())
062      tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(src.getCategory()));
063    if (src.hasCode())
064      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
065    if (src.hasSubject())
066      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
067    if (src.hasEncounter())
068      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
069    if (src.hasPerformed())
070      tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getPerformed()));
071    if (src.hasRecorder())
072      tgt.setRecorder(Reference43_50.convertReference(src.getRecorder()));
073    if (src.hasAsserter())
074      tgt.setReported(Reference43_50.convertReference(src.getAsserter()));
075    for (org.hl7.fhir.r4b.model.Procedure.ProcedurePerformerComponent t : src.getPerformer())
076      tgt.addPerformer(convertProcedurePerformerComponent(t));
077    if (src.hasLocation())
078      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
079    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getReasonCode())
080      tgt.addReason(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t));
081    for (org.hl7.fhir.r4b.model.Reference t : src.getReasonReference())
082      tgt.addReason(Reference43_50.convertReferenceToCodeableReference(t));
083    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getBodySite())
084      tgt.addBodySite(CodeableConcept43_50.convertCodeableConcept(t));
085    if (src.hasOutcome())
086      tgt.setOutcome(CodeableConcept43_50.convertCodeableConcept(src.getOutcome()));
087    for (org.hl7.fhir.r4b.model.Reference t : src.getReport()) tgt.addReport(Reference43_50.convertReference(t));
088    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getComplication())
089      tgt.addComplication().setConcept(CodeableConcept43_50.convertCodeableConcept(t));
090    for (org.hl7.fhir.r4b.model.Reference t : src.getComplicationDetail())
091      tgt.addComplication().setReference(Reference43_50.convertReference(t));
092    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getFollowUp())
093      tgt.addFollowUp(CodeableConcept43_50.convertCodeableConcept(t));
094    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
095    for (org.hl7.fhir.r4b.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice())
096      tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
097    for (org.hl7.fhir.r4b.model.Reference t : src.getUsedReference())
098      tgt.addUsed(Reference43_50.convertReferenceToCodeableReference(t));
099    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getUsedCode())
100      tgt.addUsed(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t));
101    return tgt;
102  }
103
104  public static org.hl7.fhir.r4b.model.Procedure convertProcedure(org.hl7.fhir.r5.model.Procedure src) throws FHIRException {
105    if (src == null)
106      return null;
107    org.hl7.fhir.r4b.model.Procedure tgt = new org.hl7.fhir.r4b.model.Procedure();
108    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
109    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
110      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
111    for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical())
112      tgt.getInstantiatesCanonical().add(Canonical43_50.convertCanonical(t));
113    for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri())
114      tgt.getInstantiatesUri().add(Uri43_50.convertUri(t));
115    for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t));
116    for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference43_50.convertReference(t));
117    if (src.hasStatus())
118      tgt.setStatusElement(convertProcedureStatus(src.getStatusElement()));
119    if (src.hasStatusReason())
120      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
121    if (src.hasCategory())
122      tgt.setCategory(CodeableConcept43_50.convertCodeableConcept(src.getCategoryFirstRep()));
123    if (src.hasCode())
124      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
125    if (src.hasSubject())
126      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
127    if (src.hasEncounter())
128      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
129    if (src.hasOccurrence())
130      tgt.setPerformed(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence()));
131    if (src.hasRecorder())
132      tgt.setRecorder(Reference43_50.convertReference(src.getRecorder()));
133    if (src.hasReportedReference())
134      tgt.setAsserter(Reference43_50.convertReference(src.getReportedReference()));
135    for (org.hl7.fhir.r5.model.Procedure.ProcedurePerformerComponent t : src.getPerformer())
136      tgt.addPerformer(convertProcedurePerformerComponent(t));
137    if (src.hasLocation())
138      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
139    for (CodeableReference t : src.getReason())
140      if (t.hasConcept())
141        tgt.addReasonCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
142    for (CodeableReference t : src.getReason())
143      if (t.hasReference())
144        tgt.addReasonReference(Reference43_50.convertReference(t.getReference()));
145    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getBodySite())
146      tgt.addBodySite(CodeableConcept43_50.convertCodeableConcept(t));
147    if (src.hasOutcome())
148      tgt.setOutcome(CodeableConcept43_50.convertCodeableConcept(src.getOutcome()));
149    for (org.hl7.fhir.r5.model.Reference t : src.getReport()) tgt.addReport(Reference43_50.convertReference(t));
150    for (CodeableReference t : src.getComplication()) {
151      if (t.hasConcept()) {
152        tgt.addComplication(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
153      }
154      if (t.hasReference()) {
155        tgt.addComplicationDetail(Reference43_50.convertReference(t.getReference()));
156      }
157    }
158    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getFollowUp())
159      tgt.addFollowUp(CodeableConcept43_50.convertCodeableConcept(t));
160    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
161    for (org.hl7.fhir.r5.model.Procedure.ProcedureFocalDeviceComponent t : src.getFocalDevice())
162      tgt.addFocalDevice(convertProcedureFocalDeviceComponent(t));
163    for (CodeableReference t : src.getUsed())
164      if (t.hasReference())
165        tgt.addUsedReference(Reference43_50.convertReference(t.getReference()));
166    for (CodeableReference t : src.getUsed())
167      if (t.hasConcept())
168        tgt.addUsedCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
169    return tgt;
170  }
171
172  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> convertProcedureStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.EventStatus> src) throws FHIRException {
173    if (src == null || src.isEmpty())
174      return null;
175    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.EventStatusEnumFactory());
176    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
177    switch (src.getValue()) {
178      case PREPARATION:
179        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.PREPARATION);
180        break;
181      case INPROGRESS:
182        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.INPROGRESS);
183        break;
184      case NOTDONE:
185        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.NOTDONE);
186        break;
187      case ONHOLD:
188        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.ONHOLD);
189        break;
190      case STOPPED:
191        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.STOPPED);
192        break;
193      case COMPLETED:
194        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.COMPLETED);
195        break;
196      case ENTEREDINERROR:
197        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.ENTEREDINERROR);
198        break;
199      case UNKNOWN:
200        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.UNKNOWN);
201        break;
202      default:
203        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.NULL);
204        break;
205    }
206    return tgt;
207  }
208
209  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.EventStatus> convertProcedureStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> src) throws FHIRException {
210    if (src == null || src.isEmpty())
211      return null;
212    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.EventStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.EventStatusEnumFactory());
213    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
214    switch (src.getValue()) {
215      case PREPARATION:
216        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.PREPARATION);
217        break;
218      case INPROGRESS:
219        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.INPROGRESS);
220        break;
221      case NOTDONE:
222        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.NOTDONE);
223        break;
224      case ONHOLD:
225        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.ONHOLD);
226        break;
227      case STOPPED:
228        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.STOPPED);
229        break;
230      case COMPLETED:
231        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.COMPLETED);
232        break;
233      case ENTEREDINERROR:
234        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.ENTEREDINERROR);
235        break;
236      case UNKNOWN:
237        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.UNKNOWN);
238        break;
239      default:
240        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.EventStatus.NULL);
241        break;
242    }
243    return tgt;
244  }
245
246  public static org.hl7.fhir.r5.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.r4b.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
247    if (src == null)
248      return null;
249    org.hl7.fhir.r5.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.r5.model.Procedure.ProcedurePerformerComponent();
250    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
251    if (src.hasFunction())
252      tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction()));
253    if (src.hasActor())
254      tgt.setActor(Reference43_50.convertReference(src.getActor()));
255    if (src.hasOnBehalfOf())
256      tgt.setOnBehalfOf(Reference43_50.convertReference(src.getOnBehalfOf()));
257    return tgt;
258  }
259
260  public static org.hl7.fhir.r4b.model.Procedure.ProcedurePerformerComponent convertProcedurePerformerComponent(org.hl7.fhir.r5.model.Procedure.ProcedurePerformerComponent src) throws FHIRException {
261    if (src == null)
262      return null;
263    org.hl7.fhir.r4b.model.Procedure.ProcedurePerformerComponent tgt = new org.hl7.fhir.r4b.model.Procedure.ProcedurePerformerComponent();
264    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
265    if (src.hasFunction())
266      tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction()));
267    if (src.hasActor())
268      tgt.setActor(Reference43_50.convertReference(src.getActor()));
269    if (src.hasOnBehalfOf())
270      tgt.setOnBehalfOf(Reference43_50.convertReference(src.getOnBehalfOf()));
271    return tgt;
272  }
273
274  public static org.hl7.fhir.r5.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.r4b.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
275    if (src == null)
276      return null;
277    org.hl7.fhir.r5.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r5.model.Procedure.ProcedureFocalDeviceComponent();
278    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
279    if (src.hasAction())
280      tgt.setAction(CodeableConcept43_50.convertCodeableConcept(src.getAction()));
281    if (src.hasManipulated())
282      tgt.setManipulated(Reference43_50.convertReference(src.getManipulated()));
283    return tgt;
284  }
285
286  public static org.hl7.fhir.r4b.model.Procedure.ProcedureFocalDeviceComponent convertProcedureFocalDeviceComponent(org.hl7.fhir.r5.model.Procedure.ProcedureFocalDeviceComponent src) throws FHIRException {
287    if (src == null)
288      return null;
289    org.hl7.fhir.r4b.model.Procedure.ProcedureFocalDeviceComponent tgt = new org.hl7.fhir.r4b.model.Procedure.ProcedureFocalDeviceComponent();
290    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
291    if (src.hasAction())
292      tgt.setAction(CodeableConcept43_50.convertCodeableConcept(src.getAction()));
293    if (src.hasManipulated())
294      tgt.setManipulated(Reference43_50.convertReference(src.getManipulated()));
295    return tgt;
296  }
297}