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.exceptions.FHIRException;
009
010public class Flag30_50 {
011
012  public static org.hl7.fhir.r5.model.Flag convertFlag(org.hl7.fhir.dstu3.model.Flag src) throws FHIRException {
013    if (src == null)
014      return null;
015    org.hl7.fhir.r5.model.Flag tgt = new org.hl7.fhir.r5.model.Flag();
016    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
017    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
018      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
019    if (src.hasStatus())
020      tgt.setStatusElement(convertFlagStatus(src.getStatusElement()));
021    if (src.hasCategory())
022      tgt.addCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategory()));
023    if (src.hasCode())
024      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
025    if (src.hasSubject())
026      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
027    if (src.hasPeriod())
028      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
029    if (src.hasEncounter())
030      tgt.setEncounter(Reference30_50.convertReference(src.getEncounter()));
031    if (src.hasAuthor())
032      tgt.setAuthor(Reference30_50.convertReference(src.getAuthor()));
033    return tgt;
034  }
035
036  public static org.hl7.fhir.dstu3.model.Flag convertFlag(org.hl7.fhir.r5.model.Flag src) throws FHIRException {
037    if (src == null)
038      return null;
039    org.hl7.fhir.dstu3.model.Flag tgt = new org.hl7.fhir.dstu3.model.Flag();
040    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
041    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
042      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
043    if (src.hasStatus())
044      tgt.setStatusElement(convertFlagStatus(src.getStatusElement()));
045    if (src.hasCategory())
046      tgt.setCategory(CodeableConcept30_50.convertCodeableConcept(src.getCategoryFirstRep()));
047    if (src.hasCode())
048      tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode()));
049    if (src.hasSubject())
050      tgt.setSubject(Reference30_50.convertReference(src.getSubject()));
051    if (src.hasPeriod())
052      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
053    if (src.hasEncounter())
054      tgt.setEncounter(Reference30_50.convertReference(src.getEncounter()));
055    if (src.hasAuthor())
056      tgt.setAuthor(Reference30_50.convertReference(src.getAuthor()));
057    return tgt;
058  }
059
060  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.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.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Flag.FlagStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Flag.FlagStatusEnumFactory());
064    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
065    switch (src.getValue()) {
066      case ACTIVE:
067        tgt.setValue(org.hl7.fhir.dstu3.model.Flag.FlagStatus.ACTIVE);
068        break;
069      case INACTIVE:
070        tgt.setValue(org.hl7.fhir.dstu3.model.Flag.FlagStatus.INACTIVE);
071        break;
072      case ENTEREDINERROR:
073        tgt.setValue(org.hl7.fhir.dstu3.model.Flag.FlagStatus.ENTEREDINERROR);
074        break;
075      default:
076        tgt.setValue(org.hl7.fhir.dstu3.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.dstu3.model.Enumeration<org.hl7.fhir.dstu3.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    ConversionContext30_50.INSTANCE.getVersionConvertor_30_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}