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.Identifier30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
009import org.hl7.fhir.exceptions.FHIRException;
010
011public class QuestionnaireResponse30_50 {
012
013  public static org.hl7.fhir.r5.model.QuestionnaireResponse convertQuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse src) throws FHIRException {
014    if (src == null)
015      return null;
016    org.hl7.fhir.r5.model.QuestionnaireResponse tgt = new org.hl7.fhir.r5.model.QuestionnaireResponse();
017    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
018    if (src.hasIdentifier())
019      tgt.addIdentifier(Identifier30_50.convertIdentifier(src.getIdentifier()));
020    for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_50.convertReference(t));
021    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent()) tgt.addPartOf(Reference30_50.convertReference(t));
022    if (src.hasQuestionnaire())
023      tgt.setQuestionnaireElement(Reference30_50.convertReferenceToCanonical(src.getQuestionnaire()));
024    if (src.hasStatus())
025      tgt.setStatusElement(convertQuestionnaireResponseStatus(src.getStatusElement()));
026    if (src.hasSubject())
027      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
028    if (src.hasContext())
029      tgt.setEncounter(Reference30_50.convertReference(src.getContext()));
030    if (src.hasAuthored())
031      tgt.setAuthoredElement(DateTime30_50.convertDateTime(src.getAuthoredElement()));
032    if (src.hasAuthor())
033      tgt.setAuthor(Reference30_50.convertReference(src.getAuthor()));
034    if (src.hasSource())
035      tgt.setSource(Reference30_50.convertReference(src.getSource()));
036    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
037      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
038    return tgt;
039  }
040
041  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse convertQuestionnaireResponse(org.hl7.fhir.r5.model.QuestionnaireResponse src) throws FHIRException {
042    if (src == null)
043      return null;
044    org.hl7.fhir.dstu3.model.QuestionnaireResponse tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse();
045    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
046    if (src.hasIdentifier())
047      tgt.setIdentifier(Identifier30_50.convertIdentifier(src.getIdentifierFirstRep()));
048    for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference30_50.convertReference(t));
049    for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addParent(Reference30_50.convertReference(t));
050    if (src.hasQuestionnaire())
051      tgt.setQuestionnaire(Reference30_50.convertCanonicalToReference(src.getQuestionnaireElement()));
052    if (src.hasStatus())
053      tgt.setStatusElement(convertQuestionnaireResponseStatus(src.getStatusElement()));
054    if (src.hasSubject())
055      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
056    if (src.hasEncounter())
057      tgt.setContext(Reference30_50.convertReference(src.getEncounter()));
058    if (src.hasAuthored())
059      tgt.setAuthoredElement(DateTime30_50.convertDateTime(src.getAuthoredElement()));
060    if (src.hasAuthor())
061      tgt.setAuthor(Reference30_50.convertReference(src.getAuthor()));
062    if (src.hasSource())
063      tgt.setSource(Reference30_50.convertReference(src.getSource()));
064    for (org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
065      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
066    return tgt;
067  }
068
069  public static org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent convertQuestionnaireResponseItemAnswerComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent src) throws FHIRException {
070    if (src == null)
071      return null;
072    org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent tgt = new org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent();
073    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
074    if (src.hasValue())
075      tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
076    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
077      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
078    return tgt;
079  }
080
081  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent convertQuestionnaireResponseItemAnswerComponent(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent src) throws FHIRException {
082    if (src == null)
083      return null;
084    org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent();
085    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
086    if (src.hasValue())
087      tgt.setValue(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValue()));
088    for (org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
089      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
090    return tgt;
091  }
092
093  public static org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseItemComponent(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException {
094    if (src == null)
095      return null;
096    org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent();
097    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
098    if (src.hasLinkId())
099      tgt.setLinkIdElement(String30_50.convertString(src.getLinkIdElement()));
100    if (src.hasDefinition())
101      tgt.setDefinitionElement(Uri30_50.convertUri(src.getDefinitionElement()));
102    if (src.hasText())
103      tgt.setTextElement(String30_50.convertString(src.getTextElement()));
104    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer())
105      tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t));
106    for (org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
107      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
108    return tgt;
109  }
110
111  public static org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent convertQuestionnaireResponseItemComponent(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent src) throws FHIRException {
112    if (src == null)
113      return null;
114    org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent tgt = new org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent();
115    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
116    if (src.hasLinkId())
117      tgt.setLinkIdElement(String30_50.convertString(src.getLinkIdElement()));
118    if (src.hasDefinition())
119      tgt.setDefinitionElement(Uri30_50.convertUri(src.getDefinitionElement()));
120    if (src.hasText())
121      tgt.setTextElement(String30_50.convertString(src.getTextElement()));
122    for (org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent t : src.getAnswer())
123      tgt.addAnswer(convertQuestionnaireResponseItemAnswerComponent(t));
124    for (org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseItemComponent t : src.getItem())
125      tgt.addItem(convertQuestionnaireResponseItemComponent(t));
126    return tgt;
127  }
128
129  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus> convertQuestionnaireResponseStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus> src) throws FHIRException {
130    if (src == null || src.isEmpty())
131      return null;
132    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatusEnumFactory());
133    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
134    switch (src.getValue()) {
135      case INPROGRESS:
136        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS);
137        break;
138      case COMPLETED:
139        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED);
140        break;
141      case AMENDED:
142        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED);
143        break;
144      case ENTEREDINERROR:
145        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.ENTEREDINERROR);
146        break;
147      case STOPPED:
148        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.STOPPED);
149        break;
150      default:
151        tgt.setValue(org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL);
152        break;
153    }
154    return tgt;
155  }
156
157  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus> convertQuestionnaireResponseStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.QuestionnaireResponse.QuestionnaireResponseStatus> src) throws FHIRException {
158    if (src == null || src.isEmpty())
159      return null;
160    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatusEnumFactory());
161    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
162    switch (src.getValue()) {
163      case INPROGRESS:
164        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.INPROGRESS);
165        break;
166      case COMPLETED:
167        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED);
168        break;
169      case AMENDED:
170        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.AMENDED);
171        break;
172      case ENTEREDINERROR:
173        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.ENTEREDINERROR);
174        break;
175      case STOPPED:
176        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.STOPPED);
177        break;
178      default:
179        tgt.setValue(org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus.NULL);
180        break;
181    }
182    return tgt;
183  }
184}