001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Coding10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Base64Binary10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
011import org.hl7.fhir.dstu2.model.AuditEvent;
012import org.hl7.fhir.dstu2.model.Enumeration;
013import org.hl7.fhir.exceptions.FHIRException;
014
015public class AuditEvent10_40 {
016
017  public static org.hl7.fhir.r4.model.AuditEvent convertAuditEvent(org.hl7.fhir.dstu2.model.AuditEvent src) throws FHIRException {
018    if (src == null || src.isEmpty())
019      return null;
020    org.hl7.fhir.r4.model.AuditEvent tgt = new org.hl7.fhir.r4.model.AuditEvent();
021    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
022    if (src.hasEvent()) {
023      if (src.hasType())
024        tgt.setType(Coding10_40.convertCoding(src.getEvent().getType()));
025      for (org.hl7.fhir.dstu2.model.Coding t : src.getEvent().getSubtype())
026        tgt.addSubtype(Coding10_40.convertCoding(t));
027      tgt.setActionElement(convertAuditEventAction(src.getEvent().getActionElement()));
028      tgt.setRecorded(src.getEvent().getDateTime());
029      tgt.setOutcomeElement(convertAuditEventOutcome(src.getEvent().getOutcomeElement()));
030      tgt.setOutcomeDesc(src.getEvent().getOutcomeDesc());
031      for (org.hl7.fhir.dstu2.model.Coding t : src.getEvent().getPurposeOfEvent())
032        tgt.addPurposeOfEvent().addCoding(Coding10_40.convertCoding(t));
033    }
034    for (org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantComponent t : src.getParticipant())
035      tgt.addAgent(convertAuditEventAgentComponent(t));
036    if (src.hasSource())
037      tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
038    for (org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectComponent t : src.getObject())
039      tgt.addEntity(convertAuditEventEntityComponent(t));
040    return tgt;
041  }
042
043  public static org.hl7.fhir.dstu2.model.AuditEvent convertAuditEvent(org.hl7.fhir.r4.model.AuditEvent src) throws FHIRException {
044    if (src == null || src.isEmpty())
045      return null;
046    org.hl7.fhir.dstu2.model.AuditEvent tgt = new org.hl7.fhir.dstu2.model.AuditEvent();
047    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
048    tgt.getEvent().setType(Coding10_40.convertCoding(src.getType()));
049    for (org.hl7.fhir.r4.model.Coding t : src.getSubtype()) tgt.getEvent().addSubtype(Coding10_40.convertCoding(t));
050    tgt.getEvent().setActionElement(convertAuditEventAction(src.getActionElement()));
051    tgt.getEvent().setDateTime(src.getRecorded());
052    tgt.getEvent().setOutcomeElement(convertAuditEventOutcome(src.getOutcomeElement()));
053    tgt.getEvent().setOutcomeDesc(src.getOutcomeDesc());
054    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfEvent())
055      for (org.hl7.fhir.r4.model.Coding cc : t.getCoding())
056        tgt.getEvent().addPurposeOfEvent(Coding10_40.convertCoding(cc));
057    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent t : src.getAgent())
058      tgt.addParticipant(convertAuditEventAgentComponent(t));
059    if (src.hasSource())
060      tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
061    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent t : src.getEntity())
062      tgt.addObject(convertAuditEventEntityComponent(t));
063    return tgt;
064  }
065
066  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAction> src) throws FHIRException {
067      if (src == null || src.isEmpty())
068          return null;
069      Enumeration<AuditEvent.AuditEventAction> tgt = new Enumeration<>(new AuditEvent.AuditEventActionEnumFactory());
070      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
071      if (src.getValue() == null) {
072          tgt.setValue(null);
073      } else {
074          switch (src.getValue()) {
075              case C:
076                  tgt.setValue(AuditEvent.AuditEventAction.C);
077                  break;
078              case R:
079                  tgt.setValue(AuditEvent.AuditEventAction.R);
080                  break;
081              case U:
082                  tgt.setValue(AuditEvent.AuditEventAction.U);
083                  break;
084              case D:
085                  tgt.setValue(AuditEvent.AuditEventAction.D);
086                  break;
087              case E:
088                  tgt.setValue(AuditEvent.AuditEventAction.E);
089                  break;
090              default:
091                  tgt.setValue(AuditEvent.AuditEventAction.NULL);
092                  break;
093          }
094      }
095      return tgt;
096  }
097
098  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventAction> src) throws FHIRException {
099      if (src == null || src.isEmpty())
100          return null;
101      org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAction> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AuditEvent.AuditEventActionEnumFactory());
102      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
103      if (src.getValue() == null) {
104          tgt.setValue(null);
105      } else {
106          switch (src.getValue()) {
107              case C:
108                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.C);
109                  break;
110              case R:
111                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.R);
112                  break;
113              case U:
114                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.U);
115                  break;
116              case D:
117                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.D);
118                  break;
119              case E:
120                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.E);
121                  break;
122              default:
123                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.NULL);
124                  break;
125          }
126      }
127      return tgt;
128  }
129
130  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantComponent src) throws FHIRException {
131    if (src == null || src.isEmpty())
132      return null;
133    org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent();
134    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
135    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getRole())
136      tgt.addRole(CodeableConcept10_40.convertCodeableConcept(t));
137    if (src.hasReference())
138      tgt.setWho(Reference10_40.convertReference(src.getReference()));
139    if (src.hasUserId())
140      tgt.getWho().setIdentifier(Identifier10_40.convertIdentifier(src.getUserId()));
141    if (src.hasAltIdElement())
142      tgt.setAltIdElement(String10_40.convertString(src.getAltIdElement()));
143    if (src.hasNameElement())
144      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
145    if (src.hasRequestorElement())
146      tgt.setRequestorElement(Boolean10_40.convertBoolean(src.getRequestorElement()));
147    if (src.hasLocation())
148      tgt.setLocation(Reference10_40.convertReference(src.getLocation()));
149    for (org.hl7.fhir.dstu2.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue());
150    if (src.hasMedia())
151      tgt.setMedia(Coding10_40.convertCoding(src.getMedia()));
152    if (src.hasNetwork())
153      tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
154    for (org.hl7.fhir.dstu2.model.Coding t : src.getPurposeOfUse())
155      tgt.addPurposeOfUse().addCoding(Coding10_40.convertCoding(t));
156    return tgt;
157  }
158
159  public static org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantComponent convertAuditEventAgentComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
160    if (src == null || src.isEmpty())
161      return null;
162    org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantComponent tgt = new org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantComponent();
163    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
164    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole())
165      tgt.addRole(CodeableConcept10_40.convertCodeableConcept(t));
166    if (src.hasWho()) {
167      if (src.getWho().hasIdentifier())
168        tgt.setUserId(Identifier10_40.convertIdentifier(src.getWho().getIdentifier()));
169      if (src.getWho().hasReference() || src.getWho().hasDisplay() || src.getWho().hasExtension() || src.getWho().hasId())
170        tgt.setReference(Reference10_40.convertReference(src.getWho()));
171    }
172    if (src.hasAltIdElement())
173      tgt.setAltIdElement(String10_40.convertString(src.getAltIdElement()));
174    if (src.hasNameElement())
175      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
176    if (src.hasRequestorElement())
177      tgt.setRequestorElement(Boolean10_40.convertBoolean(src.getRequestorElement()));
178    if (src.hasLocation())
179      tgt.setLocation(Reference10_40.convertReference(src.getLocation()));
180    for (org.hl7.fhir.r4.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue());
181    if (src.hasMedia())
182      tgt.setMedia(Coding10_40.convertCoding(src.getMedia()));
183    if (src.hasNetwork())
184      tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
185    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfUse())
186      for (org.hl7.fhir.r4.model.Coding cc : t.getCoding()) tgt.addPurposeOfUse(Coding10_40.convertCoding(cc));
187    return tgt;
188  }
189
190  public static org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
191    if (src == null || src.isEmpty())
192      return null;
193    org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkComponent tgt = new org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkComponent();
194    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
195    if (src.hasAddressElement())
196      tgt.setAddressElement(String10_40.convertString(src.getAddressElement()));
197    if (src.hasType())
198      tgt.setTypeElement(convertAuditEventParticipantNetworkType(src.getTypeElement()));
199    return tgt;
200  }
201
202  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkComponent src) throws FHIRException {
203    if (src == null || src.isEmpty())
204      return null;
205    org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent();
206    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
207    if (src.hasAddressElement())
208      tgt.setAddressElement(String10_40.convertString(src.getAddressElement()));
209    if (src.hasType())
210      tgt.setTypeElement(convertAuditEventParticipantNetworkType(src.getTypeElement()));
211    return tgt;
212  }
213
214  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectComponent src) throws FHIRException {
215    if (src == null || src.isEmpty())
216      return null;
217    org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent();
218    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
219    if (src.hasIdentifier())
220      tgt.getWhat().setIdentifier(Identifier10_40.convertIdentifier(src.getIdentifier()));
221    if (src.hasReference())
222      tgt.setWhat(Reference10_40.convertReference(src.getReference()));
223    if (src.hasType())
224      tgt.setType(Coding10_40.convertCoding(src.getType()));
225    if (src.hasRole())
226      tgt.setRole(Coding10_40.convertCoding(src.getRole()));
227    if (src.hasLifecycle())
228      tgt.setLifecycle(Coding10_40.convertCoding(src.getLifecycle()));
229    for (org.hl7.fhir.dstu2.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(Coding10_40.convertCoding(t));
230    if (src.hasNameElement())
231      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
232    if (src.hasDescriptionElement())
233      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
234    if (src.hasQueryElement())
235      tgt.setQueryElement(Base64Binary10_40.convertBase64Binary(src.getQueryElement()));
236    for (org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectDetailComponent t : src.getDetail())
237      tgt.addDetail(convertAuditEventEntityDetailComponent(t));
238    return tgt;
239  }
240
241  public static org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectComponent convertAuditEventEntityComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
242    if (src == null || src.isEmpty())
243      return null;
244    org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectComponent tgt = new org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectComponent();
245    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
246    if (src.hasWhat()) {
247      if (src.getWhat().hasIdentifier())
248        tgt.setIdentifier(Identifier10_40.convertIdentifier(src.getWhat().getIdentifier()));
249      if (src.getWhat().hasReference() || src.getWhat().hasDisplay() || src.getWhat().hasExtension() || src.getWhat().hasId())
250        tgt.setReference(Reference10_40.convertReference(src.getWhat()));
251    }
252    if (src.hasType())
253      tgt.setType(Coding10_40.convertCoding(src.getType()));
254    if (src.hasRole())
255      tgt.setRole(Coding10_40.convertCoding(src.getRole()));
256    if (src.hasLifecycle())
257      tgt.setLifecycle(Coding10_40.convertCoding(src.getLifecycle()));
258    for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(Coding10_40.convertCoding(t));
259    if (src.hasNameElement())
260      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
261    if (src.hasDescriptionElement())
262      tgt.setDescriptionElement(String10_40.convertString(src.getDescriptionElement()));
263    if (src.hasQueryElement())
264      tgt.setQueryElement(Base64Binary10_40.convertBase64Binary(src.getQueryElement()));
265    for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail())
266      tgt.addDetail(convertAuditEventEntityDetailComponent(t));
267    return tgt;
268  }
269
270  public static org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
271    if (src == null || src.isEmpty())
272      return null;
273    org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectDetailComponent tgt = new org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectDetailComponent();
274    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
275    if (src.hasTypeElement())
276      tgt.setTypeElement(String10_40.convertString(src.getTypeElement()));
277    if (src.hasValueStringType())
278      tgt.setValue(src.getValueStringType().getValue().getBytes());
279    else if (src.hasValueBase64BinaryType())
280      tgt.setValue(src.getValueBase64BinaryType().getValue());
281    return tgt;
282  }
283
284  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.dstu2.model.AuditEvent.AuditEventObjectDetailComponent src) throws FHIRException {
285    if (src == null || src.isEmpty())
286      return null;
287    org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent();
288    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
289    if (src.hasTypeElement())
290      tgt.setTypeElement(String10_40.convertString(src.getTypeElement()));
291    if (src.hasValue())
292      tgt.setValue(new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()));
293    return tgt;
294  }
295
296  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome> convertAuditEventOutcome(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventOutcome> src) throws FHIRException {
297      if (src == null || src.isEmpty())
298          return null;
299      org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcomeEnumFactory());
300      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
301      if (src.getValue() == null) {
302          tgt.setValue(null);
303      } else {
304          switch (src.getValue()) {
305              case _0:
306                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._0);
307                  break;
308              case _4:
309                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._4);
310                  break;
311              case _8:
312                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._8);
313                  break;
314              case _12:
315                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome._12);
316                  break;
317              default:
318                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome.NULL);
319                  break;
320          }
321      }
322      return tgt;
323  }
324
325  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventOutcome> convertAuditEventOutcome(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventOutcome> src) throws FHIRException {
326      if (src == null || src.isEmpty())
327          return null;
328      Enumeration<AuditEvent.AuditEventOutcome> tgt = new Enumeration<>(new AuditEvent.AuditEventOutcomeEnumFactory());
329      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
330      if (src.getValue() == null) {
331          tgt.setValue(null);
332      } else {
333          switch (src.getValue()) {
334              case _0:
335                  tgt.setValue(AuditEvent.AuditEventOutcome._0);
336                  break;
337              case _4:
338                  tgt.setValue(AuditEvent.AuditEventOutcome._4);
339                  break;
340              case _8:
341                  tgt.setValue(AuditEvent.AuditEventOutcome._8);
342                  break;
343              case _12:
344                  tgt.setValue(AuditEvent.AuditEventOutcome._12);
345                  break;
346              default:
347                  tgt.setValue(AuditEvent.AuditEventOutcome.NULL);
348                  break;
349          }
350      }
351      return tgt;
352  }
353
354  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkType> convertAuditEventParticipantNetworkType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType> src) throws FHIRException {
355      if (src == null || src.isEmpty())
356          return null;
357      Enumeration<AuditEvent.AuditEventParticipantNetworkType> tgt = new Enumeration<>(new AuditEvent.AuditEventParticipantNetworkTypeEnumFactory());
358      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
359      if (src.getValue() == null) {
360          tgt.setValue(null);
361      } else {
362          switch (src.getValue()) {
363              case _1:
364                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType._1);
365                  break;
366              case _2:
367                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType._2);
368                  break;
369              case _3:
370                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType._3);
371                  break;
372              case _4:
373                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType._4);
374                  break;
375              case _5:
376                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType._5);
377                  break;
378              default:
379                  tgt.setValue(AuditEvent.AuditEventParticipantNetworkType.NULL);
380                  break;
381          }
382      }
383      return tgt;
384  }
385
386  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType> convertAuditEventParticipantNetworkType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.AuditEvent.AuditEventParticipantNetworkType> src) throws FHIRException {
387      if (src == null || src.isEmpty())
388          return null;
389      org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkTypeEnumFactory());
390      ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
391      if (src.getValue() == null) {
392          tgt.setValue(null);
393      } else {
394          switch (src.getValue()) {
395              case _1:
396                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._1);
397                  break;
398              case _2:
399                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._2);
400                  break;
401              case _3:
402                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._3);
403                  break;
404              case _4:
405                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._4);
406                  break;
407              case _5:
408                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._5);
409                  break;
410              default:
411                  tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType.NULL);
412                  break;
413          }
414      }
415      return tgt;
416  }
417
418  public static org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.dstu2.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
419    if (src == null || src.isEmpty())
420      return null;
421    org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent();
422    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
423    if (src.hasSiteElement())
424      tgt.setSiteElement(String10_40.convertString(src.getSiteElement()));
425    if (src.hasIdentifier())
426      tgt.getObserver().setIdentifier(Identifier10_40.convertIdentifier(src.getIdentifier()));
427    for (org.hl7.fhir.dstu2.model.Coding t : src.getType()) tgt.addType(Coding10_40.convertCoding(t));
428    return tgt;
429  }
430
431  public static org.hl7.fhir.dstu2.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
432    if (src == null || src.isEmpty())
433      return null;
434    org.hl7.fhir.dstu2.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.dstu2.model.AuditEvent.AuditEventSourceComponent();
435    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
436    if (src.hasSiteElement())
437      tgt.setSiteElement(String10_40.convertString(src.getSiteElement()));
438    if (src.hasObserver())
439      tgt.setIdentifier(Identifier10_40.convertIdentifier(src.getObserver().getIdentifier()));
440    for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(Coding10_40.convertCoding(t));
441    return tgt;
442  }
443}