Exemplo n.º 1
0
        protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5EX_SPEF_1258 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Bool();
            //Put your code here
            //remove deleted images from database
            foreach (var image2delete in Parameter.PictureIDsToRemove)
            {
                var findingDocumentQuery = new ORM_HEC_Patient_Finding_Document.Query();
                findingDocumentQuery.Tenant_RefID   = securityTicket.TenantID;
                findingDocumentQuery.IsDeleted      = false;
                findingDocumentQuery.Document_RefID = image2delete;

                var findingDocument = ORM_HEC_Patient_Finding_Document.Query.Search(Connection, Transaction, findingDocumentQuery).Single();
                findingDocument.IsDeleted = true;
                findingDocument.Save(Connection, Transaction);

                var documentTableQuery = new ORM_DOC_Document.Query();
                documentTableQuery.DOC_DocumentID = image2delete;
                findingDocument.Tenant_RefID      = securityTicket.TenantID;
                findingDocument.IsDeleted         = false;

                var documentTable = ORM_DOC_Document.Query.Search(Connection, Transaction, documentTableQuery).Single();
                documentTable.IsDeleted = true;
                documentTable.Save(Connection, Transaction);
            }
            //delete findings that have no documents(images)
            foreach (var finding2delete in Parameter.PatientFindingIDsToRemove)
            {
                var examinationFinding = ORM_HEC_ACT_PerformedAction_PatientProvidedFinding.Query.Search(Connection, Transaction, new ORM_HEC_ACT_PerformedAction_PatientProvidedFinding.Query()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    IsDeleted    = false,
                    HEC_Patient_Finding_RefID = finding2delete
                }).Single();
                examinationFinding.IsDeleted = true;
                examinationFinding.Save(Connection, Transaction);

                var patientFindings = ORM_HEC_Patient_Finding.Query.Search(Connection, Transaction, new ORM_HEC_Patient_Finding.Query()
                {
                    Tenant_RefID          = securityTicket.TenantID,
                    IsDeleted             = false,
                    HEC_Patient_FindingID = finding2delete
                }).Single();
                patientFindings.IsDeleted = true;
                patientFindings.Save(Connection, Transaction);
            }
            //save new images
            foreach (var images2Save in Parameter.PicturesToAdd)
            {
                var findingDocument = new ORM_HEC_Patient_Finding_Document();
                findingDocument.Comment = images2Save.Name;
                findingDocument.HEC_Patient_Finding_DocumentID = Guid.NewGuid();
                findingDocument.Document_RefID        = images2Save.DocumentID;
                findingDocument.Tenant_RefID          = securityTicket.TenantID;
                findingDocument.Patient_Finding_RefID = images2Save.FindingID;
                findingDocument.Save(Connection, Transaction);

                var document = new ORM_DOC_Document();
                document.PrimaryType    = images2Save.Type.ToString();
                document.DOC_DocumentID = images2Save.DocumentID;
                document.Alias          = images2Save.Size;
                document.Tenant_RefID   = securityTicket.TenantID;
                document.Save(Connection, Transaction);
            }
            return(returnValue);

            #endregion UserCode
        }
Exemplo n.º 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_Bool Invoke(DbConnection Connection, DbTransaction Transaction, P_L5EX_SPEF_1258 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Exemplo n.º 3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Bool Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5EX_SPEF_1258 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Bool functionReturn = new FR_Bool();

            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_PatientExaminationFindings", ex);
            }
            return(functionReturn);
        }
Exemplo n.º 4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Bool Invoke(string ConnectionString, P_L5EX_SPEF_1258 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }