001package org.hl7.fhir.convertors.conv40_50;
002
003import org.hl7.fhir.convertors.VersionConvertor_30_50;
004
005import org.hl7.fhir.convertors.VersionConvertor_40_50;
006import org.hl7.fhir.exceptions.FHIRException;
007
008/*
009  Copyright (c) 2011+, HL7, Inc.
010  All rights reserved.
011  
012  Redistribution and use in source and binary forms, with or without modification, 
013  are permitted provided that the following conditions are met:
014  
015   * Redistributions of source code must retain the above copyright notice, this 
016     list of conditions and the following disclaimer.
017   * Redistributions in binary form must reproduce the above copyright notice, 
018     this list of conditions and the following disclaimer in the documentation 
019     and/or other materials provided with the distribution.
020   * Neither the name of HL7 nor the names of its contributors may be used to 
021     endorse or promote products derived from this software without specific 
022     prior written permission.
023  
024  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
025  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
026  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
027  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
028  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
029  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
030  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
031  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
032  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
033  POSSIBILITY OF SUCH DAMAGE.
034  
035*/
036// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
037public class AuditEvent40_50 extends VersionConvertor_40_50 {
038
039    public static org.hl7.fhir.r5.model.AuditEvent convertAuditEvent(org.hl7.fhir.r4.model.AuditEvent src) throws FHIRException {
040        if (src == null)
041            return null;
042        org.hl7.fhir.r5.model.AuditEvent tgt = new org.hl7.fhir.r5.model.AuditEvent();
043        copyDomainResource(src, tgt);
044        if (src.hasType())
045            tgt.setType(convertCoding(src.getType()));
046        for (org.hl7.fhir.r4.model.Coding t : src.getSubtype()) tgt.addSubtype(convertCoding(t));
047        if (src.hasAction())
048            tgt.setActionElement(convertAuditEventAction(src.getActionElement()));
049        if (src.hasPeriod())
050            tgt.setPeriod(convertPeriod(src.getPeriod()));
051        if (src.hasRecorded())
052            tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
053        if (src.hasOutcome())
054            tgt.getOutcome().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/audit-event-outcome").setCode(src.getOutcome().toCode());
055        if (src.hasOutcomeDesc())
056            tgt.getOutcome().setTextElement(convertString(src.getOutcomeDescElement()));
057        for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfEvent()) tgt.addPurposeOfEvent(convertCodeableConcept(t));
058        for (org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent t : src.getAgent()) tgt.addAgent(convertAuditEventAgentComponent(t));
059        if (src.hasSource())
060            tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
061        for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent t : src.getEntity()) tgt.addEntity(convertAuditEventEntityComponent(t));
062        return tgt;
063    }
064
065    public static org.hl7.fhir.r4.model.AuditEvent convertAuditEvent(org.hl7.fhir.r5.model.AuditEvent src) throws FHIRException {
066        if (src == null)
067            return null;
068        org.hl7.fhir.r4.model.AuditEvent tgt = new org.hl7.fhir.r4.model.AuditEvent();
069        copyDomainResource(src, tgt);
070        if (src.hasType())
071            tgt.setType(convertCoding(src.getType()));
072        for (org.hl7.fhir.r5.model.Coding t : src.getSubtype()) tgt.addSubtype(convertCoding(t));
073        if (src.hasAction())
074            tgt.setActionElement(convertAuditEventAction(src.getActionElement()));
075        if (src.hasPeriod())
076            tgt.setPeriod(convertPeriod(src.getPeriod()));
077        if (src.hasRecorded())
078            tgt.setRecordedElement(convertInstant(src.getRecordedElement()));
079        if (src.hasOutcome() && src.getOutcome().hasCoding("http://terminology.hl7.org/CodeSystem/audit-event-outcome"))
080          tgt.getOutcomeElement().setValueAsString(src.getOutcome().getCode("http://terminology.hl7.org/CodeSystem/audit-event-outcome"));
081      if (src.getOutcome().hasText())
082          tgt.setOutcomeDescElement(VersionConvertor_40_50.convertString(src.getOutcome().getTextElement()));
083        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPurposeOfEvent()) tgt.addPurposeOfEvent(convertCodeableConcept(t));
084        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent t : src.getAgent()) tgt.addAgent(convertAuditEventAgentComponent(t));
085        if (src.hasSource())
086            tgt.setSource(convertAuditEventSourceComponent(src.getSource()));
087        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent t : src.getEntity()) tgt.addEntity(convertAuditEventEntityComponent(t));
088        return tgt;
089    }
090
091    static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAction> src) throws FHIRException {
092        if (src == null || src.isEmpty())
093            return null;
094        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());
095        VersionConvertor_40_50.copyElement(src, tgt);
096        switch(src.getValue()) {
097            case C:
098                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.C);
099                break;
100            case R:
101                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.R);
102                break;
103            case U:
104                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.U);
105                break;
106            case D:
107                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.D);
108                break;
109            case E:
110                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.E);
111                break;
112            default:
113                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAction.NULL);
114                break;
115        }
116        return tgt;
117    }
118
119    static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAction> convertAuditEventAction(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAction> src) throws FHIRException {
120        if (src == null || src.isEmpty())
121            return null;
122        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());
123        VersionConvertor_40_50.copyElement(src, tgt);
124        switch(src.getValue()) {
125            case C:
126                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.C);
127                break;
128            case R:
129                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.R);
130                break;
131            case U:
132                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.U);
133                break;
134            case D:
135                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.D);
136                break;
137            case E:
138                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.E);
139                break;
140            default:
141                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAction.NULL);
142                break;
143        }
144        return tgt;
145    }
146
147
148    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
149        if (src == null)
150            return null;
151        org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent();
152        copyElement(src, tgt);
153        if (src.hasType())
154            tgt.setType(convertCodeableConcept(src.getType()));
155        for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t));
156        if (src.hasWho())
157            tgt.setWho(convertReference(src.getWho()));
158        if (src.hasAltId())
159            tgt.setAltIdElement(convertString(src.getAltIdElement()));
160        if (src.hasName())
161            tgt.setNameElement(convertString(src.getNameElement()));
162        if (src.hasRequestor())
163            tgt.setRequestorElement(convertBoolean(src.getRequestorElement()));
164        if (src.hasLocation())
165            tgt.setLocation(convertReference(src.getLocation()));
166        for (org.hl7.fhir.r4.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
167        if (src.hasMedia())
168            tgt.setMedia(convertCoding(src.getMedia()));
169        if (src.hasNetwork())
170            tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
171        for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPurposeOfUse()) tgt.addPurposeOfUse(convertCodeableConcept(t));
172        return tgt;
173    }
174
175    public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent convertAuditEventAgentComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentComponent src) throws FHIRException {
176        if (src == null)
177            return null;
178        org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentComponent();
179        copyElement(src, tgt);
180        if (src.hasType())
181            tgt.setType(convertCodeableConcept(src.getType()));
182        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) tgt.addRole(convertCodeableConcept(t));
183        if (src.hasWho())
184            tgt.setWho(convertReference(src.getWho()));
185        if (src.hasAltId())
186            tgt.setAltIdElement(convertString(src.getAltIdElement()));
187        if (src.hasName())
188            tgt.setNameElement(convertString(src.getNameElement()));
189        if (src.hasRequestor())
190            tgt.setRequestorElement(convertBoolean(src.getRequestorElement()));
191        if (src.hasLocation())
192            tgt.setLocation(convertReference(src.getLocation()));
193        for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.getPolicy().add(convertUri(t));
194        if (src.hasMedia())
195            tgt.setMedia(convertCoding(src.getMedia()));
196        if (src.hasNetwork())
197            tgt.setNetwork(convertAuditEventAgentNetworkComponent(src.getNetwork()));
198        for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPurposeOfUse()) tgt.addPurposeOfUse(convertCodeableConcept(t));
199        return tgt;
200    }
201
202    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
203        if (src == null)
204            return null;
205        org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent();
206        copyElement(src, tgt);
207        if (src.hasAddress())
208            tgt.setAddressElement(convertString(src.getAddressElement()));
209        if (src.hasType())
210            tgt.setTypeElement(convertAuditEventAgentNetworkType(src.getTypeElement()));
211        return tgt;
212    }
213
214    public static org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent convertAuditEventAgentNetworkComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkComponent src) throws FHIRException {
215        if (src == null)
216            return null;
217        org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkComponent();
218        copyElement(src, tgt);
219        if (src.hasAddress())
220            tgt.setAddressElement(convertString(src.getAddressElement()));
221        if (src.hasType())
222            tgt.setTypeElement(convertAuditEventAgentNetworkType(src.getTypeElement()));
223        return tgt;
224    }
225
226    static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType> convertAuditEventAgentNetworkType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType> src) throws FHIRException {
227        if (src == null || src.isEmpty())
228            return null;
229        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());
230        VersionConvertor_40_50.copyElement(src, tgt);
231        switch(src.getValue()) {
232            case _1:
233                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._1);
234                break;
235            case _2:
236                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._2);
237                break;
238            case _3:
239                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._3);
240                break;
241            case _4:
242                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._4);
243                break;
244            case _5:
245                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType._5);
246                break;
247            default:
248                tgt.setValue(org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType.NULL);
249                break;
250        }
251        return tgt;
252    }
253
254    static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType> convertAuditEventAgentNetworkType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.AuditEvent.AuditEventAgentNetworkType> src) throws FHIRException {
255        if (src == null || src.isEmpty())
256            return null;
257        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());
258        VersionConvertor_40_50.copyElement(src, tgt);
259        switch(src.getValue()) {
260            case _1:
261                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._1);
262                break;
263            case _2:
264                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._2);
265                break;
266            case _3:
267                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._3);
268                break;
269            case _4:
270                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._4);
271                break;
272            case _5:
273                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType._5);
274                break;
275            default:
276                tgt.setValue(org.hl7.fhir.r4.model.AuditEvent.AuditEventAgentNetworkType.NULL);
277                break;
278        }
279        return tgt;
280    }
281
282    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
283        if (src == null)
284            return null;
285        org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent();
286        copyElement(src, tgt);
287        if (src.hasSite())
288            tgt.setSiteElement(convertString(src.getSiteElement()));
289        if (src.hasObserver())
290            tgt.setObserver(convertReference(src.getObserver()));
291        for (org.hl7.fhir.r4.model.Coding t : src.getType()) tgt.addType(convertCoding(t));
292        return tgt;
293    }
294
295    public static org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent convertAuditEventSourceComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventSourceComponent src) throws FHIRException {
296        if (src == null)
297            return null;
298        org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventSourceComponent();
299        copyElement(src, tgt);
300        if (src.hasSite())
301            tgt.setSiteElement(convertString(src.getSiteElement()));
302        if (src.hasObserver())
303            tgt.setObserver(convertReference(src.getObserver()));
304        for (org.hl7.fhir.r5.model.Coding t : src.getType()) tgt.addType(convertCoding(t));
305        return tgt;
306    }
307
308    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
309        if (src == null)
310            return null;
311        org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent();
312        copyElement(src, tgt);
313        if (src.hasWhat())
314            tgt.setWhat(convertReference(src.getWhat()));
315        if (src.hasType())
316            tgt.setType(convertCoding(src.getType()));
317        if (src.hasRole())
318            tgt.setRole(convertCoding(src.getRole()));
319        if (src.hasLifecycle())
320            tgt.setLifecycle(convertCoding(src.getLifecycle()));
321        for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(convertCoding(t));
322        if (src.hasName())
323            tgt.setNameElement(convertString(src.getNameElement()));
324        // if (src.hasDescription())
325        // tgt.setDescriptionElement(convertString(src.getDescriptionElement()));
326        if (src.hasQuery())
327            tgt.setQueryElement(convertBase64Binary(src.getQueryElement()));
328        for (org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) tgt.addDetail(convertAuditEventEntityDetailComponent(t));
329        return tgt;
330    }
331
332    public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent convertAuditEventEntityComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityComponent src) throws FHIRException {
333        if (src == null)
334            return null;
335        org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityComponent();
336        copyElement(src, tgt);
337        if (src.hasWhat())
338            tgt.setWhat(convertReference(src.getWhat()));
339        if (src.hasType())
340            tgt.setType(convertCoding(src.getType()));
341        if (src.hasRole())
342            tgt.setRole(convertCoding(src.getRole()));
343        if (src.hasLifecycle())
344            tgt.setLifecycle(convertCoding(src.getLifecycle()));
345        for (org.hl7.fhir.r5.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(convertCoding(t));
346        if (src.hasName())
347            tgt.setNameElement(convertString(src.getNameElement()));
348        // if (src.hasDescription())
349        // tgt.setDescriptionElement(convertString(src.getDescriptionElement()));
350        if (src.hasQuery())
351            tgt.setQueryElement(convertBase64Binary(src.getQueryElement()));
352        for (org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent t : src.getDetail()) tgt.addDetail(convertAuditEventEntityDetailComponent(t));
353        return tgt;
354    }
355
356    public static org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
357        if (src == null)
358            return null;
359        org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent();
360        copyElement(src, tgt);
361        if (src.hasType())
362            tgt.setTypeElement(convertString(src.getTypeElement()));
363        if (src.hasValue())
364            tgt.setValue(convertType(src.getValue()));
365        return tgt;
366    }
367
368    public static org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent convertAuditEventEntityDetailComponent(org.hl7.fhir.r5.model.AuditEvent.AuditEventEntityDetailComponent src) throws FHIRException {
369        if (src == null)
370            return null;
371        org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent tgt = new org.hl7.fhir.r4.model.AuditEvent.AuditEventEntityDetailComponent();
372        copyElement(src, tgt);
373        if (src.hasType())
374            tgt.setTypeElement(convertString(src.getTypeElement()));
375        if (src.hasValue())
376            tgt.setValue(convertType(src.getValue()));
377        return tgt;
378    }
379}