001package org.hl7.fhir.convertors.conv10_50.resources10_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_50; 004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Reference10_50; 005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.CodeableConcept10_50; 006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Coding10_50; 007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.ContactPoint10_50; 008import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.String10_50; 009import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Uri10_50; 010import org.hl7.fhir.exceptions.FHIRException; 011 012public class MessageHeader10_50 { 013 014 public static org.hl7.fhir.dstu2.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 015 if (src == null || src.isEmpty()) 016 return null; 017 org.hl7.fhir.dstu2.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.dstu2.model.MessageHeader.MessageDestinationComponent(); 018 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 019 if (src.hasNameElement()) 020 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 021 if (src.hasTarget()) 022 tgt.setTarget(Reference10_50.convertReference(src.getTarget())); 023 if (src.hasEndpointUrlType()) 024 tgt.setEndpointElement(Uri10_50.convertUri(src.getEndpointUrlType())); 025 return tgt; 026 } 027 028 public static org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.dstu2.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 029 if (src == null || src.isEmpty()) 030 return null; 031 org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent(); 032 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 033 if (src.hasNameElement()) 034 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 035 if (src.hasTarget()) 036 tgt.setTarget(Reference10_50.convertReference(src.getTarget())); 037 if (src.hasEndpoint()) 038 tgt.setEndpoint(Uri10_50.convertUri(src.getEndpointElement())); 039 return tgt; 040 } 041 042 public static org.hl7.fhir.dstu2.model.MessageHeader convertMessageHeader(org.hl7.fhir.r5.model.MessageHeader src) throws FHIRException { 043 if (src == null || src.isEmpty()) 044 return null; 045 org.hl7.fhir.dstu2.model.MessageHeader tgt = new org.hl7.fhir.dstu2.model.MessageHeader(); 046 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 047 if (src.hasEventCoding()) 048 tgt.setEvent(Coding10_50.convertCoding(src.getEventCoding())); 049 if (src.hasResponse()) 050 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 051 if (src.hasSource()) 052 tgt.setSource(convertMessageSourceComponent(src.getSource())); 053 for (org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 054 tgt.addDestination(convertMessageDestinationComponent(t)); 055// if (src.hasEnterer()) 056// tgt.setEnterer(Reference10_50.convertReference(src.getEnterer())); 057 if (src.hasAuthor()) 058 tgt.setAuthor(Reference10_50.convertReference(src.getAuthor())); 059 if (src.hasResponsible()) 060 tgt.setResponsible(Reference10_50.convertReference(src.getResponsible())); 061 if (src.hasReason()) 062 tgt.setReason(CodeableConcept10_50.convertCodeableConcept(src.getReason())); 063 for (org.hl7.fhir.r5.model.Reference t : src.getFocus()) tgt.addData(Reference10_50.convertReference(t)); 064 return tgt; 065 } 066 067 public static org.hl7.fhir.r5.model.MessageHeader convertMessageHeader(org.hl7.fhir.dstu2.model.MessageHeader src) throws FHIRException { 068 if (src == null || src.isEmpty()) 069 return null; 070 org.hl7.fhir.r5.model.MessageHeader tgt = new org.hl7.fhir.r5.model.MessageHeader(); 071 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt); 072 if (src.hasEvent()) 073 tgt.setEvent(Coding10_50.convertCoding(src.getEvent())); 074 if (src.hasResponse()) 075 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 076 if (src.hasSource()) 077 tgt.setSource(convertMessageSourceComponent(src.getSource())); 078 for (org.hl7.fhir.dstu2.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 079 tgt.addDestination(convertMessageDestinationComponent(t)); 080// if (src.hasEnterer()) 081// tgt.setEnterer(Reference10_50.convertReference(src.getEnterer())); 082 if (src.hasAuthor()) 083 tgt.setAuthor(Reference10_50.convertReference(src.getAuthor())); 084 if (src.hasResponsible()) 085 tgt.setResponsible(Reference10_50.convertReference(src.getResponsible())); 086 if (src.hasReason()) 087 tgt.setReason(CodeableConcept10_50.convertCodeableConcept(src.getReason())); 088 for (org.hl7.fhir.dstu2.model.Reference t : src.getData()) tgt.addFocus(Reference10_50.convertReference(t)); 089 return tgt; 090 } 091 092 public static org.hl7.fhir.dstu2.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 093 if (src == null || src.isEmpty()) 094 return null; 095 org.hl7.fhir.dstu2.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.dstu2.model.MessageHeader.MessageHeaderResponseComponent(); 096 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 097 if (src.hasIdentifier()) 098 tgt.setIdentifierElement(new org.hl7.fhir.dstu2.model.IdType(src.getIdentifier().getValue())); 099 if (src.hasCode()) 100 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 101 if (src.hasDetails()) 102 tgt.setDetails(Reference10_50.convertReference(src.getDetails())); 103 return tgt; 104 } 105 106 public static org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.dstu2.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 107 if (src == null || src.isEmpty()) 108 return null; 109 org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent(); 110 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 111 if (src.hasIdentifierElement()) 112 tgt.setIdentifier(new org.hl7.fhir.r5.model.Identifier().setValue(src.getIdentifier())); 113 if (src.hasCode()) 114 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 115 if (src.hasDetails()) 116 tgt.setDetails(Reference10_50.convertReference(src.getDetails())); 117 return tgt; 118 } 119 120 public static org.hl7.fhir.dstu2.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 121 if (src == null || src.isEmpty()) 122 return null; 123 org.hl7.fhir.dstu2.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.dstu2.model.MessageHeader.MessageSourceComponent(); 124 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 125 if (src.hasNameElement()) 126 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 127 if (src.hasSoftwareElement()) 128 tgt.setSoftwareElement(String10_50.convertString(src.getSoftwareElement())); 129 if (src.hasVersionElement()) 130 tgt.setVersionElement(String10_50.convertString(src.getVersionElement())); 131 if (src.hasContact()) 132 tgt.setContact(ContactPoint10_50.convertContactPoint(src.getContact())); 133 if (src.hasEndpointUrlType()) 134 tgt.setEndpointElement(Uri10_50.convertUri(src.getEndpointUrlType())); 135 return tgt; 136 } 137 138 public static org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.dstu2.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 139 if (src == null || src.isEmpty()) 140 return null; 141 org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent(); 142 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt); 143 if (src.hasNameElement()) 144 tgt.setNameElement(String10_50.convertString(src.getNameElement())); 145 if (src.hasSoftwareElement()) 146 tgt.setSoftwareElement(String10_50.convertString(src.getSoftwareElement())); 147 if (src.hasVersionElement()) 148 tgt.setVersionElement(String10_50.convertString(src.getVersionElement())); 149 if (src.hasContact()) 150 tgt.setContact(ContactPoint10_50.convertContactPoint(src.getContact())); 151 if (src.hasEndpoint()) 152 tgt.setEndpoint(Uri10_50.convertUri(src.getEndpointElement())); 153 return tgt; 154 } 155 156 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> convertResponseType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MessageHeader.ResponseType> src) throws FHIRException { 157 if (src == null || src.isEmpty()) 158 return null; 159 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MessageHeader.ResponseTypeEnumFactory()); 160 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 161 switch (src.getValue()) { 162 case OK: 163 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.OK); 164 break; 165 case TRANSIENTERROR: 166 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.TRANSIENTERROR); 167 break; 168 case FATALERROR: 169 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.FATALERROR); 170 break; 171 default: 172 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.NULL); 173 break; 174 } 175 return tgt; 176 } 177 178 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MessageHeader.ResponseType> convertResponseType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> src) throws FHIRException { 179 if (src == null || src.isEmpty()) 180 return null; 181 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MessageHeader.ResponseType> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.MessageHeader.ResponseTypeEnumFactory()); 182 ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt); 183 switch (src.getValue()) { 184 case OK: 185 tgt.setValue(org.hl7.fhir.dstu2.model.MessageHeader.ResponseType.OK); 186 break; 187 case TRANSIENTERROR: 188 tgt.setValue(org.hl7.fhir.dstu2.model.MessageHeader.ResponseType.TRANSIENTERROR); 189 break; 190 case FATALERROR: 191 tgt.setValue(org.hl7.fhir.dstu2.model.MessageHeader.ResponseType.FATALERROR); 192 break; 193 default: 194 tgt.setValue(org.hl7.fhir.dstu2.model.MessageHeader.ResponseType.NULL); 195 break; 196 } 197 return tgt; 198 } 199}