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.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Coding43_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.Code43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Url43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
013import org.hl7.fhir.exceptions.FHIRException;
014import org.hl7.fhir.r5.model.Endpoint.EndpointPayloadComponent;
015
016/*
017  Copyright (c) 2011+, HL7, Inc.
018  All rights reserved.
019  
020  Redistribution and use in source and binary forms, with or without modification, 
021  are permitted provided that the following conditions are met:
022  
023   * Redistributions of source code must retain the above copyright notice, this 
024     list of conditions and the following disclaimer.
025   * Redistributions in binary form must reproduce the above copyright notice, 
026     this list of conditions and the following disclaimer in the documentation 
027     and/or other materials provided with the distribution.
028   * Neither the name of HL7 nor the names of its contributors may be used to 
029     endorse or promote products derived from this software without specific 
030     prior written permission.
031  
032  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
033  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
034  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
035  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
036  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
037  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
038  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
039  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
040  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
041  POSSIBILITY OF SUCH DAMAGE.
042  
043*/
044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
045public class Endpoint43_50 {
046
047  public static org.hl7.fhir.r5.model.Endpoint convertEndpoint(org.hl7.fhir.r4b.model.Endpoint src) throws FHIRException {
048    if (src == null)
049      return null;
050    org.hl7.fhir.r5.model.Endpoint tgt = new org.hl7.fhir.r5.model.Endpoint();
051    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
052    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
053      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
054    if (src.hasStatus())
055      tgt.setStatusElement(convertEndpointStatus(src.getStatusElement()));
056    if (src.hasConnectionType())
057      tgt.addConnectionType(Coding43_50.convertCodingToCodeableConcept(src.getConnectionType()));
058    if (src.hasName())
059      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
060    if (src.hasManagingOrganization())
061      tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization()));
062    for (org.hl7.fhir.r4b.model.ContactPoint t : src.getContact())
063      tgt.addContact(ContactPoint43_50.convertContactPoint(t));
064    if (src.hasPeriod())
065      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
066    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getPayloadType())
067      tgt.addPayload().addType(CodeableConcept43_50.convertCodeableConcept(t));
068    for (org.hl7.fhir.r4b.model.CodeType t : src.getPayloadMimeType())
069      tgt.addPayload().getMimeType().add(Code43_50.convertCode(t));
070    if (src.hasAddress())
071      tgt.setAddressElement(Url43_50.convertUrl(src.getAddressElement()));
072    for (org.hl7.fhir.r4b.model.StringType t : src.getHeader()) tgt.getHeader().add(String43_50.convertString(t));
073    return tgt;
074  }
075
076  public static org.hl7.fhir.r4b.model.Endpoint convertEndpoint(org.hl7.fhir.r5.model.Endpoint src) throws FHIRException {
077    if (src == null)
078      return null;
079    org.hl7.fhir.r4b.model.Endpoint tgt = new org.hl7.fhir.r4b.model.Endpoint();
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(convertEndpointStatus(src.getStatusElement()));
085    if (src.hasConnectionType())
086      tgt.setConnectionType(Coding43_50.convertCoding(src.getConnectionTypeFirstRep()));
087    if (src.hasName())
088      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
089    if (src.hasManagingOrganization())
090      tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization()));
091    for (org.hl7.fhir.r5.model.ContactPoint t : src.getContact())
092      tgt.addContact(ContactPoint43_50.convertContactPoint(t));
093    if (src.hasPeriod())
094      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
095    for (EndpointPayloadComponent t : src.getPayload())
096      if (t.hasType())
097        tgt.addPayloadType(CodeableConcept43_50.convertCodeableConcept(t.getTypeFirstRep()));
098    for (EndpointPayloadComponent t : src.getPayload())
099      if (t.hasMimeType())
100        tgt.getPayloadMimeType().add(Code43_50.convertCode(t.getMimeType().get(0)));
101    if (src.hasAddress())
102      tgt.setAddressElement(Url43_50.convertUrl(src.getAddressElement()));
103    for (org.hl7.fhir.r5.model.StringType t : src.getHeader()) tgt.getHeader().add(String43_50.convertString(t));
104    return tgt;
105  }
106
107  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Endpoint.EndpointStatus> convertEndpointStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Endpoint.EndpointStatus> src) throws FHIRException {
108    if (src == null || src.isEmpty())
109      return null;
110    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());
111    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
112    switch (src.getValue()) {
113      case ACTIVE:
114        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ACTIVE);
115        break;
116      case SUSPENDED:
117        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.SUSPENDED);
118        break;
119      case ERROR:
120        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ERROR);
121        break;
122      case OFF:
123        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.OFF);
124        break;
125      case ENTEREDINERROR:
126        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.ENTEREDINERROR);
127        break;
128      default:
129        tgt.setValue(org.hl7.fhir.r5.model.Endpoint.EndpointStatus.NULL);
130        break;
131    }
132    return tgt;
133  }
134
135  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Endpoint.EndpointStatus> convertEndpointStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Endpoint.EndpointStatus> src) throws FHIRException {
136    if (src == null || src.isEmpty())
137      return null;
138    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Endpoint.EndpointStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Endpoint.EndpointStatusEnumFactory());
139    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
140    switch (src.getValue()) {
141      case ACTIVE:
142        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.ACTIVE);
143        break;
144      case SUSPENDED:
145        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.SUSPENDED);
146        break;
147      case ERROR:
148        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.ERROR);
149        break;
150      case OFF:
151        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.OFF);
152        break;
153      case ENTEREDINERROR:
154        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.ENTEREDINERROR);
155        break;
156      default:
157        tgt.setValue(org.hl7.fhir.r4b.model.Endpoint.EndpointStatus.NULL);
158        break;
159    }
160    return tgt;
161  }
162}