001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.UnsignedInt43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r5.model.Group.GroupMembershipBasis;
013
014/*
015  Copyright (c) 2011+, HL7, Inc.
016  All rights reserved.
017  
018  Redistribution and use in source and binary forms, with or without modification, 
019  are permitted provided that the following conditions are met:
020  
021   * Redistributions of source code must retain the above copyright notice, this 
022     list of conditions and the following disclaimer.
023   * Redistributions in binary form must reproduce the above copyright notice, 
024     this list of conditions and the following disclaimer in the documentation 
025     and/or other materials provided with the distribution.
026   * Neither the name of HL7 nor the names of its contributors may be used to 
027     endorse or promote products derived from this software without specific 
028     prior written permission.
029  
030  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
031  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
032  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
033  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
034  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
035  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
036  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
037  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
038  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
039  POSSIBILITY OF SUCH DAMAGE.
040  
041*/
042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
043public class Group43_50 {
044
045  public static org.hl7.fhir.r5.model.Group convertGroup(org.hl7.fhir.r4b.model.Group src) throws FHIRException {
046    if (src == null)
047      return null;
048    org.hl7.fhir.r5.model.Group tgt = new org.hl7.fhir.r5.model.Group();
049    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
050    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
051      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
052    if (src.hasActive())
053      tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement()));
054    if (src.hasType())
055      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
056    if (src.hasActual())
057      tgt.setMembership(src.getActual() ? GroupMembershipBasis.ENUMERATED : GroupMembershipBasis.DEFINITIONAL);
058    if (src.hasCode())
059      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
060    if (src.hasName())
061      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
062    if (src.hasQuantity())
063      tgt.setQuantityElement(UnsignedInt43_50.convertUnsignedInt(src.getQuantityElement()));
064    if (src.hasManagingEntity())
065      tgt.setManagingEntity(Reference43_50.convertReference(src.getManagingEntity()));
066    for (org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
067      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
068    for (org.hl7.fhir.r4b.model.Group.GroupMemberComponent t : src.getMember())
069      tgt.addMember(convertGroupMemberComponent(t));
070    return tgt;
071  }
072
073  public static org.hl7.fhir.r4b.model.Group convertGroup(org.hl7.fhir.r5.model.Group src) throws FHIRException {
074    if (src == null)
075      return null;
076    org.hl7.fhir.r4b.model.Group tgt = new org.hl7.fhir.r4b.model.Group();
077    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
078    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
079      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
080    if (src.hasActive())
081      tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement()));
082    if (src.hasType())
083      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
084    if (src.hasMembership())
085      tgt.setActual(src.getMembership() == GroupMembershipBasis.ENUMERATED);
086    if (src.hasCode())
087      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
088    if (src.hasName())
089      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
090    if (src.hasQuantity())
091      tgt.setQuantityElement(UnsignedInt43_50.convertUnsignedInt(src.getQuantityElement()));
092    if (src.hasManagingEntity())
093      tgt.setManagingEntity(Reference43_50.convertReference(src.getManagingEntity()));
094    for (org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
095      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
096    for (org.hl7.fhir.r5.model.Group.GroupMemberComponent t : src.getMember())
097      tgt.addMember(convertGroupMemberComponent(t));
098    return tgt;
099  }
100
101  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> convertGroupType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> src) throws FHIRException {
102    if (src == null || src.isEmpty())
103      return null;
104    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Group.GroupTypeEnumFactory());
105    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
106    switch (src.getValue()) {
107      case PERSON:
108        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PERSON);
109        break;
110      case ANIMAL:
111        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.ANIMAL);
112        break;
113      case PRACTITIONER:
114        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PRACTITIONER);
115        break;
116      case DEVICE:
117        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.DEVICE);
118        break;
119      default:
120        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.NULL);
121        break;
122    }
123    return tgt;
124  }
125
126  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> convertGroupType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> src) throws FHIRException {
127    if (src == null || src.isEmpty())
128      return null;
129    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Group.GroupTypeEnumFactory());
130    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
131    switch (src.getValue()) {
132      case PERSON:
133        tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.PERSON);
134        break;
135      case ANIMAL:
136        tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.ANIMAL);
137        break;
138      case PRACTITIONER:
139        tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.PRACTITIONER);
140        break;
141      case DEVICE:
142        tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.DEVICE);
143        break;
144      default:
145        tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.NULL);
146        break;
147    }
148    return tgt;
149  }
150
151  public static org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent src) throws FHIRException {
152    if (src == null)
153      return null;
154    org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent();
155    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
156    if (src.hasCode())
157      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
158    if (src.hasValue())
159      tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue()));
160    if (src.hasExclude())
161      tgt.setExcludeElement(Boolean43_50.convertBoolean(src.getExcludeElement()));
162    if (src.hasPeriod())
163      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
164    return tgt;
165  }
166
167  public static org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent src) throws FHIRException {
168    if (src == null)
169      return null;
170    org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent();
171    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
172    if (src.hasCode())
173      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
174    if (src.hasValue())
175      tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue()));
176    if (src.hasExclude())
177      tgt.setExcludeElement(Boolean43_50.convertBoolean(src.getExcludeElement()));
178    if (src.hasPeriod())
179      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
180    return tgt;
181  }
182
183  public static org.hl7.fhir.r5.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r4b.model.Group.GroupMemberComponent src) throws FHIRException {
184    if (src == null)
185      return null;
186    org.hl7.fhir.r5.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r5.model.Group.GroupMemberComponent();
187    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
188    if (src.hasEntity())
189      tgt.setEntity(Reference43_50.convertReference(src.getEntity()));
190    if (src.hasPeriod())
191      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
192    if (src.hasInactive())
193      tgt.setInactiveElement(Boolean43_50.convertBoolean(src.getInactiveElement()));
194    return tgt;
195  }
196
197  public static org.hl7.fhir.r4b.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r5.model.Group.GroupMemberComponent src) throws FHIRException {
198    if (src == null)
199      return null;
200    org.hl7.fhir.r4b.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r4b.model.Group.GroupMemberComponent();
201    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
202    if (src.hasEntity())
203      tgt.setEntity(Reference43_50.convertReference(src.getEntity()));
204    if (src.hasPeriod())
205      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
206    if (src.hasInactive())
207      tgt.setInactiveElement(Boolean43_50.convertBoolean(src.getInactiveElement()));
208    return tgt;
209  }
210}