001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Period30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
010import org.hl7.fhir.dstu3.model.CareTeam;
011import org.hl7.fhir.dstu3.model.Enumeration;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class CareTeam30_40 {
015
016  public static org.hl7.fhir.dstu3.model.CareTeam convertCareTeam(org.hl7.fhir.r4.model.CareTeam src) throws FHIRException {
017    if (src == null)
018      return null;
019    org.hl7.fhir.dstu3.model.CareTeam tgt = new org.hl7.fhir.dstu3.model.CareTeam();
020    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
021    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
023    if (src.hasStatus())
024      tgt.setStatusElement(convertCareTeamStatus(src.getStatusElement()));
025    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
026      tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t));
027    if (src.hasName())
028      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
029    if (src.hasSubject())
030      tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
031    if (src.hasEncounter())
032      tgt.setContext(Reference30_40.convertReference(src.getEncounter()));
033    if (src.hasPeriod())
034      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
035    for (org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
036      tgt.addParticipant(convertCareTeamParticipantComponent(t));
037    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
038      tgt.addReasonCode(CodeableConcept30_40.convertCodeableConcept(t));
039    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
040      tgt.addReasonReference(Reference30_40.convertReference(t));
041    for (org.hl7.fhir.r4.model.Reference t : src.getManagingOrganization())
042      tgt.addManagingOrganization(Reference30_40.convertReference(t));
043    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
044    return tgt;
045  }
046
047  public static org.hl7.fhir.r4.model.CareTeam convertCareTeam(org.hl7.fhir.dstu3.model.CareTeam src) throws FHIRException {
048    if (src == null)
049      return null;
050    org.hl7.fhir.r4.model.CareTeam tgt = new org.hl7.fhir.r4.model.CareTeam();
051    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
052    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
053      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
054    if (src.hasStatus())
055      tgt.setStatusElement(convertCareTeamStatus(src.getStatusElement()));
056    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory())
057      tgt.addCategory(CodeableConcept30_40.convertCodeableConcept(t));
058    if (src.hasName())
059      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
060    if (src.hasSubject())
061      tgt.setSubject(Reference30_40.convertReference(src.getSubject()));
062    if (src.hasContext())
063      tgt.setEncounter(Reference30_40.convertReference(src.getContext()));
064    if (src.hasPeriod())
065      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
066    for (org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent t : src.getParticipant())
067      tgt.addParticipant(convertCareTeamParticipantComponent(t));
068    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
069      tgt.addReasonCode(CodeableConcept30_40.convertCodeableConcept(t));
070    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
071      tgt.addReasonReference(Reference30_40.convertReference(t));
072    for (org.hl7.fhir.dstu3.model.Reference t : src.getManagingOrganization())
073      tgt.addManagingOrganization(Reference30_40.convertReference(t));
074    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_40.convertAnnotation(t));
075    return tgt;
076  }
077
078  public static org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
079    if (src == null)
080      return null;
081    org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent();
082    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
083    if (src.hasRole())
084      tgt.setRole(CodeableConcept30_40.convertCodeableConcept(src.getRoleFirstRep()));
085    if (src.hasMember())
086      tgt.setMember(Reference30_40.convertReference(src.getMember()));
087    if (src.hasOnBehalfOf())
088      tgt.setOnBehalfOf(Reference30_40.convertReference(src.getOnBehalfOf()));
089    if (src.hasPeriod())
090      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
091    return tgt;
092  }
093
094  public static org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent convertCareTeamParticipantComponent(org.hl7.fhir.dstu3.model.CareTeam.CareTeamParticipantComponent src) throws FHIRException {
095    if (src == null)
096      return null;
097    org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent tgt = new org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent();
098    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
099    if (src.hasRole())
100      tgt.addRole(CodeableConcept30_40.convertCodeableConcept(src.getRole()));
101    if (src.hasMember())
102      tgt.setMember(Reference30_40.convertReference(src.getMember()));
103    if (src.hasOnBehalfOf())
104      tgt.setOnBehalfOf(Reference30_40.convertReference(src.getOnBehalfOf()));
105    if (src.hasPeriod())
106      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
107    return tgt;
108  }
109
110  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus> convertCareTeamStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CareTeam.CareTeamStatus> src) throws FHIRException {
111      if (src == null || src.isEmpty())
112          return null;
113      Enumeration<CareTeam.CareTeamStatus> tgt = new Enumeration<>(new CareTeam.CareTeamStatusEnumFactory());
114      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
115      if (src.getValue() == null) {
116          tgt.setValue(null);
117      } else {
118          switch (src.getValue()) {
119              case PROPOSED:
120                  tgt.setValue(CareTeam.CareTeamStatus.PROPOSED);
121                  break;
122              case ACTIVE:
123                  tgt.setValue(CareTeam.CareTeamStatus.ACTIVE);
124                  break;
125              case SUSPENDED:
126                  tgt.setValue(CareTeam.CareTeamStatus.SUSPENDED);
127                  break;
128              case INACTIVE:
129                  tgt.setValue(CareTeam.CareTeamStatus.INACTIVE);
130                  break;
131              case ENTEREDINERROR:
132                  tgt.setValue(CareTeam.CareTeamStatus.ENTEREDINERROR);
133                  break;
134              default:
135                  tgt.setValue(CareTeam.CareTeamStatus.NULL);
136                  break;
137          }
138      }
139      return tgt;
140  }
141
142  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CareTeam.CareTeamStatus> convertCareTeamStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CareTeam.CareTeamStatus> src) throws FHIRException {
143      if (src == null || src.isEmpty())
144          return null;
145      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());
146      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
147      if (src.getValue() == null) {
148          tgt.setValue(null);
149      } else {
150          switch (src.getValue()) {
151              case PROPOSED:
152                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.PROPOSED);
153                  break;
154              case ACTIVE:
155                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.ACTIVE);
156                  break;
157              case SUSPENDED:
158                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.SUSPENDED);
159                  break;
160              case INACTIVE:
161                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.INACTIVE);
162                  break;
163              case ENTEREDINERROR:
164                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.ENTEREDINERROR);
165                  break;
166              default:
167                  tgt.setValue(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus.NULL);
168                  break;
169          }
170      }
171      return tgt;
172  }
173}