001package org.hl7.fhir.convertors.conv30_50;
002
003import org.hl7.fhir.convertors.VersionConvertor_30_50;
004import org.hl7.fhir.exceptions.FHIRException;
005
006public class AuditEvent30_50 {
007
008    public static org.hl7.fhir.r5.model.AuditEvent convertAuditEvent(org.hl7.fhir.dstu3.model.AuditEvent src) throws FHIRException {
009        if (src == null)
010            return null;
011        org.hl7.fhir.r5.model.AuditEvent tgt = new org.hl7.fhir.r5.model.AuditEvent();
012        VersionConvertor_30_50.copyDomainResource(src, tgt);
013        if (src.hasType())
014            tgt.setType(VersionConvertor_30_50.convertCoding(src.getType()));
015        for (org.hl7.fhir.dstu3.model.Coding t : src.getSubtype()) tgt.addSubtype(VersionConvertor_30_50.convertCoding(t));
016        if (src.hasAction())
017            tgt.setActionElement(convertAuditEventAction(src.getActionElement()));
018        if (src.hasRecorded())
019            tgt.setRecordedElement(VersionConvertor_30_50.convertInstant(src.getRecordedElement()));
020        if (src.hasOutcome())
021          tgt.getOutcome().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/audit-event-outcome").setCode(src.getOutcome().toCode());
022        if (src.hasOutcomeDesc())
023          tgt.getOutcome().setTextElement(VersionConvertor_30_50.convertString(src.getOutcomeDescElement()));
024        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPurposeOfEvent()) tgt.addPurposeOfEvent(VersionConvertor_30_50.convertCodeableConcept(t));
025        for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent t : src.getAgent()) tgt.addAgent(convertAuditEventAgentComponent(t));
026        if (src.hasSource())
027            tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
028        for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent t : src.getEntity()) tgt.addEntity(convertAuditEventEntityComponent(t));
029        return tgt;
030    }
031
032    public static org.hl7.fhir.dstu3.model.AuditEvent convertAuditEvent(org.hl7.fhir.r5.model.AuditEvent src) throws FHIRException {
033        if (src == null)
034            return null;
035        org.hl7.fhir.dstu3.model.AuditEvent tgt = new org.hl7.fhir.dstu3.model.AuditEvent();
036        VersionConvertor_30_50.copyDomainResource(src, tgt);
037        if (src.hasType())
038            tgt.setType(VersionConvertor_30_50.convertCoding(src.getType()));
039        for (org.hl7.fhir.r5.model.Coding t : src.getSubtype()) tgt.addSubtype(VersionConvertor_30_50.convertCoding(t));
040        if (src.hasAction())
041            tgt.setActionElement(convertAuditEventAction(src.getActionElement()));
042        if (src.hasRecorded())
043            tgt.setRecordedElement(VersionConvertor_30_50.convertInstant(src.getRecordedElement()));
044        if (src.hasOutcome() && src.getOutcome().hasCoding("http://terminology.hl7.org/CodeSystem/audit-event-outcome"))
045            tgt.getOutcomeElement().setValueAsString(src.getOutcome().getCode("http://terminology.hl7.org/CodeSystem/audit-event-outcome"));
046        if (src.getOutcome().hasText())
047            tgt.setOutcomeDescElement(VersionConvertor_30_50.convertString(src.getOutcome().getTextElement()));
048        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPurposeOfEvent()) tgt.addPurposeOfEvent(VersionConvertor_30_50.convertCodeableConcept(t));
049        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent t : src.getAgent()) tgt.addAgent(convertAuditEventAgentComponent(t));
050        if (src.hasSource())
051            tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
052        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent t : src.getEntity()) tgt.addEntity(convertAuditEventEntityComponent(t));
053        return tgt;
054    }
055
056    static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction> src) throws FHIRException {
057        if (src == null || src.isEmpty())
058            return null;
059        org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAction> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.AuditEvent.AuditEventActionEnumFactory());
060        VersionConvertor_30_50.copyElement(src, tgt);
061        switch(src.getValue()) {
062            case C:
063                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.C);
064                break;
065            case R:
066                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.R);
067                break;
068            case U:
069                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.U);
070                break;
071            case D:
072                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.D);
073                break;
074            case E:
075                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.E);
076                break;
077            default:
078                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.NULL);
079                break;
080        }
081        return tgt;
082    }
083
084    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAction> src) throws FHIRException {
085        if (src == null || src.isEmpty())
086            return null;
087        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventActionEnumFactory());
088        VersionConvertor_30_50.copyElement(src, tgt);
089        switch(src.getValue()) {
090            case C:
091                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.C);
092                break;
093            case R:
094                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.R);
095                break;
096            case U:
097                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.U);
098                break;
099            case D:
100                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.D);
101                break;
102            case E:
103                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.E);
104                break;
105            default:
106                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAction.NULL);
107                break;
108        }
109        return tgt;
110    }
111
112    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
113        if (src == null)
114            return null;
115        org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent();
116        VersionConvertor_30_50.copyElement(src, tgt);
117        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRole()) tgt.addRole(VersionConvertor_30_50.convertCodeableConcept(t));
118        if (src.hasReference())
119            tgt.setWho(VersionConvertor_30_50.convertReference(src.getReference()));
120        if (src.hasUserId())
121            tgt.getWho().setIdentifier(VersionConvertor_30_50.convertIdentifier(src.getUserId()));
122        if (src.hasAltId())
123            tgt.setAltIdElement(VersionConvertor_30_50.convertString(src.getAltIdElement()));
124        if (src.hasName())
125            tgt.setNameElement(VersionConvertor_30_50.convertString(src.getNameElement()));
126        if (src.hasRequestor())
127            tgt.setRequestorElement(VersionConvertor_30_50.convertBoolean(src.getRequestorElement()));
128        if (src.hasLocation())
129            tgt.setLocation(VersionConvertor_30_50.convertReference(src.getLocation()));
130        for (org.hl7.fhir.dstu3.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue());
131        if (src.hasMedia())
132            tgt.setMedia(VersionConvertor_30_50.convertCoding(src.getMedia()));
133        if (src.hasNetwork())
134            tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
135        for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPurposeOfUse()) tgt.addPurposeOfUse(VersionConvertor_30_50.convertCodeableConcept(t));
136        return tgt;
137    }
138
139    public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
140        if (src == null)
141            return null;
142        org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentComponent();
143        VersionConvertor_30_50.copyElement(src, tgt);
144        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) tgt.addRole(VersionConvertor_30_50.convertCodeableConcept(t));
145        if (src.hasWho()) {
146            if (src.getWho().hasIdentifier())
147                tgt.setUserId(VersionConvertor_30_50.convertIdentifier(src.getWho().getIdentifier()));
148            if (src.getWho().hasReference() || src.getWho().hasDisplay() || src.getWho().hasExtension() || src.getWho().hasId())
149                tgt.setReference(VersionConvertor_30_50.convertReference(src.getWho()));
150        }
151        if (src.hasAltId())
152            tgt.setAltIdElement(VersionConvertor_30_50.convertString(src.getAltIdElement()));
153        if (src.hasName())
154            tgt.setNameElement(VersionConvertor_30_50.convertString(src.getNameElement()));
155        if (src.hasRequestor())
156            tgt.setRequestorElement(VersionConvertor_30_50.convertBoolean(src.getRequestorElement()));
157        if (src.hasLocation())
158            tgt.setLocation(VersionConvertor_30_50.convertReference(src.getLocation()));
159        for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.addPolicy(t.getValue());
160        if (src.hasMedia())
161            tgt.setMedia(VersionConvertor_30_50.convertCoding(src.getMedia()));
162        if (src.hasNetwork())
163            tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
164        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPurposeOfUse()) tgt.addPurposeOfUse(VersionConvertor_30_50.convertCodeableConcept(t));
165        return tgt;
166    }
167
168    public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
169        if (src == null)
170            return null;
171        org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent();
172        VersionConvertor_30_50.copyElement(src, tgt);
173        if (src.hasAddress())
174            tgt.setAddressElement(VersionConvertor_30_50.convertString(src.getAddressElement()));
175        if (src.hasType())
176            tgt.setTypeElement(convertAuditEventAgentNetworkType(src.getTypeElement()));
177        return tgt;
178    }
179
180    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
181        if (src == null)
182            return null;
183        org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent();
184        VersionConvertor_30_50.copyElement(src, tgt);
185        if (src.hasAddress())
186            tgt.setAddressElement(VersionConvertor_30_50.convertString(src.getAddressElement()));
187        if (src.hasType())
188            tgt.setTypeElement(convertAuditEventAgentNetworkType(src.getTypeElement()));
189        return tgt;
190    }
191
192    static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType> convertAuditEventAgentNetworkType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType> src) throws FHIRException {
193        if (src == null || src.isEmpty())
194            return null;
195        org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkTypeEnumFactory());
196        VersionConvertor_30_50.copyElement(src, tgt);
197        switch(src.getValue()) {
198            case _1:
199                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._1);
200                break;
201            case _2:
202                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._2);
203                break;
204            case _3:
205                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._3);
206                break;
207            case _4:
208                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._4);
209                break;
210            case _5:
211                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._5);
212                break;
213            default:
214                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType.NULL);
215                break;
216        }
217        return tgt;
218    }
219
220    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType> convertAuditEventAgentNetworkType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType> src) throws FHIRException {
221        if (src == null || src.isEmpty())
222            return null;
223        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkTypeEnumFactory());
224        VersionConvertor_30_50.copyElement(src, tgt);
225        switch(src.getValue()) {
226            case _1:
227                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._1);
228                break;
229            case _2:
230                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._2);
231                break;
232            case _3:
233                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._3);
234                break;
235            case _4:
236                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._4);
237                break;
238            case _5:
239                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType._5);
240                break;
241            default:
242                tgt.setValue(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventAgentNetworkType.NULL);
243                break;
244        }
245        return tgt;
246    }
247
248    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
249        if (src == null)
250            return null;
251        org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent();
252        VersionConvertor_30_50.copyElement(src, tgt);
253        if (src.hasIdentifier())
254            tgt.getWhat().setIdentifier(VersionConvertor_30_50.convertIdentifier(src.getIdentifier()));
255        if (src.hasReference())
256            tgt.setWhat(VersionConvertor_30_50.convertReference(src.getReference()));
257        if (src.hasType())
258            tgt.setType(VersionConvertor_30_50.convertCoding(src.getType()));
259        if (src.hasRole())
260            tgt.setRole(VersionConvertor_30_50.convertCoding(src.getRole()));
261        if (src.hasLifecycle())
262            tgt.setLifecycle(VersionConvertor_30_50.convertCoding(src.getLifecycle()));
263        for (org.hl7.fhir.dstu3.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(VersionConvertor_30_50.convertCoding(t));
264        if (src.hasName())
265            tgt.setNameElement(VersionConvertor_30_50.convertString(src.getNameElement()));
266        if (src.hasQuery())
267            tgt.setQueryElement(VersionConvertor_30_50.convertBase64Binary(src.getQueryElement()));
268        for (org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) tgt.addDetail(convertAuditEventEntityDetailComponent(t));
269        return tgt;
270    }
271
272    public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
273        if (src == null)
274            return null;
275        org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityComponent();
276        VersionConvertor_30_50.copyElement(src, tgt);
277        if (src.hasWhat()) {
278            if (src.getWhat().hasIdentifier())
279                tgt.setIdentifier(VersionConvertor_30_50.convertIdentifier(src.getWhat().getIdentifier()));
280            if (src.getWhat().hasReference() || src.getWhat().hasDisplay() || src.getWhat().hasExtension() || src.getWhat().hasId())
281                tgt.setReference(VersionConvertor_30_50.convertReference(src.getWhat()));
282        }
283        if (src.hasType())
284            tgt.setType(VersionConvertor_30_50.convertCoding(src.getType()));
285        if (src.hasRole())
286            tgt.setRole(VersionConvertor_30_50.convertCoding(src.getRole()));
287        if (src.hasLifecycle())
288            tgt.setLifecycle(VersionConvertor_30_50.convertCoding(src.getLifecycle()));
289        for (org.hl7.fhir.r5.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(VersionConvertor_30_50.convertCoding(t));
290        if (src.hasName())
291            tgt.setNameElement(VersionConvertor_30_50.convertString(src.getNameElement()));
292        if (src.hasQuery())
293            tgt.setQueryElement(VersionConvertor_30_50.convertBase64Binary(src.getQueryElement()));
294        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) tgt.addDetail(convertAuditEventEntityDetailComponent(t));
295        return tgt;
296    }
297
298    public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
299        if (src == null)
300            return null;
301        org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent();
302        VersionConvertor_30_50.copyElement(src, tgt);
303        if (src.hasType())
304            tgt.setTypeElement(VersionConvertor_30_50.convertString(src.getTypeElement()));
305        if (src.hasValueStringType())
306            tgt.setValue(src.getValueStringType().getValue().getBytes());
307        else if (src.hasValueBase64BinaryType())
308            tgt.setValue(src.getValueBase64BinaryType().getValue());
309        return tgt;
310    }
311
312    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
313        if (src == null)
314            return null;
315        org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent();
316        VersionConvertor_30_50.copyElement(src, tgt);
317        if (src.hasType())
318            tgt.setTypeElement(VersionConvertor_30_50.convertString(src.getTypeElement()));
319        if (src.hasValue())
320            tgt.setValue(new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()));
321        return tgt;
322    }
323
324
325    public static org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
326        if (src == null)
327            return null;
328        org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent();
329        VersionConvertor_30_50.copyElement(src, tgt);
330        if (src.hasSite())
331            tgt.setSiteElement(VersionConvertor_30_50.convertString(src.getSiteElement()));
332        if (src.hasObserver())
333            tgt.setIdentifier(VersionConvertor_30_50.convertIdentifier(src.getObserver().getIdentifier()));
334        for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(VersionConvertor_30_50.convertCoding(t));
335        return tgt;
336    }
337
338    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.dstu3.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
339        if (src == null)
340            return null;
341        org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent();
342        VersionConvertor_30_50.copyElement(src, tgt);
343        if (src.hasSite())
344            tgt.setSiteElement(VersionConvertor_30_50.convertString(src.getSiteElement()));
345        if (src.hasIdentifier())
346            tgt.getObserver().setIdentifier(VersionConvertor_30_50.convertIdentifier(src.getIdentifier()));
347        for (org.hl7.fhir.dstu3.model.Coding t : src.getType()) tgt.addType(VersionConvertor_30_50.convertCoding(t));
348        return tgt;
349    }
350}