Example #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var practice = new ORM_HEC_MedicalPractis()
            {
                HEC_MedicalPractiseID = Guid.NewGuid(),
                Tenant_RefID          = securityTicket.TenantID,
                Ext_CompanyInfo_RefID = Guid.NewGuid()
            };
            practice.Save(Connection, Transaction);

            var companyInfo = new ORM_CMN_COM_CompanyInfo()
            {
                CMN_COM_CompanyInfoID           = practice.Ext_CompanyInfo_RefID,
                Tenant_RefID                    = securityTicket.TenantID,
                CompanyInfo_EstablishmentNumber = Parameter.Practice_BSNR
            };
            companyInfo.Save(Connection, Transaction);

            var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, new ORM_CMN_BPT_BusinessParticipant.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                IsTenant     = true
            }).Single();

            bParticipant.IsCompany = true;
            bParticipant.IfCompany_CMN_COM_CompanyInfo_RefID = companyInfo.CMN_COM_CompanyInfoID;
            bParticipant.Save(Connection, Transaction);

            if (Parameter.Doctor != null)
            {
                var account2personInfo = ORM_CMN_PER_PersonInfo_2_Account.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo_2_Account.Query()
                {
                    Tenant_RefID      = securityTicket.TenantID,
                    IsDeleted         = false,
                    USR_Account_RefID = Parameter.Doctor.AccountID
                }).Single();

                var query2 = new ORM_CMN_PER_PersonInfo.Query();
                query2.CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID;

                var personInfo = ORM_CMN_PER_PersonInfo.Query.Search(Connection, Transaction, new ORM_CMN_PER_PersonInfo.Query()
                {
                    Tenant_RefID         = securityTicket.TenantID,
                    IsDeleted            = false,
                    CMN_PER_PersonInfoID = account2personInfo.CMN_PER_PersonInfo_RefID
                }).First();

                personInfo.FirstName = Parameter.Doctor.FirstName;
                personInfo.LastName  = Parameter.Doctor.LastName;
                personInfo.Title     = Parameter.Doctor.Title;
                personInfo.Save(Connection, Transaction);

                var bussinessParticipantTable = new ORM_CMN_BPT_BusinessParticipant();
                bussinessParticipantTable.CMN_BPT_BusinessParticipantID = Guid.NewGuid();
                bussinessParticipantTable.IsNaturalPerson = true;
                bussinessParticipantTable.Tenant_RefID    = securityTicket.TenantID;
                bussinessParticipantTable.IfNaturalPerson_CMN_PER_PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID;
                bussinessParticipantTable.Save(Connection, Transaction);

                var doctor = new ORM_HEC_Doctor();
                doctor.Tenant_RefID = securityTicket.TenantID;
                doctor.BusinessParticipant_RefID = bussinessParticipantTable.CMN_BPT_BusinessParticipantID;
                doctor.Account_RefID             = Parameter.Doctor.AccountID;
                doctor.DoctorIDNumber            = Parameter.Doctor.LANR;
                doctor.Save(Connection, Transaction);

                var associatedbusinessparticipants = new ORM_CMN_BPT_BusinessParticipant_AssociatedBusinessParticipant();
                associatedbusinessparticipants.BusinessParticipant_RefID           = bussinessParticipantTable.CMN_BPT_BusinessParticipantID;
                associatedbusinessparticipants.AssociatedBusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID;
                associatedbusinessparticipants.Tenant_RefID = securityTicket.TenantID;
                associatedbusinessparticipants.Save(Connection, Transaction);

                if (Parameter.Doctor.BankData != 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.Tenant_RefID = securityTicket.TenantID;

                    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.Tenant_RefID          = securityTicket.TenantID;
                    bankAccount.OwnerText             = Parameter.Doctor.BankData.AccountHolder;
                    bankAccount.AccountNumber         = Parameter.Doctor.BankData.AccountNumber;
                    bankAccount.IBAN       = Parameter.Doctor.BankData.IBAN;
                    bankAccount.Bank_RefID = Guid.NewGuid();

                    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.BankName       = Parameter.Doctor.BankData.BankName;
                    bank.BICCode        = Parameter.Doctor.BankData.BIC;
                    bank.BankNumber     = Parameter.Doctor.BankData.BankNumber;

                    bank.Save(Connection, Transaction);
                }
            }

            return(returnValue);

            #endregion UserCode
        }
Example #2
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Example #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guid functionReturn = new FR_Guid();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Save_Practice", ex);
            }
            return(functionReturn);
        }
Example #4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L5PR_SP_1538 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }