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.ContactPoint43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r5.model.CodeableReference;
013
014/*
015  Copyright (c) 2011+, HL7, Inc.
016  All rights reserved.
017  
018  Redistribution and use in source and binary forms, with or without modification, 
019  are permitted provided that the following conditions are met:
020  
021   * Redistributions of source code must retain the above copyright notice, this 
022     list of conditions and the following disclaimer.
023   * Redistributions in binary form must reproduce the above copyright notice, 
024     this list of conditions and the following disclaimer in the documentation 
025     and/or other materials provided with the distribution.
026   * Neither the name of HL7 nor the names of its contributors may be used to 
027     endorse or promote products derived from this software without specific 
028     prior written permission.
029  
030  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
031  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
032  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
033  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
034  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
035  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
036  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
037  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
038  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
039  POSSIBILITY OF SUCH DAMAGE.
040  
041*/
042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
043public class CareTeam43_50 {
044
045  public static org.hl7.fhir.r5.model.CareTeam convertCareTeam(org.hl7.fhir.r4b.model.CareTeam src) throws FHIRException {
046    if (src == null)
047      return null;
048    org.hl7.fhir.r5.model.CareTeam tgt = new org.hl7.fhir.r5.model.CareTeam();
049    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
050    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
051      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
052    if (src.hasStatus())
053      tgt.setStatusElement(convertCareTeamStatus(src.getStatusElement()));
054    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCategory())
055      tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t));
056    if (src.hasName())
057      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
058    if (src.hasSubject())
059      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
060    if (src.hasPeriod())
061      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
062    for (org.hl7.fhir.r4b.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
063      tgt.addParticipant(convertCareTeamParticipantComponent(t));
064    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getReasonCode())
065      tgt.addReason(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t));
066    for (org.hl7.fhir.r4b.model.Reference t : src.getReasonReference())
067      tgt.addReason(Reference43_50.convertReferenceToCodeableReference(t));
068    for (org.hl7.fhir.r4b.model.Reference t : src.getManagingOrganization())
069      tgt.addManagingOrganization(Reference43_50.convertReference(t));
070    for (org.hl7.fhir.r4b.model.ContactPoint t : src.getTelecom())
071      tgt.addTelecom(ContactPoint43_50.convertContactPoint(t));
072    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
073    return tgt;
074  }
075
076  public static org.hl7.fhir.r4b.model.CareTeam convertCareTeam(org.hl7.fhir.r5.model.CareTeam src) throws FHIRException {
077    if (src == null)
078      return null;
079    org.hl7.fhir.r4b.model.CareTeam tgt = new org.hl7.fhir.r4b.model.CareTeam();
080    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
081    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
082      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
083    if (src.hasStatus())
084      tgt.setStatusElement(convertCareTeamStatus(src.getStatusElement()));
085    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
086      tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t));
087    if (src.hasName())
088      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
089    if (src.hasSubject())
090      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
091    if (src.hasPeriod())
092      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
093    for (org.hl7.fhir.r5.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
094      tgt.addParticipant(convertCareTeamParticipantComponent(t));
095    for (CodeableReference t : src.getReason())
096      if (t.hasConcept())
097        tgt.addReasonCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
098    for (CodeableReference t : src.getReason())
099      if (t.hasReference())
100        tgt.addReasonReference(Reference43_50.convertReference(t.getReference()));
101    for (org.hl7.fhir.r5.model.Reference t : src.getManagingOrganization())
102      tgt.addManagingOrganization(Reference43_50.convertReference(t));
103    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
104      tgt.addTelecom(ContactPoint43_50.convertContactPoint(t));
105    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
106    return tgt;
107  }
108
109  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CareTeam.CareTeamStatus> convertCareTeamStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus> src) throws FHIRException {
110    if (src == null || src.isEmpty())
111      return null;
112    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CareTeam.CareTeamStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CareTeam.CareTeamStatusEnumFactory());
113    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
114    switch (src.getValue()) {
115      case PROPOSED:
116        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.PROPOSED);
117        break;
118      case ACTIVE:
119        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.ACTIVE);
120        break;
121      case SUSPENDED:
122        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.SUSPENDED);
123        break;
124      case INACTIVE:
125        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.INACTIVE);
126        break;
127      case ENTEREDINERROR:
128        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.ENTEREDINERROR);
129        break;
130      default:
131        tgt.setValue(org.hl7.fhir.r5.model.CareTeam.CareTeamStatus.NULL);
132        break;
133    }
134    return tgt;
135  }
136
137  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus> convertCareTeamStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CareTeam.CareTeamStatus> src) throws FHIRException {
138    if (src == null || src.isEmpty())
139      return null;
140    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.CareTeam.CareTeamStatusEnumFactory());
141    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
142    switch (src.getValue()) {
143      case PROPOSED:
144        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.PROPOSED);
145        break;
146      case ACTIVE:
147        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.ACTIVE);
148        break;
149      case SUSPENDED:
150        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.SUSPENDED);
151        break;
152      case INACTIVE:
153        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.INACTIVE);
154        break;
155      case ENTEREDINERROR:
156        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.ENTEREDINERROR);
157        break;
158      default:
159        tgt.setValue(org.hl7.fhir.r4b.model.CareTeam.CareTeamStatus.NULL);
160        break;
161    }
162    return tgt;
163  }
164
165  public static org.hl7.fhir.r5.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.r4b.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
166    if (src == null)
167      return null;
168    org.hl7.fhir.r5.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.r5.model.CareTeam.CareTeamParticipantComponent();
169    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
170    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getRole())
171      tgt.setRole(CodeableConcept43_50.convertCodeableConcept(t));
172    if (src.hasMember())
173      tgt.setMember(Reference43_50.convertReference(src.getMember()));
174    if (src.hasOnBehalfOf())
175      tgt.setOnBehalfOf(Reference43_50.convertReference(src.getOnBehalfOf()));
176    if (src.hasPeriod())
177      tgt.setCoverage(Period43_50.convertPeriod(src.getPeriod()));
178    return tgt;
179  }
180
181  public static org.hl7.fhir.r4b.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.r5.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
182    if (src == null)
183      return null;
184    org.hl7.fhir.r4b.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.r4b.model.CareTeam.CareTeamParticipantComponent();
185    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
186    if (src.hasRole())
187      tgt.addRole(CodeableConcept43_50.convertCodeableConcept(src.getRole()));
188    if (src.hasMember())
189      tgt.setMember(Reference43_50.convertReference(src.getMember()));
190    if (src.hasOnBehalfOf())
191      tgt.setOnBehalfOf(Reference43_50.convertReference(src.getOnBehalfOf()));
192    if (src.hasCoveragePeriod())
193      tgt.setPeriod(Period43_50.convertPeriod(src.getCoveragePeriod()));
194    return tgt;
195  }
196}