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.ContactDetail30_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.Timing30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Code30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Integer30_40;
011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.MarkDown30_40;
012import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
013import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Uri30_40;
014import org.hl7.fhir.exceptions.FHIRException;
015import org.hl7.fhir.r4.model.Enumeration;
016import org.hl7.fhir.r4.model.GraphDefinition;
017
018public class GraphDefinition30_40 {
019
020  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode> convertCompartmentCode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode> src) throws FHIRException {
021      if (src == null || src.isEmpty())
022          return null;
023      Enumeration<GraphDefinition.CompartmentCode> tgt = new Enumeration<>(new GraphDefinition.CompartmentCodeEnumFactory());
024      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
025      if (src.getValue() == null) {
026          tgt.setValue(null);
027      } else {
028          switch (src.getValue()) {
029              case PATIENT:
030                  tgt.setValue(GraphDefinition.CompartmentCode.PATIENT);
031                  break;
032              case ENCOUNTER:
033                  tgt.setValue(GraphDefinition.CompartmentCode.ENCOUNTER);
034                  break;
035              case RELATEDPERSON:
036                  tgt.setValue(GraphDefinition.CompartmentCode.RELATEDPERSON);
037                  break;
038              case PRACTITIONER:
039                  tgt.setValue(GraphDefinition.CompartmentCode.PRACTITIONER);
040                  break;
041              case DEVICE:
042                  tgt.setValue(GraphDefinition.CompartmentCode.DEVICE);
043                  break;
044              default:
045                  tgt.setValue(GraphDefinition.CompartmentCode.NULL);
046                  break;
047          }
048      }
049      return tgt;
050  }
051
052  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode> convertCompartmentCode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.GraphDefinition.CompartmentCode> src) throws FHIRException {
053      if (src == null || src.isEmpty())
054          return null;
055      org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCodeEnumFactory());
056      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
057      if (src.getValue() == null) {
058          tgt.setValue(null);
059      } else {
060          switch (src.getValue()) {
061              case PATIENT:
062                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.PATIENT);
063                  break;
064              case ENCOUNTER:
065                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.ENCOUNTER);
066                  break;
067              case RELATEDPERSON:
068                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.RELATEDPERSON);
069                  break;
070              case PRACTITIONER:
071                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.PRACTITIONER);
072                  break;
073              case DEVICE:
074                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.DEVICE);
075                  break;
076              default:
077                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.CompartmentCode.NULL);
078                  break;
079          }
080      }
081      return tgt;
082  }
083
084  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule> convertGraphCompartmentRule(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule> src) throws FHIRException {
085      if (src == null || src.isEmpty())
086          return null;
087      Enumeration<GraphDefinition.GraphCompartmentRule> tgt = new Enumeration<>(new GraphDefinition.GraphCompartmentRuleEnumFactory());
088      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
089      if (src.getValue() == null) {
090          tgt.setValue(null);
091      } else {
092          switch (src.getValue()) {
093              case IDENTICAL:
094                  tgt.setValue(GraphDefinition.GraphCompartmentRule.IDENTICAL);
095                  break;
096              case MATCHING:
097                  tgt.setValue(GraphDefinition.GraphCompartmentRule.MATCHING);
098                  break;
099              case DIFFERENT:
100                  tgt.setValue(GraphDefinition.GraphCompartmentRule.DIFFERENT);
101                  break;
102              case CUSTOM:
103                  tgt.setValue(GraphDefinition.GraphCompartmentRule.CUSTOM);
104                  break;
105              default:
106                  tgt.setValue(GraphDefinition.GraphCompartmentRule.NULL);
107                  break;
108          }
109      }
110      return tgt;
111  }
112
113  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule> convertGraphCompartmentRule(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.GraphDefinition.GraphCompartmentRule> src) throws FHIRException {
114      if (src == null || src.isEmpty())
115          return null;
116      org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRuleEnumFactory());
117      ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
118      if (src.getValue() == null) {
119          tgt.setValue(null);
120      } else {
121          switch (src.getValue()) {
122              case IDENTICAL:
123                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.IDENTICAL);
124                  break;
125              case MATCHING:
126                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.MATCHING);
127                  break;
128              case DIFFERENT:
129                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.DIFFERENT);
130                  break;
131              case CUSTOM:
132                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.CUSTOM);
133                  break;
134              default:
135                  tgt.setValue(org.hl7.fhir.dstu3.model.GraphDefinition.GraphCompartmentRule.NULL);
136                  break;
137          }
138      }
139      return tgt;
140  }
141
142  public static org.hl7.fhir.dstu3.model.GraphDefinition convertGraphDefinition(org.hl7.fhir.r4.model.GraphDefinition src) throws FHIRException {
143    if (src == null)
144      return null;
145    org.hl7.fhir.dstu3.model.GraphDefinition tgt = new org.hl7.fhir.dstu3.model.GraphDefinition();
146    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
147    if (src.hasUrl())
148      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
149    if (src.hasVersion())
150      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
151    if (src.hasName())
152      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
153    if (src.hasStatus())
154      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
155    if (src.hasExperimental())
156      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
157    if (src.hasDateElement())
158      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
159    if (src.hasPublisher())
160      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
161    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
162      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
163    if (src.hasDescription())
164      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
165    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
166      tgt.addUseContext(Timing30_40.convertUsageContext(t));
167    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
168      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
169    if (src.hasPurpose())
170      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
171    if (src.hasStart())
172      tgt.setStartElement(Code30_40.convertCode(src.getStartElement()));
173    if (src.hasProfile())
174      tgt.setProfile(src.getProfile());
175    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
176      tgt.addLink(convertGraphDefinitionLinkComponent(t));
177    return tgt;
178  }
179
180  public static org.hl7.fhir.r4.model.GraphDefinition convertGraphDefinition(org.hl7.fhir.dstu3.model.GraphDefinition src) throws FHIRException {
181    if (src == null)
182      return null;
183    org.hl7.fhir.r4.model.GraphDefinition tgt = new org.hl7.fhir.r4.model.GraphDefinition();
184    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
185    if (src.hasUrl())
186      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
187    if (src.hasVersion())
188      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
189    if (src.hasName())
190      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
191    if (src.hasStatus())
192      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
193    if (src.hasExperimental())
194      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
195    if (src.hasDateElement())
196      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
197    if (src.hasPublisher())
198      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
199    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
200      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
201    if (src.hasDescription())
202      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
203    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
204      tgt.addUseContext(Timing30_40.convertUsageContext(t));
205    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
206      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
207    if (src.hasPurpose())
208      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
209    if (src.hasStart())
210      tgt.setStartElement(Code30_40.convertCode(src.getStartElement()));
211    if (src.hasProfile())
212      tgt.setProfile(src.getProfile());
213    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
214      tgt.addLink(convertGraphDefinitionLinkComponent(t));
215    return tgt;
216  }
217
218  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent convertGraphDefinitionLinkComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent src) throws FHIRException {
219    if (src == null)
220      return null;
221    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent();
222    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
223    if (src.hasPath())
224      tgt.setPathElement(String30_40.convertString(src.getPathElement()));
225    if (src.hasSliceName())
226      tgt.setSliceNameElement(String30_40.convertString(src.getSliceNameElement()));
227    if (src.hasMin())
228      tgt.setMinElement(Integer30_40.convertInteger(src.getMinElement()));
229    if (src.hasMax())
230      tgt.setMaxElement(String30_40.convertString(src.getMaxElement()));
231    if (src.hasDescription())
232      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
233    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent t : src.getTarget())
234      tgt.addTarget(convertGraphDefinitionLinkTargetComponent(t));
235    return tgt;
236  }
237
238  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent convertGraphDefinitionLinkComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent src) throws FHIRException {
239    if (src == null)
240      return null;
241    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent();
242    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
243    if (src.hasPath())
244      tgt.setPathElement(String30_40.convertString(src.getPathElement()));
245    if (src.hasSliceName())
246      tgt.setSliceNameElement(String30_40.convertString(src.getSliceNameElement()));
247    if (src.hasMin())
248      tgt.setMinElement(Integer30_40.convertInteger(src.getMinElement()));
249    if (src.hasMax())
250      tgt.setMaxElement(String30_40.convertString(src.getMaxElement()));
251    if (src.hasDescription())
252      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
253    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent t : src.getTarget())
254      tgt.addTarget(convertGraphDefinitionLinkTargetComponent(t));
255    return tgt;
256  }
257
258  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent convertGraphDefinitionLinkTargetCompartmentComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent src) throws FHIRException {
259    if (src == null)
260      return null;
261    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent();
262    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
263    if (src.hasCode())
264      tgt.setCodeElement(convertCompartmentCode(src.getCodeElement()));
265    if (src.hasRule())
266      tgt.setRuleElement(convertGraphCompartmentRule(src.getRuleElement()));
267    if (src.hasExpression())
268      tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement()));
269    if (src.hasDescription())
270      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
271    return tgt;
272  }
273
274  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent convertGraphDefinitionLinkTargetCompartmentComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent src) throws FHIRException {
275    if (src == null)
276      return null;
277    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent();
278    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
279    if (src.hasCode())
280      tgt.setCodeElement(convertCompartmentCode(src.getCodeElement()));
281    if (src.hasRule())
282      tgt.setRuleElement(convertGraphCompartmentRule(src.getRuleElement()));
283    if (src.hasExpression())
284      tgt.setExpressionElement(String30_40.convertString(src.getExpressionElement()));
285    if (src.hasDescription())
286      tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement()));
287    return tgt;
288  }
289
290  public static org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent convertGraphDefinitionLinkTargetComponent(org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent src) throws FHIRException {
291    if (src == null)
292      return null;
293    org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent tgt = new org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent();
294    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
295    if (src.hasType())
296      tgt.setTypeElement(Code30_40.convertCode(src.getTypeElement()));
297    if (src.hasProfile())
298      tgt.setProfile(src.getProfile());
299    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent t : src.getCompartment())
300      tgt.addCompartment(convertGraphDefinitionLinkTargetCompartmentComponent(t));
301    for (org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
302      tgt.addLink(convertGraphDefinitionLinkComponent(t));
303    return tgt;
304  }
305
306  public static org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent convertGraphDefinitionLinkTargetComponent(org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetComponent src) throws FHIRException {
307    if (src == null)
308      return null;
309    org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent tgt = new org.hl7.fhir.r4.model.GraphDefinition.GraphDefinitionLinkTargetComponent();
310    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
311    if (src.hasType())
312      tgt.setTypeElement(Code30_40.convertCode(src.getTypeElement()));
313    if (src.hasProfile())
314      tgt.setProfile(src.getProfile());
315    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkTargetCompartmentComponent t : src.getCompartment())
316      tgt.addCompartment(convertGraphDefinitionLinkTargetCompartmentComponent(t));
317    for (org.hl7.fhir.dstu3.model.GraphDefinition.GraphDefinitionLinkComponent t : src.getLink())
318      tgt.addLink(convertGraphDefinitionLinkComponent(t));
319    return tgt;
320  }
321}