001package org.hl7.fhir.convertors.conv10_30;
002
003import org.hl7.fhir.convertors.VersionConvertor_10_30;
004import org.hl7.fhir.exceptions.FHIRException;
005
006public class Account10_30 {
007
008    public static org.hl7.fhir.dstu2.model.Account convertAccount(org.hl7.fhir.dstu3.model.Account src) throws FHIRException {
009        if (src == null || src.isEmpty())
010            return null;
011        org.hl7.fhir.dstu2.model.Account tgt = new org.hl7.fhir.dstu2.model.Account();
012        VersionConvertor_10_30.copyDomainResource(src, tgt);
013        for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(t));
014        if (src.hasNameElement())
015            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
016        if (src.hasType())
017            tgt.setType(VersionConvertor_10_30.convertCodeableConcept(src.getType()));
018        if (src.hasStatus())
019            tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
020        if (src.hasActive())
021            tgt.setActivePeriod(VersionConvertor_10_30.convertPeriod(src.getActive()));
022        if (src.hasBalance())
023            tgt.setBalance(VersionConvertor_10_30.convertMoney(src.getBalance()));
024        if (src.hasSubject())
025            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getSubject()));
026        if (src.hasOwner())
027            tgt.setOwner(VersionConvertor_10_30.convertReference(src.getOwner()));
028        if (src.hasDescriptionElement())
029            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
030        return tgt;
031    }
032
033    public static org.hl7.fhir.dstu3.model.Account convertAccount(org.hl7.fhir.dstu2.model.Account src) throws FHIRException {
034        if (src == null || src.isEmpty())
035            return null;
036        org.hl7.fhir.dstu3.model.Account tgt = new org.hl7.fhir.dstu3.model.Account();
037        VersionConvertor_10_30.copyDomainResource(src, tgt);
038        for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(VersionConvertor_10_30.convertIdentifier(t));
039        if (src.hasName())
040            tgt.setNameElement(VersionConvertor_10_30.convertString(src.getNameElement()));
041        if (src.hasType())
042            tgt.setType(VersionConvertor_10_30.convertCodeableConcept(src.getType()));
043        if (src.hasStatus())
044            tgt.setStatusElement(convertAccountStatus(src.getStatusElement()));
045        if (src.hasActivePeriod())
046            tgt.setActive(VersionConvertor_10_30.convertPeriod(src.getActivePeriod()));
047        if (src.hasBalance())
048            tgt.setBalance(VersionConvertor_10_30.convertMoney(src.getBalance()));
049        if (src.hasSubject())
050            tgt.setSubject(VersionConvertor_10_30.convertReference(src.getSubject()));
051        if (src.hasOwner())
052            tgt.setOwner(VersionConvertor_10_30.convertReference(src.getOwner()));
053        if (src.hasDescriptionElement())
054            tgt.setDescriptionElement(VersionConvertor_10_30.convertString(src.getDescriptionElement()));
055        return tgt;
056    }
057
058    static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Account.AccountStatus> convertAccountStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Account.AccountStatus> src) throws FHIRException {
059        if (src == null || src.isEmpty())
060            return null;
061        org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Account.AccountStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Account.AccountStatusEnumFactory());
062        VersionConvertor_10_30.copyElement(src, tgt);
063        switch(src.getValue()) {
064            case ACTIVE:
065                tgt.setValue(org.hl7.fhir.dstu3.model.Account.AccountStatus.ACTIVE);
066                break;
067            case INACTIVE:
068                tgt.setValue(org.hl7.fhir.dstu3.model.Account.AccountStatus.INACTIVE);
069                break;
070            default:
071                tgt.setValue(org.hl7.fhir.dstu3.model.Account.AccountStatus.NULL);
072                break;
073        }
074        return tgt;
075    }
076
077    static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Account.AccountStatus> convertAccountStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Account.AccountStatus> src) throws FHIRException {
078        if (src == null || src.isEmpty())
079            return null;
080        org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Account.AccountStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Account.AccountStatusEnumFactory());
081        VersionConvertor_10_30.copyElement(src, tgt);
082        switch(src.getValue()) {
083            case ACTIVE:
084                tgt.setValue(org.hl7.fhir.dstu2.model.Account.AccountStatus.ACTIVE);
085                break;
086            case INACTIVE:
087                tgt.setValue(org.hl7.fhir.dstu2.model.Account.AccountStatus.INACTIVE);
088                break;
089            default:
090                tgt.setValue(org.hl7.fhir.dstu2.model.Account.AccountStatus.NULL);
091                break;
092        }
093        return tgt;
094    }
095}