001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.PositiveInt30_50;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class EpisodeOfCare30_50 {
012
013  public static org.hl7.fhir.dstu3.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.r5.model.EpisodeOfCare src) throws FHIRException {
014    if (src == null)
015      return null;
016    org.hl7.fhir.dstu3.model.EpisodeOfCare tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare();
017    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
018    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
019      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
020    if (src.hasStatus())
021      tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement()));
022    for (org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory())
023      tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t));
024    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType())
025      tgt.addType(CodeableConcept30_50.convertCodeableConcept(t));
026    for (org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis())
027      tgt.addDiagnosis(convertDiagnosisComponent(t));
028    if (src.hasPatient())
029      tgt.setPatient(Reference30_50.convertReference(src.getPatient()));
030    if (src.hasManagingOrganization())
031      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
032    if (src.hasPeriod())
033      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
034    for (org.hl7.fhir.r5.model.Reference t : src.getReferralRequest())
035      tgt.addReferralRequest(Reference30_50.convertReference(t));
036    if (src.hasCareManager())
037      tgt.setCareManager(Reference30_50.convertReference(src.getCareManager()));
038    for (org.hl7.fhir.r5.model.Reference t : src.getTeam()) tgt.addTeam(Reference30_50.convertReference(t));
039    for (org.hl7.fhir.r5.model.Reference t : src.getAccount()) tgt.addAccount(Reference30_50.convertReference(t));
040    return tgt;
041  }
042
043  public static org.hl7.fhir.r5.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.dstu3.model.EpisodeOfCare src) throws FHIRException {
044    if (src == null)
045      return null;
046    org.hl7.fhir.r5.model.EpisodeOfCare tgt = new org.hl7.fhir.r5.model.EpisodeOfCare();
047    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
048    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
049      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
050    if (src.hasStatus())
051      tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement()));
052    for (org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory())
053      tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t));
054    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType())
055      tgt.addType(CodeableConcept30_50.convertCodeableConcept(t));
056    for (org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis())
057      tgt.addDiagnosis(convertDiagnosisComponent(t));
058    if (src.hasPatient())
059      tgt.setPatient(Reference30_50.convertReference(src.getPatient()));
060    if (src.hasManagingOrganization())
061      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
062    if (src.hasPeriod())
063      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
064    for (org.hl7.fhir.dstu3.model.Reference t : src.getReferralRequest())
065      tgt.addReferralRequest(Reference30_50.convertReference(t));
066    if (src.hasCareManager())
067      tgt.setCareManager(Reference30_50.convertReference(src.getCareManager()));
068    for (org.hl7.fhir.dstu3.model.Reference t : src.getTeam()) tgt.addTeam(Reference30_50.convertReference(t));
069    for (org.hl7.fhir.dstu3.model.Reference t : src.getAccount()) tgt.addAccount(Reference30_50.convertReference(t));
070    return tgt;
071  }
072
073  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException {
074    if (src == null || src.isEmpty())
075      return null;
076    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusEnumFactory());
077    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
078    switch (src.getValue()) {
079      case PLANNED:
080        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED);
081        break;
082      case WAITLIST:
083        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST);
084        break;
085      case ACTIVE:
086        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE);
087        break;
088      case ONHOLD:
089        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD);
090        break;
091      case FINISHED:
092        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED);
093        break;
094      case CANCELLED:
095        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED);
096        break;
097      case ENTEREDINERROR:
098        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR);
099        break;
100      default:
101        tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.NULL);
102        break;
103    }
104    return tgt;
105  }
106
107  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException {
108    if (src == null || src.isEmpty())
109      return null;
110    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusEnumFactory());
111    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
112    switch (src.getValue()) {
113      case PLANNED:
114        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED);
115        break;
116      case WAITLIST:
117        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST);
118        break;
119      case ACTIVE:
120        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE);
121        break;
122      case ONHOLD:
123        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD);
124        break;
125      case FINISHED:
126        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED);
127        break;
128      case CANCELLED:
129        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED);
130        break;
131      case ENTEREDINERROR:
132        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR);
133        break;
134      default:
135        tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.NULL);
136        break;
137    }
138    return tgt;
139  }
140
141  public static org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException {
142    if (src == null)
143      return null;
144    org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent();
145    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
146    if (src.hasStatus())
147      tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement()));
148    if (src.hasPeriod())
149      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
150    return tgt;
151  }
152
153  public static org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException {
154    if (src == null)
155      return null;
156    org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent();
157    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
158    if (src.hasStatus())
159      tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement()));
160    if (src.hasPeriod())
161      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
162    return tgt;
163  }
164
165  public static org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException {
166    if (src == null) return null;
167    org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent();
168    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
169    if (src.hasCondition()) tgt.setCondition(Reference30_50.convertReference(src.getCondition()));
170    if (src.hasRole()) tgt.setRole(CodeableConcept30_50.convertCodeableConcept(src.getRole()));
171    if (src.hasRank()) tgt.setRankElement(PositiveInt30_50.convertPositiveInt(src.getRankElement()));
172    return tgt;
173  }
174
175  public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException {
176    if (src == null) return null;
177    org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent();
178    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
179    if (src.hasCondition()) tgt.setCondition(Reference30_50.convertReference(src.getCondition()));
180    if (src.hasRole()) tgt.setRole(CodeableConcept30_50.convertCodeableConcept(src.getRole()));
181    if (src.hasRank()) tgt.setRankElement(PositiveInt30_50.convertPositiveInt(src.getRankElement()));
182    return tgt;
183  }
184}