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