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