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