001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.UnsignedInt30_50;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class Group30_50 {
014
015  public static org.hl7.fhir.r5.model.Group convertGroup(org.hl7.fhir.dstu3.model.Group src) throws FHIRException {
016    if (src == null)
017      return null;
018    org.hl7.fhir.r5.model.Group tgt = new org.hl7.fhir.r5.model.Group();
019    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
022    if (src.hasActive())
023      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
024    if (src.hasType())
025      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
026    if (src.hasActual())
027      tgt.setActualElement(Boolean30_50.convertBoolean(src.getActualElement()));
028    if (src.hasCode())
029      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
030    if (src.hasName())
031      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
032    if (src.hasQuantity())
033      tgt.setQuantityElement(UnsignedInt30_50.convertUnsignedInt(src.getQuantityElement()));
034    for (org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
035      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
036    for (org.hl7.fhir.dstu3.model.Group.GroupMemberComponent t : src.getMember())
037      tgt.addMember(convertGroupMemberComponent(t));
038    return tgt;
039  }
040
041  public static org.hl7.fhir.dstu3.model.Group convertGroup(org.hl7.fhir.r5.model.Group src) throws FHIRException {
042    if (src == null)
043      return null;
044    org.hl7.fhir.dstu3.model.Group tgt = new org.hl7.fhir.dstu3.model.Group();
045    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
046    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
047      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
048    if (src.hasActive())
049      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
050    if (src.hasType())
051      tgt.setTypeElement(convertGroupType(src.getTypeElement()));
052    if (src.hasActual())
053      tgt.setActualElement(Boolean30_50.convertBoolean(src.getActualElement()));
054    if (src.hasCode())
055      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
056    if (src.hasName())
057      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
058    if (src.hasQuantity())
059      tgt.setQuantityElement(UnsignedInt30_50.convertUnsignedInt(src.getQuantityElement()));
060    for (org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent t : src.getCharacteristic())
061      tgt.addCharacteristic(convertGroupCharacteristicComponent(t));
062    for (org.hl7.fhir.r5.model.Group.GroupMemberComponent t : src.getMember())
063      tgt.addMember(convertGroupMemberComponent(t));
064    return tgt;
065  }
066
067  public static org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent src) throws FHIRException {
068    if (src == null)
069      return null;
070    org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent();
071    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
072    if (src.hasCode())
073      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
074    if (src.hasValue())
075      tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
076    if (src.hasExclude())
077      tgt.setExcludeElement(Boolean30_50.convertBoolean(src.getExcludeElement()));
078    if (src.hasPeriod())
079      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
080    return tgt;
081  }
082
083  public static org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent src) throws FHIRException {
084    if (src == null)
085      return null;
086    org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupCharacteristicComponent();
087    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
088    if (src.hasCode())
089      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
090    if (src.hasValue())
091      tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
092    if (src.hasExclude())
093      tgt.setExcludeElement(Boolean30_50.convertBoolean(src.getExcludeElement()));
094    if (src.hasPeriod())
095      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
096    return tgt;
097  }
098
099  public static org.hl7.fhir.dstu3.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r5.model.Group.GroupMemberComponent src) throws FHIRException {
100    if (src == null)
101      return null;
102    org.hl7.fhir.dstu3.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.dstu3.model.Group.GroupMemberComponent();
103    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
104    if (src.hasEntity())
105      tgt.setEntity(Reference30_50.convertReference(src.getEntity()));
106    if (src.hasPeriod())
107      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
108    if (src.hasInactive())
109      tgt.setInactiveElement(Boolean30_50.convertBoolean(src.getInactiveElement()));
110    return tgt;
111  }
112
113  public static org.hl7.fhir.r5.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.dstu3.model.Group.GroupMemberComponent src) throws FHIRException {
114    if (src == null)
115      return null;
116    org.hl7.fhir.r5.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r5.model.Group.GroupMemberComponent();
117    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
118    if (src.hasEntity())
119      tgt.setEntity(Reference30_50.convertReference(src.getEntity()));
120    if (src.hasPeriod())
121      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
122    if (src.hasInactive())
123      tgt.setInactiveElement(Boolean30_50.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.r5.model.Enumeration<org.hl7.fhir.r5.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_50.INSTANCE.getVersionConvertor_30_50().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.r5.model.Enumeration<org.hl7.fhir.r5.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.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());
162    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
163    switch (src.getValue()) {
164      case PERSON:
165        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PERSON);
166        break;
167      case ANIMAL:
168        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.ANIMAL);
169        break;
170      case PRACTITIONER:
171        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PRACTITIONER);
172        break;
173      case DEVICE:
174        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.DEVICE);
175        break;
176      case MEDICATION:
177        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.MEDICATION);
178        break;
179      case SUBSTANCE:
180        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.SUBSTANCE);
181        break;
182      default:
183        tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.NULL);
184        break;
185    }
186    return tgt;
187  }
188}