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