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