001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Period30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.UnsignedInt30_40;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class Group30_40 {
014
015  public static org.hl7.fhir.dstu3.model.Group convertGroup(org.hl7.fhir.r4.model.Group src) throws FHIRException {
016    if (src == null)
017      return null;
018    org.hl7.fhir.dstu3.model.Group tgt = new org.hl7.fhir.dstu3.model.Group();
019    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
022    if (src.hasActive())
023      tgt.setActiveElement(Boolean30_40.convertBoolean(src.getActiveElement()));
024    if (src.hasType())
025      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
026    if (src.hasActual())
027      tgt.setActualElement(Boolean30_40.convertBoolean(src.getActualElement()));
028    if (src.hasCode())
029      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
030    if (src.hasName())
031      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
032    if (src.hasQuantity())
033      tgt.setQuantityElement(UnsignedInt30_40.convertUnsignedInt(src.getQuantityElement()));
034    for (org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
035      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
036    for (org.hl7.fhir.r4.model.Group.GroupMemberComponent t : src.getMember())
037      tgt.addMember(convertGroupMemberComponent(t));
038    return tgt;
039  }
040
041  public static org.hl7.fhir.r4.model.Group convertGroup(org.hl7.fhir.dstu3.model.Group src) throws FHIRException {
042    if (src == null)
043      return null;
044    org.hl7.fhir.r4.model.Group tgt = new org.hl7.fhir.r4.model.Group();
045    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
046    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
047      tgt.addIdentifier(Identifier30_40.convertIdentifier(t));
048    if (src.hasActive())
049      tgt.setActiveElement(Boolean30_40.convertBoolean(src.getActiveElement()));
050    if (src.hasType())
051      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
052    if (src.hasActual())
053      tgt.setActualElement(Boolean30_40.convertBoolean(src.getActualElement()));
054    if (src.hasCode())
055      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
056    if (src.hasName())
057      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
058    if (src.hasQuantity())
059      tgt.setQuantityElement(UnsignedInt30_40.convertUnsignedInt(src.getQuantityElement()));
060    for (org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
061      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
062    for (org.hl7.fhir.dstu3.model.Group.GroupMemberComponent t : src.getMember())
063      tgt.addMember(convertGroupMemberComponent(t));
064    return tgt;
065  }
066
067  public static org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent src) throws FHIRException {
068    if (src == null)
069      return null;
070    org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent();
071    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
072    if (src.hasCode())
073      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
074    if (src.hasValue())
075      tgt.setValue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValue()));
076    if (src.hasExclude())
077      tgt.setExcludeElement(Boolean30_40.convertBoolean(src.getExcludeElement()));
078    if (src.hasPeriod())
079      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
080    return tgt;
081  }
082
083  public static org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent src) throws FHIRException {
084    if (src == null)
085      return null;
086    org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent();
087    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
088    if (src.hasCode())
089      tgt.setCode(CodeableConcept30_40.convertCodeableConcept(src.getCode()));
090    if (src.hasValue())
091      tgt.setValue(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValue()));
092    if (src.hasExclude())
093      tgt.setExcludeElement(Boolean30_40.convertBoolean(src.getExcludeElement()));
094    if (src.hasPeriod())
095      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
096    return tgt;
097  }
098
099  public static org.hl7.fhir.r4.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.dstu3.model.Group.GroupMemberComponent src) throws FHIRException {
100    if (src == null)
101      return null;
102    org.hl7.fhir.r4.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r4.model.Group.GroupMemberComponent();
103    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
104    if (src.hasEntity())
105      tgt.setEntity(Reference30_40.convertReference(src.getEntity()));
106    if (src.hasPeriod())
107      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
108    if (src.hasInactive())
109      tgt.setInactiveElement(Boolean30_40.convertBoolean(src.getInactiveElement()));
110    return tgt;
111  }
112
113  public static org.hl7.fhir.dstu3.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r4.model.Group.GroupMemberComponent src) throws FHIRException {
114    if (src == null)
115      return null;
116    org.hl7.fhir.dstu3.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupMemberComponent();
117    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
118    if (src.hasEntity())
119      tgt.setEntity(Reference30_40.convertReference(src.getEntity()));
120    if (src.hasPeriod())
121      tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
122    if (src.hasInactive())
123      tgt.setInactiveElement(Boolean30_40.convertBoolean(src.getInactiveElement()));
124    return tgt;
125  }
126
127  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Group.GroupType> convertGroupType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> src) throws FHIRException {
128    if (src == null || src.isEmpty())
129      return null;
130    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Group.GroupType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Group.GroupTypeEnumFactory());
131    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
132    switch (src.getValue()) {
133      case PERSON:
134        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.PERSON);
135        break;
136      case ANIMAL:
137        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.ANIMAL);
138        break;
139      case PRACTITIONER:
140        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.PRACTITIONER);
141        break;
142      case DEVICE:
143        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.DEVICE);
144        break;
145      case MEDICATION:
146        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.MEDICATION);
147        break;
148      case SUBSTANCE:
149        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.SUBSTANCE);
150        break;
151      default:
152        tgt.setValue(org.hl7.fhir.dstu3.model.Group.GroupType.NULL);
153        break;
154    }
155    return tgt;
156  }
157
158  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> convertGroupType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Group.GroupType> src) throws FHIRException {
159    if (src == null || src.isEmpty())
160      return null;
161    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Group.GroupTypeEnumFactory());
162    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
163    switch (src.getValue()) {
164      case PERSON:
165        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.PERSON);
166        break;
167      case ANIMAL:
168        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.ANIMAL);
169        break;
170      case PRACTITIONER:
171        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.PRACTITIONER);
172        break;
173      case DEVICE:
174        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.DEVICE);
175        break;
176      case MEDICATION:
177        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.MEDICATION);
178        break;
179      case SUBSTANCE:
180        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.SUBSTANCE);
181        break;
182      default:
183        tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.NULL);
184        break;
185    }
186    return tgt;
187  }
188}