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.*;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
007import org.hl7.fhir.exceptions.FHIRException;
008
009public class Endpoint30_50 {
010
011  public static org.hl7.fhir.dstu3.model.Endpoint convertEndpoint(org.hl7.fhir.r5.model.Endpoint src) throws FHIRException {
012    if (src == null)
013      return null;
014    org.hl7.fhir.dstu3.model.Endpoint tgt = new org.hl7.fhir.dstu3.model.Endpoint();
015    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
016    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
017      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
018    if (src.hasStatus())
019      tgt.setStatusElement(convertEndpointStatus(src.getStatusElement()));
020    if (src.hasConnectionType())
021      tgt.setConnectionType(Coding30_50.convertCoding(src.getConnectionType()));
022    if (src.hasName())
023      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
024    if (src.hasManagingOrganization())
025      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
026    for (org.hl7.fhir.r5.model.ContactPoint t : src.getContact())
027      tgt.addContact(ContactPoint30_50.convertContactPoint(t));
028    if (src.hasPeriod())
029      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
030    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPayloadType())
031      tgt.addPayloadType(CodeableConcept30_50.convertCodeableConcept(t));
032    for (org.hl7.fhir.r5.model.CodeType t : src.getPayloadMimeType()) tgt.addPayloadMimeType(t.getValue());
033    if (src.hasAddress())
034      tgt.setAddress(src.getAddress());
035    for (org.hl7.fhir.r5.model.StringType t : src.getHeader()) tgt.addHeader(t.getValue());
036    return tgt;
037  }
038
039  public static org.hl7.fhir.r5.model.Endpoint convertEndpoint(org.hl7.fhir.dstu3.model.Endpoint src) throws FHIRException {
040    if (src == null)
041      return null;
042    org.hl7.fhir.r5.model.Endpoint tgt = new org.hl7.fhir.r5.model.Endpoint();
043    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
044    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
045      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
046    if (src.hasStatus())
047      tgt.setStatusElement(convertEndpointStatus(src.getStatusElement()));
048    if (src.hasConnectionType())
049      tgt.setConnectionType(Coding30_50.convertCoding(src.getConnectionType()));
050    if (src.hasName())
051      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
052    if (src.hasManagingOrganization())
053      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
054    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getContact())
055      tgt.addContact(ContactPoint30_50.convertContactPoint(t));
056    if (src.hasPeriod())
057      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
058    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPayloadType())
059      tgt.addPayloadType(CodeableConcept30_50.convertCodeableConcept(t));
060    for (org.hl7.fhir.dstu3.model.CodeType t : src.getPayloadMimeType()) tgt.addPayloadMimeType(t.getValue());
061    if (src.hasAddress())
062      tgt.setAddress(src.getAddress());
063    for (org.hl7.fhir.dstu3.model.StringType t : src.getHeader()) tgt.addHeader(t.getValue());
064    return tgt;
065  }
066
067  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Endpoint.EndpointStatus> convertEndpointStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus> src) throws FHIRException {
068    if (src == null || src.isEmpty())
069      return null;
070    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Endpoint.EndpointStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Endpoint.EndpointStatusEnumFactory());
071    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
072    switch (src.getValue()) {
073      case ACTIVE:
074        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ACTIVE);
075        break;
076      case SUSPENDED:
077        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.SUSPENDED);
078        break;
079      case ERROR:
080        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ERROR);
081        break;
082      case OFF:
083        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.OFF);
084        break;
085      case ENTEREDINERROR:
086        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ENTEREDINERROR);
087        break;
088      case TEST:
089        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.TEST);
090        break;
091      default:
092        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.NULL);
093        break;
094    }
095    return tgt;
096  }
097
098  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus> convertEndpointStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Endpoint.EndpointStatus> src) throws FHIRException {
099    if (src == null || src.isEmpty())
100      return null;
101    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Endpoint.EndpointStatusEnumFactory());
102    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
103    switch (src.getValue()) {
104      case ACTIVE:
105        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ACTIVE);
106        break;
107      case SUSPENDED:
108        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.SUSPENDED);
109        break;
110      case ERROR:
111        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ERROR);
112        break;
113      case OFF:
114        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.OFF);
115        break;
116      case ENTEREDINERROR:
117        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.ENTEREDINERROR);
118        break;
119      case TEST:
120        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.TEST);
121        break;
122      default:
123        tgt.setValue(org.hl7.fhir.dstu3.model.Endpoint.EndpointStatus.NULL);
124        break;
125    }
126    return tgt;
127  }
128}