001package org.hl7.fhir.convertors.conv10_50.resources10_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_50;
004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Reference10_50;
005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.CodeableConcept10_50;
006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Identifier10_50;
007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Period10_50;
008import org.hl7.fhir.exceptions.FHIRException;
009
010public class Flag10_50 {
011
012  public static org.hl7.fhir.r5.model.Flag convertFlag(org.hl7.fhir.dstu2.model.Flag src) throws FHIRException {
013    if (src == null || src.isEmpty())
014      return null;
015    org.hl7.fhir.r5.model.Flag tgt = new org.hl7.fhir.r5.model.Flag();
016    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
017    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
018      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
019    if (src.hasCategory())
020      tgt.addCategory(CodeableConcept10_50.convertCodeableConcept(src.getCategory()));
021    if (src.hasStatus())
022      tgt.setStatusElement(convertFlagStatus(src.getStatusElement()));
023    if (src.hasPeriod())
024      tgt.setPeriod(Period10_50.convertPeriod(src.getPeriod()));
025    if (src.hasSubject())
026      tgt.setSubject(Reference10_50.convertReference(src.getSubject()));
027    if (src.hasEncounter())
028      tgt.setEncounter(Reference10_50.convertReference(src.getEncounter()));
029    if (src.hasAuthor())
030      tgt.setAuthor(Reference10_50.convertReference(src.getAuthor()));
031    if (src.hasCode())
032      tgt.setCode(CodeableConcept10_50.convertCodeableConcept(src.getCode()));
033    return tgt;
034  }
035
036  public static org.hl7.fhir.dstu2.model.Flag convertFlag(org.hl7.fhir.r5.model.Flag src) throws FHIRException {
037    if (src == null || src.isEmpty())
038      return null;
039    org.hl7.fhir.dstu2.model.Flag tgt = new org.hl7.fhir.dstu2.model.Flag();
040    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
041    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
042      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
043    if (src.hasCategory())
044      tgt.setCategory(CodeableConcept10_50.convertCodeableConcept(src.getCategoryFirstRep()));
045    if (src.hasStatus())
046      tgt.setStatusElement(convertFlagStatus(src.getStatusElement()));
047    if (src.hasPeriod())
048      tgt.setPeriod(Period10_50.convertPeriod(src.getPeriod()));
049    if (src.hasSubject())
050      tgt.setSubject(Reference10_50.convertReference(src.getSubject()));
051    if (src.hasEncounter())
052      tgt.setEncounter(Reference10_50.convertReference(src.getEncounter()));
053    if (src.hasAuthor())
054      tgt.setAuthor(Reference10_50.convertReference(src.getAuthor()));
055    if (src.hasCode())
056      tgt.setCode(CodeableConcept10_50.convertCodeableConcept(src.getCode()));
057    return tgt;
058  }
059
060  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Flag.FlagStatus> convertFlagStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> src) throws FHIRException {
061    if (src == null || src.isEmpty())
062      return null;
063    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Flag.FlagStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Flag.FlagStatusEnumFactory());
064    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
065    switch (src.getValue()) {
066      case ACTIVE:
067        tgt.setValue(org.hl7.fhir.dstu2.model.Flag.FlagStatus.ACTIVE);
068        break;
069      case INACTIVE:
070        tgt.setValue(org.hl7.fhir.dstu2.model.Flag.FlagStatus.INACTIVE);
071        break;
072      case ENTEREDINERROR:
073        tgt.setValue(org.hl7.fhir.dstu2.model.Flag.FlagStatus.ENTEREDINERROR);
074        break;
075      default:
076        tgt.setValue(org.hl7.fhir.dstu2.model.Flag.FlagStatus.NULL);
077        break;
078    }
079    return tgt;
080  }
081
082  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> convertFlagStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Flag.FlagStatus> src) throws FHIRException {
083    if (src == null || src.isEmpty())
084      return null;
085    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Flag.FlagStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Flag.FlagStatusEnumFactory());
086    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
087    switch (src.getValue()) {
088      case ACTIVE:
089        tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.ACTIVE);
090        break;
091      case INACTIVE:
092        tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.INACTIVE);
093        break;
094      case ENTEREDINERROR:
095        tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.ENTEREDINERROR);
096        break;
097      default:
098        tgt.setValue(org.hl7.fhir.r5.model.Flag.FlagStatus.NULL);
099        break;
100    }
101    return tgt;
102  }
103}