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