Exemplo n.º 1
0
        protected static FR_L5EM_GEBAIFBPID_1111 Execute(DbConnection Connection, DbTransaction Transaction, P_L5EM_GEBAIFBPID_1111 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L5EM_GEBAIFBPID_1111();

            ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query bankAcc2BPQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query();
            bankAcc2BPQuery.CMN_BPT_BusinessParticipant_RefID = Parameter.BusinessParticipantID;
            bankAcc2BPQuery.IsDeleted    = false;
            bankAcc2BPQuery.Tenant_RefID = securityTicket.TenantID;

            var bankAcc2BPQueryResult = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, bankAcc2BPQuery);

            if (bankAcc2BPQueryResult.Count == 0)
            {
                return(null);
            }

            ORM_ACC_BNK_BankAccount.Query bankAccQuery = new ORM_ACC_BNK_BankAccount.Query();
            bankAccQuery.ACC_BNK_BankAccountID = bankAcc2BPQueryResult.FirstOrDefault().ACC_BNK_BankAccount_RefID;
            bankAccQuery.IsDeleted             = false;
            bankAccQuery.Tenant_RefID          = securityTicket.TenantID;

            var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccQuery).FirstOrDefault();

            ORM_ACC_BNK_Bank.Query banksQuery = new ORM_ACC_BNK_Bank.Query();
            banksQuery.ACC_BNK_BankID = bankAccount.Bank_RefID;
            banksQuery.IsDeleted      = false;
            banksQuery.Tenant_RefID   = securityTicket.TenantID;

            var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, banksQuery).FirstOrDefault();

            L5EM_GEBAIFBPID_1111 result = new L5EM_GEBAIFBPID_1111();
            result.BankName = bank.BankName;
            result.BIC      = bank.BICCode;
            result.IBAN     = bankAccount.IBAN;

            returnValue.Result = result;

            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, PL5DO_SD_1349 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            if (Parameter.isDeleted == true)
            {
                P_L3MD_DDbID_1031 param1 = new P_L3MD_DDbID_1031();
                param1.DoctorID = Parameter.DoctorID;

                var deleteQuery = new ORM_HEC_Patient_Treatment.Query();
                deleteQuery.IsTreatmentPerformed = true;
                deleteQuery.IfTreatmentPerformed_ByDoctor_RefID = Parameter.DoctorID;

                var treatmentsList = ORM_HEC_Patient_Treatment.Query.Search(Connection, Transaction, deleteQuery).ToList();

                foreach (var treatment in treatmentsList)
                {
                    treatment.IsTreatmentPerformed = false;
                    treatment.Save(Connection, Transaction);
                }


                cls_Delete_Doctor_byID.Invoke(Connection, Transaction, param1, securityTicket);
            }

            else
            {
                P_L3MD_SDBI_1349 param = new P_L3MD_SDBI_1349();

                param.Account_RefID         = Parameter.Account_RefID;
                param.DoctorID              = Parameter.DoctorID;
                param.Title                 = Parameter.Title;
                param.FirstName             = Parameter.FirstName;
                param.LastName              = Parameter.LastName;
                param.ifLucentis_LoginEmail = Parameter.LoginEmail;
                param.isLucentisSave        = true;
                param.ifLucentis_LANR       = Parameter.ifLucentis_LANR;

                List <P_L3MD_SDBI_1349_Practice> practiceNewList = new List <P_L3MD_SDBI_1349_Practice>();

                foreach (var practice in Parameter.Practices)
                {
                    P_L3MD_SDBI_1349_Practice practiceNew = new P_L3MD_SDBI_1349_Practice();
                    practiceNew.AssociatedParticipant_FunctionName = practice.AssociatedParticipant_FunctionName;
                    practiceNew.isDeleted  = practice.isDeleted;
                    practiceNew.PracticeID = practice.PracticeID;
                    practiceNewList.Add(practiceNew);
                }



                param.Practices = practiceNewList.ToArray();



                List <P_L3MD_SDBI_1349_Contacts> contactsNewList = new List <P_L3MD_SDBI_1349_Contacts>();

                foreach (var contact in Parameter.Contacts)
                {
                    P_L3MD_SDBI_1349_Contacts contactNew = new P_L3MD_SDBI_1349_Contacts();
                    contactNew.CMN_PER_CommunicationContact_TypeID = contact.CMN_PER_CommunicationContact_TypeID;
                    contactNew.Content = contact.Content;
                    contactsNewList.Add(contactNew);
                }


                param.Contacts = contactsNewList.ToArray();


                Guid Hec_Doctor_ID = cls_Save_Doctor_BaseInfo.Invoke(Connection, Transaction, param, securityTicket).Result;


                if (Parameter.DoctorID != Guid.Empty)
                {
                    #region Edit

                    var doctorQuery = new ORM_HEC_Doctor.Query();

                    doctorQuery.IsDeleted    = false;
                    doctorQuery.HEC_DoctorID = Hec_Doctor_ID;

                    var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).FirstOrDefault();

                    if (doctor != null)
                    {
                        var bussiness_2_BankaAccountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query();
                        bussiness_2_BankaAccountQuery.IsDeleted = false;
                        bussiness_2_BankaAccountQuery.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID;

                        var bussiness_2_BankaAccount = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, bussiness_2_BankaAccountQuery).FirstOrDefault();

                        if (bussiness_2_BankaAccount != null)
                        {
                            var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query();
                            bankAccountQuery.IsDeleted             = false;
                            bankAccountQuery.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID;

                            var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).FirstOrDefault();


                            bankAccount.OwnerText     = Parameter.AccountHolder;
                            bankAccount.AccountNumber = Parameter.AccountNumber;
                            bankAccount.IBAN          = Parameter.IBAN;
                            bankAccount.Save(Connection, Transaction);


                            var bankQuery = new ORM_ACC_BNK_Bank.Query();
                            bankQuery.IsDeleted      = false;
                            bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID;

                            var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).FirstOrDefault();


                            bank.BankName   = Parameter.BankName;
                            bank.BICCode    = Parameter.BIC;
                            bank.BankNumber = Parameter.BankNumber;
                            bank.Save(Connection, Transaction);
                        }
                        else
                        {
                            ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount1 = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount();
                            bussiness_2_BankaAccount1.AssignmentID = Guid.NewGuid();
                            bussiness_2_BankaAccount1.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID;
                            bussiness_2_BankaAccount1.ACC_BNK_BankAccount_RefID         = Guid.NewGuid();
                            bussiness_2_BankaAccount1.Creation_Timestamp = DateTime.Now;
                            bussiness_2_BankaAccount1.Tenant_RefID       = securityTicket.TenantID;
                            bussiness_2_BankaAccount1.IsDeleted          = false;

                            bussiness_2_BankaAccount1.Save(Connection, Transaction);

                            ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount();

                            bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount1.ACC_BNK_BankAccount_RefID;
                            bankAccount.Creation_Timestamp    = DateTime.Now;
                            bankAccount.Tenant_RefID          = securityTicket.TenantID;
                            bankAccount.OwnerText             = Parameter.AccountHolder;
                            bankAccount.AccountNumber         = Parameter.AccountNumber;
                            bankAccount.IBAN       = Parameter.IBAN;
                            bankAccount.Bank_RefID = Guid.NewGuid();
                            bankAccount.IsDeleted  = false;

                            bankAccount.Save(Connection, Transaction);

                            ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank();
                            bank.ACC_BNK_BankID     = bankAccount.Bank_RefID;
                            bank.Tenant_RefID       = securityTicket.TenantID;
                            bank.IsDeleted          = false;
                            bank.Creation_Timestamp = DateTime.Now;
                            bank.BankName           = Parameter.BankName;
                            bank.BICCode            = Parameter.BIC;
                            bank.BankNumber         = Parameter.BankNumber;

                            bank.Save(Connection, Transaction);
                        }
                    }


                    #endregion
                }
                else
                {
                    #region Save

                    var doctorQuery = new ORM_HEC_Doctor.Query();

                    doctorQuery.IsDeleted    = false;
                    doctorQuery.HEC_DoctorID = Hec_Doctor_ID;

                    var doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).FirstOrDefault();

                    if (doctor != null)
                    {
                        ORM_CMN_BPT_BusinessParticipant_2_BankAccount bussiness_2_BankaAccount = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount();
                        bussiness_2_BankaAccount.AssignmentID = Guid.NewGuid();
                        bussiness_2_BankaAccount.CMN_BPT_BusinessParticipant_RefID = doctor.BusinessParticipant_RefID;
                        bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID         = Guid.NewGuid();
                        bussiness_2_BankaAccount.Creation_Timestamp = DateTime.Now;
                        bussiness_2_BankaAccount.Tenant_RefID       = securityTicket.TenantID;
                        bussiness_2_BankaAccount.IsDeleted          = false;

                        bussiness_2_BankaAccount.Save(Connection, Transaction);

                        ORM_ACC_BNK_BankAccount bankAccount = new ORM_ACC_BNK_BankAccount();

                        bankAccount.ACC_BNK_BankAccountID = bussiness_2_BankaAccount.ACC_BNK_BankAccount_RefID;
                        bankAccount.Creation_Timestamp    = DateTime.Now;
                        bankAccount.Tenant_RefID          = securityTicket.TenantID;
                        bankAccount.OwnerText             = Parameter.AccountHolder;
                        bankAccount.AccountNumber         = Parameter.AccountNumber;
                        bankAccount.IBAN       = Parameter.IBAN;
                        bankAccount.Bank_RefID = Guid.NewGuid();
                        bankAccount.IsDeleted  = false;

                        bankAccount.Save(Connection, Transaction);

                        ORM_ACC_BNK_Bank bank = new ORM_ACC_BNK_Bank();
                        bank.ACC_BNK_BankID     = bankAccount.Bank_RefID;
                        bank.Tenant_RefID       = securityTicket.TenantID;
                        bank.IsDeleted          = false;
                        bank.Creation_Timestamp = DateTime.Now;
                        bank.BankName           = Parameter.BankName;
                        bank.BICCode            = Parameter.BIC;
                        bank.BankNumber         = Parameter.BankNumber;

                        bank.Save(Connection, Transaction);
                    }

                    #endregion
                }

                returnValue.Result = Hec_Doctor_ID;
            }
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PA_SPHIaBD_1143 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            #region Save
            if (!Parameter.IsDeleted)
            {
                //ORM_HEC_Patient
                var patientQuery = new ORM_HEC_Patient.Query();
                patientQuery.IsDeleted     = false;
                patientQuery.Tenant_RefID  = securityTicket.TenantID;
                patientQuery.HEC_PatientID = Parameter.PatientID;

                var patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single();

                var businessParticipantBank_2_accountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query();
                businessParticipantBank_2_accountQuery.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID;
                businessParticipantBank_2_accountQuery.IsDeleted    = false;
                businessParticipantBank_2_accountQuery.Tenant_RefID = securityTicket.TenantID;

                var businessParticipantBank_2_account = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, businessParticipantBank_2_accountQuery).SingleOrDefault();

                if (businessParticipantBank_2_account == null)
                {
                    //ORM_CMN_BPT_BusinessParticipant_2_BankAccount
                    businessParticipantBank_2_account = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount();
                    businessParticipantBank_2_account.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID;
                    businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID         = Guid.NewGuid();
                    businessParticipantBank_2_account.AssignmentID       = Guid.NewGuid();
                    businessParticipantBank_2_account.Tenant_RefID       = securityTicket.TenantID;
                    businessParticipantBank_2_account.Creation_Timestamp = DateTime.Now;
                    businessParticipantBank_2_account.Save(Connection, Transaction);

                    //ORM_ACC_BNK_BankAccount
                    var bankAccount = new ORM_ACC_BNK_BankAccount();
                    bankAccount.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID;
                    bankAccount.OwnerText             = Parameter.OwnerText;
                    bankAccount.AccountNumber         = Parameter.AccountNumber;
                    bankAccount.IBAN               = Parameter.IBAN;
                    bankAccount.Bank_RefID         = Guid.NewGuid();
                    bankAccount.Tenant_RefID       = securityTicket.TenantID;
                    bankAccount.Creation_Timestamp = DateTime.Now;
                    bankAccount.Save(Connection, Transaction);

                    //ORM_ACC_BNK_Bank
                    var bank = new ORM_ACC_BNK_Bank();
                    bank.ACC_BNK_BankID     = bankAccount.Bank_RefID;
                    bank.BankName           = Parameter.BankName;
                    bank.BICCode            = Parameter.BICCode;
                    bank.Tenant_RefID       = securityTicket.TenantID;
                    bank.Creation_Timestamp = DateTime.Now;
                    bank.Save(Connection, Transaction);

                    //ORM_HEC_Patient_HealthInsurance
                    var healthInsurance = new ORM_HEC_Patient_HealthInsurance();
                    healthInsurance.HEC_Patient_HealthInsurancesID = Guid.NewGuid();
                    healthInsurance.Patient_RefID                     = Parameter.PatientID;
                    healthInsurance.HealthInsurance_Number            = Parameter.HealthInsurance_Number;
                    healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HEC_HealthInsurance_CompanyID;
                    healthInsurance.HealthInsurance_State_RefID       = Parameter.HEC_Patient_HealthInsurance_StateID;
                    healthInsurance.InsuranceValidFrom                = Parameter.InsuranceValidFrom;
                    healthInsurance.InsuranceValidThrough             = Parameter.InsuranceValidThrough;
                    healthInsurance.IsNotSelfInsured                  = Parameter.IsNotSelfInsured;

                    if (healthInsurance.IsNotSelfInsured)
                    {
                        healthInsurance.IsNotSelfInsured_InsuredPersonBirthday = Parameter.IsNotSelfInsured_InsuredPersonBirthday;
                        healthInsurance.IsNotSelfInsured_InsuredPersonName     = Parameter.IsNotSelfInsured_InsuredPersonName;
                    }
                    healthInsurance.Creation_Timestamp = DateTime.Now;
                    healthInsurance.Tenant_RefID       = securityTicket.TenantID;
                    healthInsurance.Save(Connection, Transaction);
                }
                else
                {
                    var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query();
                    bankAccountQuery.IsDeleted             = false;
                    bankAccountQuery.Tenant_RefID          = securityTicket.TenantID;
                    bankAccountQuery.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID;

                    var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).Single();
                    bankAccount.OwnerText     = Parameter.OwnerText;
                    bankAccount.AccountNumber = Parameter.AccountNumber;
                    bankAccount.IBAN          = Parameter.IBAN;
                    bankAccount.Save(Connection, Transaction);

                    var bankQuery = new ORM_ACC_BNK_Bank.Query();
                    bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID;
                    bankQuery.IsDeleted      = false;
                    bankQuery.Tenant_RefID   = securityTicket.TenantID;

                    var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).Single();
                    bank.BankName = Parameter.BankName;
                    bank.BICCode  = Parameter.BICCode;
                    bank.Save(Connection, Transaction);

                    var healthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query();
                    healthInsuranceQuery.Patient_RefID = patient.HEC_PatientID;
                    healthInsuranceQuery.IsDeleted     = false;
                    healthInsuranceQuery.Tenant_RefID  = securityTicket.TenantID;

                    var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healthInsuranceQuery).Single();
                    healthInsurance.HealthInsurance_Number            = Parameter.HealthInsurance_Number;
                    healthInsurance.HIS_HealthInsurance_Company_RefID = Parameter.HEC_HealthInsurance_CompanyID;
                    healthInsurance.HealthInsurance_State_RefID       = Parameter.HEC_Patient_HealthInsurance_StateID;
                    healthInsurance.InsuranceValidFrom    = Parameter.InsuranceValidFrom;
                    healthInsurance.InsuranceValidThrough = Parameter.InsuranceValidThrough;
                    healthInsurance.IsNotSelfInsured      = Parameter.IsNotSelfInsured;
                    healthInsurance.IsNotSelfInsured_InsuredPersonBirthday = Parameter.IsNotSelfInsured_InsuredPersonBirthday;
                    healthInsurance.IsNotSelfInsured_InsuredPersonName     = Parameter.IsNotSelfInsured_InsuredPersonName;
                    healthInsurance.Save(Connection, Transaction);
                }
            }
            #endregion
            else
            {
                #region delete

                var patientQuery = new ORM_HEC_Patient.Query();
                patientQuery.IsDeleted     = false;
                patientQuery.Tenant_RefID  = securityTicket.TenantID;
                patientQuery.HEC_PatientID = Parameter.PatientID;

                var patient = ORM_HEC_Patient.Query.Search(Connection, Transaction, patientQuery).Single();
                patient.IsDeleted = true;
                patient.Save(Connection, Transaction);

                var businessParticipantBank_2_accountQuery = new ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query();
                businessParticipantBank_2_accountQuery.CMN_BPT_BusinessParticipant_RefID = patient.CMN_BPT_BusinessParticipant_RefID;
                businessParticipantBank_2_accountQuery.IsDeleted    = false;
                businessParticipantBank_2_accountQuery.Tenant_RefID = securityTicket.TenantID;

                var businessParticipantBank_2_account = ORM_CMN_BPT_BusinessParticipant_2_BankAccount.Query.Search(Connection, Transaction, businessParticipantBank_2_accountQuery).Single();
                businessParticipantBank_2_account.IsDeleted = true;
                businessParticipantBank_2_account.Save(Connection, Transaction);

                var bankAccountQuery = new ORM_ACC_BNK_BankAccount.Query();
                bankAccountQuery.IsDeleted             = false;
                bankAccountQuery.Tenant_RefID          = securityTicket.TenantID;
                bankAccountQuery.ACC_BNK_BankAccountID = businessParticipantBank_2_account.ACC_BNK_BankAccount_RefID;

                var bankAccount = ORM_ACC_BNK_BankAccount.Query.Search(Connection, Transaction, bankAccountQuery).Single();
                bankAccount.IsDeleted = true;
                bankAccount.Save(Connection, Transaction);

                var bankQuery = new ORM_ACC_BNK_Bank.Query();
                bankQuery.ACC_BNK_BankID = bankAccount.Bank_RefID;
                bankQuery.IsDeleted      = false;
                bankQuery.Tenant_RefID   = securityTicket.TenantID;

                var bank = ORM_ACC_BNK_Bank.Query.Search(Connection, Transaction, bankQuery).Single();
                bank.IsDeleted = true;
                bank.Save(Connection, Transaction);

                var healthInsuranceQuery = new ORM_HEC_Patient_HealthInsurance.Query();
                healthInsuranceQuery.Patient_RefID = patient.HEC_PatientID;
                healthInsuranceQuery.IsDeleted     = false;
                healthInsuranceQuery.Tenant_RefID  = securityTicket.TenantID;

                var healthInsurance = ORM_HEC_Patient_HealthInsurance.Query.Search(Connection, Transaction, healthInsuranceQuery).Single();
                healthInsurance.IsDeleted = true;
                healthInsurance.Save(Connection, Transaction);

                #endregion
            }

            return(returnValue);

            #endregion UserCode
        }