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.Annotation30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_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.DateTime30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
011import org.hl7.fhir.exceptions.FHIRException;
012import org.hl7.fhir.r5.model.CodeableReference;
013
014public class FamilyMemberHistory30_50 {
015
016  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus> convertFamilyHistoryStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> src) throws FHIRException {
017    if (src == null || src.isEmpty())
018      return null;
019    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatusEnumFactory());
020    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
021    switch (src.getValue()) {
022      case PARTIAL:
023        tgt.setValue(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL);
024        break;
025      case COMPLETED:
026        tgt.setValue(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED);
027        break;
028      case ENTEREDINERROR:
029        tgt.setValue(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR);
030        break;
031      case HEALTHUNKNOWN:
032        tgt.setValue(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN);
033        break;
034      default:
035        tgt.setValue(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus.NULL);
036        break;
037    }
038    return tgt;
039  }
040
041  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> convertFamilyHistoryStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyHistoryStatus> src) throws FHIRException {
042    if (src == null || src.isEmpty())
043      return null;
044    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatusEnumFactory());
045    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
046    switch (src.getValue()) {
047      case PARTIAL:
048        tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL);
049        break;
050      case COMPLETED:
051        tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED);
052        break;
053      case ENTEREDINERROR:
054        tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR);
055        break;
056      case HEALTHUNKNOWN:
057        tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN);
058        break;
059      default:
060        tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.NULL);
061        break;
062    }
063    return tgt;
064  }
065
066  public static org.hl7.fhir.dstu3.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.r5.model.FamilyMemberHistory src) throws FHIRException {
067    if (src == null)
068      return null;
069    org.hl7.fhir.dstu3.model.FamilyMemberHistory tgt = new org.hl7.fhir.dstu3.model.FamilyMemberHistory();
070    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
071    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
072      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
073    for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesCanonical())
074      tgt.addDefinition(new org.hl7.fhir.dstu3.model.Reference(t.getValue()));
075    if (src.hasStatus())
076      tgt.setStatusElement(convertFamilyHistoryStatus(src.getStatusElement()));
077    if (src.hasDataAbsentReason())
078      tgt.setNotDoneReason(CodeableConcept30_50.convertCodeableConcept(src.getDataAbsentReason()));
079    if (src.hasPatient())
080      tgt.setPatient(Reference30_50.convertReference(src.getPatient()));
081    if (src.hasDate())
082      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
083    if (src.hasName())
084      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
085    if (src.hasRelationship())
086      tgt.setRelationship(CodeableConcept30_50.convertCodeableConcept(src.getRelationship()));
087    if (src.hasBorn())
088      tgt.setBorn(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getBorn()));
089    if (src.hasAge())
090      tgt.setAge(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getAge()));
091    if (src.hasEstimatedAge())
092      tgt.setEstimatedAgeElement(Boolean30_50.convertBoolean(src.getEstimatedAgeElement()));
093    if (src.hasDeceased())
094      tgt.setDeceased(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getDeceased()));
095    for (CodeableReference t : src.getReason())
096      if (t.hasConcept())
097        tgt.addReasonCode(CodeableConcept30_50.convertCodeableConcept(t.getConcept()));
098    for (CodeableReference t : src.getReason())
099      if (t.hasReference())
100        tgt.addReasonReference(Reference30_50.convertReference(t.getReference()));
101    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
102    for (org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition())
103      tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t));
104    return tgt;
105  }
106
107  public static org.hl7.fhir.r5.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.dstu3.model.FamilyMemberHistory src) throws FHIRException {
108    if (src == null)
109      return null;
110    org.hl7.fhir.r5.model.FamilyMemberHistory tgt = new org.hl7.fhir.r5.model.FamilyMemberHistory();
111    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
112    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
113      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
114    for (org.hl7.fhir.dstu3.model.Reference t : src.getDefinition()) tgt.addInstantiatesCanonical(t.getReference());
115    if (src.hasStatus())
116      tgt.setStatusElement(convertFamilyHistoryStatus(src.getStatusElement()));
117    if (src.hasNotDoneReason())
118      tgt.setDataAbsentReason(CodeableConcept30_50.convertCodeableConcept(src.getNotDoneReason()));
119    if (src.hasPatient())
120      tgt.setPatient(Reference30_50.convertReference(src.getPatient()));
121    if (src.hasDate())
122      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
123    if (src.hasName())
124      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
125    if (src.hasRelationship())
126      tgt.setRelationship(CodeableConcept30_50.convertCodeableConcept(src.getRelationship()));
127    if (src.hasBorn())
128      tgt.setBorn(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getBorn()));
129    if (src.hasAge())
130      tgt.setAge(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getAge()));
131    if (src.hasEstimatedAge())
132      tgt.setEstimatedAgeElement(Boolean30_50.convertBoolean(src.getEstimatedAgeElement()));
133    if (src.hasDeceased())
134      tgt.setDeceased(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getDeceased()));
135    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode())
136      tgt.addReason(Reference30_50.convertCodeableConceptToCodableReference(t));
137    for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference())
138      tgt.addReason(Reference30_50.convertReferenceToCodableReference(t));
139    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
140    for (org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition())
141      tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t));
142    return tgt;
143  }
144
145  public static org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException {
146    if (src == null)
147      return null;
148    org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent();
149    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
150    if (src.hasCode())
151      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
152    if (src.hasOutcome())
153      tgt.setOutcome(CodeableConcept30_50.convertCodeableConcept(src.getOutcome()));
154    if (src.hasOnset())
155      tgt.setOnset(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getOnset()));
156    for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
157    return tgt;
158  }
159
160  public static org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException {
161    if (src == null)
162      return null;
163    org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.dstu3.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent();
164    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
165    if (src.hasCode())
166      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
167    if (src.hasOutcome())
168      tgt.setOutcome(CodeableConcept30_50.convertCodeableConcept(src.getOutcome()));
169    if (src.hasOnset())
170      tgt.setOnset(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getOnset()));
171    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation30_50.convertAnnotation(t));
172    return tgt;
173  }
174}