001package org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_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.primitivetypes30_50.String30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
007import org.hl7.fhir.exceptions.FHIRException;
008
009public class Identifier30_50 {
010  public static org.hl7.fhir.r5.model.Identifier convertIdentifier(org.hl7.fhir.dstu3.model.Identifier src) throws FHIRException {
011    if (src == null) return null;
012    org.hl7.fhir.r5.model.Identifier tgt = new org.hl7.fhir.r5.model.Identifier();
013    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
014    if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement()));
015    if (src.hasType()) tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
016    if (src.hasSystem()) tgt.setSystemElement(Uri30_50.convertUri(src.getSystemElement()));
017    if (src.hasValue()) tgt.setValueElement(String30_50.convertString(src.getValueElement()));
018    if (src.hasPeriod()) tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
019    if (src.hasAssigner()) tgt.setAssigner(Reference30_50.convertReference(src.getAssigner()));
020    return tgt;
021  }
022
023  public static org.hl7.fhir.dstu3.model.Identifier convertIdentifier(org.hl7.fhir.r5.model.Identifier src) throws FHIRException {
024    if (src == null) return null;
025    org.hl7.fhir.dstu3.model.Identifier tgt = new org.hl7.fhir.dstu3.model.Identifier();
026    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
027    if (src.hasUse()) tgt.setUseElement(convertIdentifierUse(src.getUseElement()));
028    if (src.hasType()) tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
029    if (src.hasSystem()) tgt.setSystemElement(Uri30_50.convertUri(src.getSystemElement()));
030    if (src.hasValue()) tgt.setValueElement(String30_50.convertString(src.getValueElement()));
031    if (src.hasPeriod()) tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
032    if (src.hasAssigner()) tgt.setAssigner(Reference30_50.convertReference(src.getAssigner()));
033    return tgt;
034  }
035
036  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Identifier.IdentifierUse> convertIdentifierUse(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Identifier.IdentifierUse> src) throws FHIRException {
037    if (src == null || src.isEmpty()) return null;
038    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Identifier.IdentifierUse> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Identifier.IdentifierUseEnumFactory());
039    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
040    if (src.getValue() == null) {
041      tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL);
042    } else {
043      switch (src.getValue()) {
044        case USUAL:
045          tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.USUAL);
046          break;
047        case OFFICIAL:
048          tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.OFFICIAL);
049          break;
050        case TEMP:
051          tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.TEMP);
052          break;
053        case SECONDARY:
054          tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.SECONDARY);
055          break;
056        default:
057          tgt.setValue(org.hl7.fhir.r5.model.Identifier.IdentifierUse.NULL);
058          break;
059      }
060    }
061    return tgt;
062  }
063
064  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Identifier.IdentifierUse> convertIdentifierUse(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Identifier.IdentifierUse> src) throws FHIRException {
065    if (src == null || src.isEmpty()) return null;
066    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Identifier.IdentifierUse> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Identifier.IdentifierUseEnumFactory());
067    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
068    if (src.getValue() == null) {
069      tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL);
070    } else {
071      switch (src.getValue()) {
072        case USUAL:
073          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.USUAL);
074          break;
075        case OFFICIAL:
076          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.OFFICIAL);
077          break;
078        case TEMP:
079          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP);
080          break;
081        case OLD:
082          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.TEMP);
083          break;
084        case SECONDARY:
085          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.SECONDARY);
086          break;
087        default:
088          tgt.setValue(org.hl7.fhir.dstu3.model.Identifier.IdentifierUse.NULL);
089          break;
090      }
091    }
092    return tgt;
093  }
094}