Exemple #1
0
        public override DsProfile LoadSystemProfile(string ModuleID)
        {
            RisDAL    oKodakDAL = new RisDAL();
            DsProfile m_ds      = new DsProfile();

            try
            {
                string szQuery1 = "SELECT Name, nvl(Value, '') as Value, ModuleID, Exportable, nvl(PropertyDesc, '') as PropertyDesc, nvl(PropertyOptions, '') as PropertyOptions, Inheritance, PropertyType, IsHidden, OrderingPos FROM tSystemProfile " +
                                  " WHERE  (ModuleID = '" + ModuleID + "')";
                oKodakDAL.ExecuteQuery(szQuery1, m_ds, "Profile");
                foreach (DataRow myRow in m_ds.Tables["Profile"].Rows)
                {
                    if (myRow["Value"].Equals(DBNull.Value))
                    {
                        myRow["Value"] = "";
                    }
                    if (myRow["PropertyDesc"].Equals(DBNull.Value))
                    {
                        myRow["PropertyDesc"] = "";
                    }
                    if (myRow["PropertyOptions"].Equals(DBNull.Value))
                    {
                        myRow["PropertyOptions"] = "";
                    }
                }
            }
            catch (Exception Ex)
            {
                logger.Error((long)ModuleEnum.Framework_Client, ModuleInstanceName.Framework, 1, Ex.Message,
                             string.Empty, (new System.Diagnostics.StackFrame(true)).GetFileName(),
                             (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
                m_ds = null;
            }
            finally
            {
                if (oKodakDAL != null)
                {
                    oKodakDAL.Dispose();
                }
            }
            return(m_ds);
        }
Exemple #2
0
            public Object Execute(object param)
            {
                try
                {
                    using (RisDAL oKodak = new RisDAL())
                    {
                        string strOrderGuid  = CommonGlobalSettings.Utilities.GetParameter("OrderGuid", param.ToString());
                        string strReportGuid = CommonGlobalSettings.Utilities.GetParameter("ReportGuid", param.ToString());
                        string strSQL        = "";
                        if (string.IsNullOrWhiteSpace(strOrderGuid))
                        {
                            strSQL = string.Format("select IsFilmSent from tregorder where OrderGuid='{0}'", strOrderGuid);
                        }
                        else
                        {
                            strSQL = string.Format("select IsPrint from treport where ReportGuid='{0}'", strReportGuid);
                        }

                        Object obj = oKodak.ExecuteScalar(strSQL);
                        if (obj == null || Convert.ToInt32(obj) == 0)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Assert(false, ex.Message);

                    ServerPubFun.RISLog_Error(0, "GetRePrintDAO=" + ex.Message,
                                              (new System.Diagnostics.StackFrame()).GetFileName(),
                                              (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                }


                return(false
                       );
            }
Exemple #3
0
        public object Execute(object param)
        {
            try
            {
                BaseDataSetModel bdsm = param as BaseDataSetModel;

                if (bdsm == null || bdsm.DataSetParameter == null)
                {
                    throw (new Exception("No parameter in SaveLeaveWordDAO!"));
                }



                //KodakDAL dal = new KodakDAL();
                {
                    DataSet ds = bdsm.DataSetParameter;
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        string strReportGuid = Convert.ToString(ds.Tables[0].Rows[0]["ReportGuid"]);
                        string strLeaveWord  = Convert.ToString(ds.Tables[0].Rows[0]["LeaveWord"]);
                        string strSQL        = string.Format("update tReport set isLeaveWord=1, Comments= @Comments where ReportGuid='{0}'", strReportGuid);
                        using (var dal = new RisDAL())
                        {
                            dal.Parameters.Add("@Comments", strLeaveWord);
                            dal.ExecuteNonQuery(strSQL);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "SaveLeaveWordDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                return(false);
            }


            return(true);
        }
Exemple #4
0
        /// <summary>
        /// DeclareNoCase
        /// </summary>
        public static void DeclareOracleNoCase()
        {
            try
            {
                string sql0 = " alter session set nls_comp=ANSI";
                string sql1 = " alter session set nls_sort=GENERIC_BASELETTER";

                using (RisDAL dal = new RisDAL())
                {
                    if (dal.DriverClassName.ToUpper() == "ORACLE")
                    {
                        dal.ExecuteNonQuery(sql0);
                        dal.ExecuteNonQuery(sql1);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);
            }
        }
Exemple #5
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetLeaveSoundDAO!"));
                }



                string strReportGuid = paramMap["ReportGuid"] as string;



                DataSet ds = new DataSet();


                using (RisDAL oKodak = new RisDAL())
                {
                    string    strSQL       = string.Format("select A.SoundGuid,A.ReportGuid,A.Path,A.Status,A.LeaveTime,A.Owner,B.LocalName from tLeaveSound A,tUser B where A.Owner=B.UserGuid and ReportGuid='{0}' order  by LeaveTime desc", strReportGuid);
                    DataTable dtLeaveSound = oKodak.ExecuteQuery(strSQL);
                    ds.Tables.Add(dtLeaveSound);
                    return(ds);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLeaveSoundDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                return(null);
            }

            return(null);
        }
Exemple #6
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public object Execute(object param)
        {
            bool bHide0 = ServerPubFun.GetSystemProfile_Bool(ReportCommon.ProfileName.ReportList_HideCount, ReportCommon.ModuleID.Report);
            bool bHide1 = ServerPubFun.GetSystemProfile_Bool(ReportCommon.ProfileName.ReportPrint_HideCount, ReportCommon.ModuleID.Report);

            if (bHide0 && bHide1)
            {
                return(-1);
            }

            using (RisDAL oKodak = new RisDAL())
            {
                string clsType = string.Format("{0}_{1}", this.GetType().ToString(), oKodak.DriverClassName.ToUpper());
                if (oKodak != null)
                {
                    oKodak.Dispose();
                }

                Type       type    = Type.GetType(clsType);
                IReportDAO iRptDAO = Activator.CreateInstance(type) as IReportDAO;
                return(iRptDAO.Execute(param));
            }
        }
Exemple #7
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetReportNameDAO!"));
                }

                string reportGuid = "";
                string rpGuids    = "";
                string accNO      = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = paramMap[key] as string;

                        if (rpGuids == null)
                        {
                            rpGuids = "";
                        }
                    }
                    else if (key.ToUpper() == "ACCNO")
                    {
                        accNO = paramMap[key] as string;

                        if (accNO == null)
                        {
                            accNO = "";
                        }
                    }
                }

                string sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                             "select " + GetAllReportColumn() + " \r\n"
                             + " from tRegPatient with (nolock), tRegOrder with (nolock), tProcedureCode with (nolock), tRegProcedure with (nolock) \r\n"
                             + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                             + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                             + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                             + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n";

                string sqlFile = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                 " select distinct tReportFile.* from tReportFile, tReport "
                                 + " where tReportFile.reportGuid = tReport.reportGuid";


                #region Added by Kevin For SR

                string sqlreportcontent = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                          " select * from tReportContent"
                                          + " where tReportContent.ReportId ='" + reportGuid + "' ";

                #endregion


                if (!string.IsNullOrWhiteSpace(reportGuid))
                {
                    sql += " and tReport.reportGuid = '" + reportGuid + "'";

                    sqlFile += " and tReport.reportGuid = '" + reportGuid + "'";
                }
                else if (!string.IsNullOrWhiteSpace(rpGuids))
                {
                    rpGuids = rpGuids.Trim(", ".ToCharArray());

                    string[] arr = rpGuids.Split(',');
                    if (arr.Length > 1)
                    {
                        if (!rpGuids.Contains("','"))
                        {
                            rpGuids = rpGuids.Replace(",", "','");
                            rpGuids = "'" + rpGuids + "'";
                        }
                        sql += " and tRegProcedure.ProcedureGuid in (" + rpGuids + ")";
                    }
                    else
                    {
                        rpGuids = "'" + rpGuids + "'";
                        sql    += " and tRegProcedure.ProcedureGuid =" + rpGuids;
                    }

                    sqlFile += " and 1=2 ";
                }
                else if (!string.IsNullOrWhiteSpace(accNO))
                {
                    sql += " AND tRegOrder.ACCNO = '" + accNO.Trim() + "'";

                    sqlFile += " AND 1=2 ";
                }

                if (0 == iWrittenCount++ % 100)
                {
                    ServerPubFun.RISLog_Info(0, "GetReportInfoDAO=" + sql + ", reportFile=" + sqlFile, "", 0);
                }
                else
                {
                    ServerPubFun.RISLog_Info(0, "GetReportInfoDAO, rpGuid=" + rpGuids + ", reportGuid=" + reportGuid + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                }

                DataSet ds = new DataSet();

                using (RisDAL dal = new RisDAL())
                {
                    //
                    // report info
                    DataTable dt0 = new DataTable("ReportInfo");

                    dal.ExecuteQuery(sql, dt0);

                    ds.Tables.Add(dt0);

                    //
                    // report file
                    DataTable dt1 = new DataTable("ReportFile");

                    dal.ExecuteQuery(sqlFile, dt1);

                    ds.Tables.Add(dt1);

                    string    sqlPrintTemplate = "select * from tPrintTemplate where Type=3 and TemplateName='QualityControlReportTemplate'";
                    DataTable dt2 = new DataTable("PrintTemplate");
                    dal.ExecuteQuery(sqlPrintTemplate, dt2);
                    ds.Tables.Add(dt2);
                    #region Added by Kevin For SR

                    // reportcontent
                    DataTable dt3 = new DataTable("ReportContent");

                    dal.ExecuteQuery(sqlreportcontent, dt3);

                    ds.Tables.Add(dt3);

                    #endregion
                }


                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportInfoDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #8
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetReportNameDAO!"));
                }

                string reportGuid = "";
                string rpGuids    = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = paramMap[key] as string;

                        if (rpGuids == null)
                        {
                            rpGuids = "";
                        }
                    }
                }

                string sql = "select " + GetAllReportColumn()
                             + " from tRegPatient, tRegOrder, tProcedureCode, tRegProcedure "
                             + " left join tReport on tRegProcedure.reportGuid = tReport.reportGuid "
                             + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid "
                             + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid "
                             + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode ";

                string sqlFile = " select distinct tReportFile.* from tReportFile, tReport "
                                 + " where tReportFile.reportGuid = tReport.reportGuid ";



                if (reportGuid.Length > 0)
                {
                    sql += " and tReport.reportGuid = '" + reportGuid + "'";

                    sqlFile += " and tReport.reportGuid = '" + reportGuid + "'";
                }

                if (rpGuids.Length > 0 && reportGuid.Length == 0)
                {
                    rpGuids = rpGuids.Trim(", ".ToCharArray());
                    rpGuids = rpGuids.Replace(",", "','");
                    rpGuids = "'" + rpGuids + "'";

                    sql += " and tRegProcedure.ProcedureGuid in (" + rpGuids + ")";

                    sqlFile += " 1!=1";
                }

                DataSet ds = new DataSet();

                using (RisDAL dal = new RisDAL())
                {
                    //
                    // report info
                    DataTable dt0 = new DataTable("ReportInfo");



                    //ServerPubFun.DeclareOracleNoCase();

                    dal.ExecuteQuery(sql, dt0);

                    ds.Tables.Add(dt0);

                    //
                    // report file
                    DataTable dt1 = new DataTable("ReportFile");



                    dal.ExecuteQuery(sqlFile, dt1);

                    ds.Tables.Add(dt1);

                    if (dal != null)
                    {
                        dal.Dispose();
                    }
                }
                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportInfoDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #9
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;
                string  sql = null;
                DataSet ds  = new DataSet();
                using (RisDAL dal = new RisDAL())
                {
                    if (inMap == null || inMap.Count < 1)
                    {
                        throw (new Exception("No parameter!"));
                    }

                    foreach (string key in inMap.Keys)
                    {
                        string value = "";
                        value = inMap[key].ToString().ToUpper();

                        if (value == "MODALITYTYPE-MODALITY")
                        {
                            sql = "select distinct modality as text,modalityType, modality as value  from tModality";
                            DataTable dt = new DataTable("ModalityType_Modality");
                            dal.ExecuteQuery(sql, dt);
                            ds.Tables.Add(dt);
                        }
                        else if (value == "MODALITYTYPE-DESCRIPTION")
                        {
                            sql = "select distinct Description as text, modalityType,Description as value  from tProcedureCode";
                            DataTable dt = new DataTable("ModalityType_DESCRIPTION");
                            dal.ExecuteQuery(sql, dt);
                            ds.Tables.Add(dt);
                        }
                        else if (value == "MODALITYTYPE-BODYPART")
                        {
                            sql = "select distinct bodypart as text, modalityType,bodypart as value from tProcedureCode";
                            DataTable dt = new DataTable("ModalityType_BodyPart");
                            dal.ExecuteQuery(sql, dt);
                            ds.Tables.Add(dt);
                        }
                        else if (value == "MODALITYTYPE-CHECKINGITEM")
                        {
                            //EK_HI00064564 Foman 2007.12.26   "select distinct modalityType,CheckingItem as text,  CheckingItem as value  from tProcedureCode""
                            sql = "select distinct CheckingItem as text, modalityType, CheckingItem as value  from tProcedureCode";
                            DataTable dt = new DataTable("ModalityType_CheckingItem");
                            dal.ExecuteQuery(sql, dt);
                            ds.Tables.Add(dt);
                        }
                    }
                }

                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetConditionRelatedControlDataDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }
            return(null);
        }
Exemple #10
0
        /// <summary>
        /// GetLocalName
        /// </summary>
        /// <param name="userGuid"></param>
        /// <returns></returns>
        public static string GetLocalName(string userGuid)
        {
            try
            {
                if (userGuid != null && (userGuid = userGuid.Trim()).Length > 0)
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        DataTable dt  = new DataTable();
                        string    sql = "";

                        //multi userguid
                        if (userGuid.Length > Guid.NewGuid().ToString().Length)
                        {
                            string tmp = "'" + userGuid.Replace(",", "','") + "'";
                            sql = "select UserGuid,LocalName from tUser where UserGuid in(" + tmp + ")";
                            dal.ExecuteQuery(sql, dt);
                            if (null != dt && dt.Rows.Count > 0)
                            {
                                tmp = "";
                                foreach (string str in userGuid.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                                {
                                    DataRow[] drs = dt.Select("UserGuid='" + str + "'");
                                    if (drs.Length > 0)
                                    {
                                        tmp += drs[0]["LocalName"].ToString() + ",";
                                    }
                                    else
                                    {
                                        tmp += str + ",";
                                    }
                                }
                                tmp = tmp.TrimEnd(",".ToCharArray());
                                return(tmp);
                            }
                            return("");
                        }
                        else
                        {
                            sql = "select rolename, tUser.userGuid, LoginName, localName, englishname "
                                  + " from tUser, tRole2User"
                                  + " where tUser.UserGuid = tRole2User.UserGuid"
                                  + " and tUser.UserGuid = '" + userGuid + "'";

                            dal.ExecuteQuery(sql, dt);

                            if (dt != null && dt.Rows.Count > 0)
                            {
                                string retName = dt.Rows[0]["LocalName"].ToString();


                                return(retName);
                            }
                        }
                        if (dal != null)
                        {
                            dal.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLocalName=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("");
        }
Exemple #11
0
        /// <summary>
        /// OnReportDelete
        /// </summary>
        /// <param name="rptInfo"></param>
        /// <param name="nextStatus"></param>
        public static void OnReportDelete(tagReportInfo rptInfo, ReportCommon.RP_Status nextStatus)
        {
            try
            {
                // Need to send gateway
                if (!ServerPubFun.GetSystemProfile_Bool("SendToGateServer", ReportCommon.ModuleID.Integration))
                {
                    return;
                }

                //
                // Gateway
                using (RisDAL dal = new RisDAL())
                {
                    string guid = Guid.NewGuid().ToString();

                    if (dal.DriverClassName.ToUpper() == "ORACLE")
                    #region Oracle
                    {
                        string sql = " insert into GW_DataIndex(data_id, data_dt, event_type, RECORD_INDEX_1, Data_Source)"
                                     + " values('" + guid + "', SYSDATE, '" + (nextStatus == ReportCommon.RP_Status.Repeatshot ? "32" : "33") + "', 'ReportGuid', 'Local'); "
                                     + " insert into GW_Patient(DATA_ID,DATA_DT,PATIENTID,PATIENT_NAME,PATIENT_LOCAL_NAME,BIRTHDATE,SEX)"
                                     + "    values('" + guid + "', SYSDATE, '" + rptInfo.patientID + "','" + rptInfo.patientName + "',N'" + rptInfo.patientLocalName + "','" + rptInfo.birthday.ToString("yyyy-MM-dd") + "','" + rptInfo.gender + "'); "
                                     + " insert into GW_Order(DATA_ID,DATA_DT,ORDER_NO,FILLER_NO,PATIENT_ID,EXAM_STATUS) "
                                     + "    values('" + guid + "', SYSDATE, '" + rptInfo.orderGuid + "', '" + rptInfo.AccNO + "', '" + rptInfo.patientID
                                     + "', '" + (nextStatus == ReportCommon.RP_Status.Repeatshot ? "17" : "16") + "'); "
                                     + " insert into GW_Report(data_id, data_dt, report_no, ACCESSION_NUMBER, PATIENT_ID, REPORT_STATUS, MODALITY, "
                                     + " REPORT_TYPE, REPORT_FILE, REPORT_WRITER, REPORT_APPROVER, REPORTDT, OBSERVATIONMETHOD)"
                                     + " values('" + guid + "', SYSDATE, '"
                                     + ((rptInfo.reportGuid == null || rptInfo.reportGuid == "") ? " " : rptInfo.reportGuid) + "', '"
                                     + rptInfo.AccNO + "'," + " '" + rptInfo.patientID + "', '204', '"
                                     + rptInfo.modality + "', '0', '', '" + rptInfo.reportCreater_LocalName + "',"
                                     + " '" + rptInfo.reportApprover_LocalName + "', '" + rptInfo.reportApproveDt.ToString("yyyy-MM-dd HH:mm:ss") + "',"
                                     + " '" + ReportCommon.ReportCommon.StringLeft(rptInfo.operationStep, ServerPubFun.GetColumnWidth("GW_Report", "OBSERVATIONMETHOD") / 2) + "'); ";

                        sql = "begin " + sql + " commit; end;";

                        dal.ExecuteNonQuery(sql);

                        if (rptInfo.wysText != null && rptInfo.wysText.Length > 0)
                        {
                            dal.WriteLargeObj("GW_Report", "data_id", guid, "DIAGNOSE", rptInfo.wysText, rptInfo.wysText.Length, RisDAL.ConnectionState.KeepOpen);
                        }

                        if (rptInfo.wygText != null && rptInfo.wygText.Length > 0)
                        {
                            dal.WriteLargeObj("GW_Report", "data_id", guid, "COMMENTS", rptInfo.wygText, rptInfo.wygText.Length, RisDAL.ConnectionState.KeepOpen);
                        }
                    }
                    #endregion
                    else if (dal.DriverClassName.ToUpper() == "MSSQL")
                    #region MSSQL
                    {
                        string sql = SaveReportDAO_MSSQL.MakeSQL4GateWay(rptInfo, guid, nextStatus == ReportCommon.RP_Status.Repeatshot ? 32 : 33, 16, 204);

                        using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(dal.ConnectionString))
                        {
                            conn.Open();

                            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                            cmd.Connection = conn;

                            try
                            {
                                //
                                // begin transaction
                                //cmd.Transaction = conn.BeginTransaction();

                                ServerPubFun.RISLog_Info(0, "OnReportDelete=" + sql,
                                                         (new System.Diagnostics.StackFrame(true)).GetFileName(),
                                                         (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());

                                cmd.CommandText = sql;
                                cmd.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {
                                //cmd.Transaction.Rollback();

                                System.Diagnostics.Debug.Assert(false, ex.Message);

                                RISLog_Error(0, "OnReportDelete, MSG=" + ex.Message + ", SQL=" + sql,
                                             (new System.Diagnostics.StackFrame(true)).GetFileName(),
                                             (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
                            }
                        }
                    }
                    #endregion
                    else
                    {
                        System.Diagnostics.Debug.Assert(false, "Invalid DB setting!");
                    }

                    // Hippa
                    Server.Utilities.HippaLogTool.HippaLogTool.AuditPatientCareAssignMsg(
                        CommonGlobalSettings.HippaName.ActionCode.Delete,

                        rptInfo.AccNO, rptInfo.reportGuid, rptInfo.reportName, rptInfo.patientID, rptInfo.patientName, "", true);
                }
            }
            catch
            {
                Server.Utilities.HippaLogTool.HippaLogTool.AuditPatientCareAssignMsg(
                    CommonGlobalSettings.HippaName.ActionCode.Delete,
                    rptInfo.AccNO, rptInfo.reportGuid, rptInfo.reportName, rptInfo.patientID, rptInfo.patientName, "", false);
            }
        }
Exemple #12
0
        public DataSet GetGridCol(string gridName, string userGuid)
        {
            try
            {
                gridName = gridName == null ? "" : gridName.Trim();
                userGuid = userGuid == null ? "" : userGuid.Trim();

                if (gridName.Length > 0)
                {
                    /*
                     * string sql = "if exists(select 1 from tGridColumn, tGridColumnOption"
                     + " where tGridColumn.Guid = tGridColumnOption.Guid"
                     + " and tGridColumnOption.listname = '" + gridName + "' and tGridColumn.UserGuid = '" + userGuid + "') \r\n"
                     + "  select * from tGridColumn, tGridColumnOption"
                     + "  where tGridColumn.Guid = tGridColumnOption.Guid"
                     + "  and tGridColumnOption.listname = '" + gridName + "'"
                     + "  and tGridColumn.UserGuid = '" + userGuid + "' order by tGridColumn.OrderID \r\n"
                     + " else if exists(select 1 from tGridColumn, tGridColumnOption"
                     + " where tGridColumn.Guid = tGridColumnOption.Guid"
                     + " and tGridColumnOption.listname = '" + gridName + "' and tGridColumn.UserGuid = '') \r\n"
                     + "  select * from tGridColumn, tGridColumnOption"
                     + "  where tGridColumn.Guid = tGridColumnOption.Guid"
                     + "  and tGridColumnOption.listname = '" + gridName + "'"
                     + "  and tGridColumn.UserGuid = '' order by tGridColumn.OrderID \r\n"
                     + " else \r\n"
                     + "  select * from tGridColumnOption"
                     + "  left join tGridColumn on tGridColumn.Guid = tGridColumnOption.Guid"
                     + "	 and tGridColumn.UserGuid = ''"
                     + "  where tGridColumnOption.listname = '" + gridName + "' order by tGridColumnOption.OrderID";
                     */
                    string sql = string.Format("select tGridColumn.Guid,tGridColumn.ColumnWidth,tGridColumn.IsHidden,tGridColumnOption.ColumnID," +
                                               " tGridColumnOption.TableName,tGridColumnOption.ColumnName,tGridColumnOption.Expression," +
                                               " tGridColumnOption.ModuleID, tGridColumnOption.isImageColumn, tGridColumnOption.ImagePath" +
                                               " from tGridColumn left join tGridColumnOption on " +
                                               " tGridColumn.Guid=tGridColumnOption.Guid where " +
                                               " tGridColumn.UserGuid='' AND tGridColumnOption.ListName='{0}' " +
                                               " order by tGridColumn.OrderID ", gridName);



                    DataSet ds = new DataSet();

                    using (RisDAL dal = new RisDAL())
                    {
                        dal.ExecuteQuery(sql, ds, "GridColumn");

                        return(ds);
                    }
                }
                else
                {
                    throw (new Exception("Missing Parameter!"));
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetGridColumnDAO_MSSQL, MSG=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #13
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetLockDAO!"));
                }

                string action   = "";
                string lockType = "";
                string lockGuid = "";
                string owner    = "";
                string ownerIP  = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "LOCKTYPE")
                    {
                        lockType = paramMap[key] as string;

                        if (lockType == null)
                        {
                            lockType = "";
                        }
                    }
                    else if (key.ToUpper() == "LOCKGUID")
                    {
                        lockGuid = paramMap[key] as string;

                        if (lockGuid == null)
                        {
                            lockGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "ACTION")
                    {
                        action = paramMap[key] as string;

                        if (action == null)
                        {
                            action = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNER")
                    {
                        owner = paramMap[key] as string;

                        if (owner == null)
                        {
                            owner = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNERIP")
                    {
                        ownerIP = paramMap[key] as string;

                        if (ownerIP == null)
                        {
                            ownerIP = "";
                        }
                    }
                }



                DataSet ds = new DataSet();

                //dal.BeginTransaction();

                try
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        if (action.ToUpper() == "ADD")
                        {
                            string sql0 = "merge into tSync D"
                                          + " using (select " + lockType + " syncType, '" + lockGuid + "' guid, '"
                                          + owner + "' owner, '" + ownerIP + "' ownerIP from dual) S"
                                          + " on (s.synctype = d.syncType and s.guid = d.guid)"
                                          + " when not matched then insert (d.syncType, d.guid, d.owner, d.ownerIP)"
                                          + " values(s.synctype, s.guid, s.owner, s.ownerip)";
                            string sql1 = " select * from tSync, tUser where tSync.Owner = tUser.UserGuid"
                                          + " and tSync.SyncType=" + lockType + " and tSync.Guid='" + lockGuid + "' for update";
                            string sql2 = " commit";



                            dal.ExecuteNonQuery(sql0);
                            dal.ExecuteQuery(sql1, ds, "tSync");
                            dal.ExecuteNonQuery(sql2);
                        }
                        else if (action.ToUpper() == "DELETE" || action.ToUpper() == "DEL")
                        {
                            string sql0 = "delete from tSync"
                                          + " where syncType=" + lockType + " and guid='" + lockGuid + "'";
                            string sql1 = " select * from tSync, tUser where tSync.Owner = tUser.UserGuid"
                                          + " and tSync.SyncType=" + lockType + " and tSync.Guid='" + lockGuid + "' ";
                            string sql2 = " commit";

                            dal.ExecuteNonQuery(sql0);
                            dal.ExecuteQuery(sql1, ds, "tSync");
                            dal.ExecuteNonQuery(sql2);
                        }
                        else
                        {
                            string sql = "select * from tSync, tUser where tSync.Owner=tUser.UserGuid and tSync.SyncType="
                                         + lockType + " and tSync.Guid='" + lockGuid + "'";

                            dal.ExecuteQuery(sql, ds, "tSync");
                        }
                    }
                }
                catch (Exception ex)
                {
                    //dal.RollbackTransaction();

                    throw (ex);
                }

                //dal.CommitTransaction();



                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #14
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in DisqualifyImageDAO!"));
                }

                string rpGuids = "", reportGuid = "", curUserGuid = "", reason = "";
                string strDomain = CommonGlobalSettings.Utilities.GetCurDomain();
                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "USERID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "REASON")
                    {
                        reason = inMap[key] as string;
                    }
                }

                if ((reportGuid == null || reportGuid.Length < 1) &&
                    (rpGuids == null || rpGuids.Length < 1))
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (curUserGuid == null || curUserGuid.Length < 1)
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (reportGuid == null)
                {
                    reportGuid = "";
                }

                reportGuid = reportGuid.Trim(" ,".ToCharArray());

                if (rpGuids == null)
                {
                    rpGuids = "";
                }

                rpGuids = rpGuids.Trim(" ,".ToCharArray());

                reason = reason == null ? "" : reason.Length >= 512 ? reason.Substring(0, 512) : reason;

                string sql = " begin ";

                if (reportGuid != null && reportGuid.Length > 0)
                {
                    sql += " delete from tReShot where procedureGuid in (select procedureGuid from tRegProcedure "
                           + " where reportGuid = '" + reportGuid + "'; "
                           + " insert into tReShot(ProcedureGuid) select procedureGuid from tRegProcedure"
                           + " where reportGuid = '" + reportGuid + "'; "
                           + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = sysdate,domain='" + strDomain + "' "
                           + " where (rejectDoctor is null or rejectDoctor = '')"
                           + " and procedureGuid in (select procedureGuid from tRegProcedure "
                           + "  where reportGuid = '" + reportGuid + "'); ";

                    sql += " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString() + " where "
                           + "  reportGuid = '" + reportGuid + "'; "
                           + " delete from tReportlist where reportGuid = '" + reportGuid + "';"
                           + "  delete from tReport where reportGuid = '" + reportGuid + "'; ";
                }
                else if (rpGuids != null && rpGuids.Length > 0)
                {
                    if (!rpGuids.Contains("'"))
                    {
                        rpGuids = rpGuids.Replace(",", "','");
                        rpGuids = rpGuids.Replace(";", "','");
                        rpGuids = "'" + rpGuids + "'";
                    }


                    sql += " delete from tReShot where procedureGuid in (" + rpGuids + "); "
                           + " insert into tReShot(ProcedureGuid) select procedureGuid from tRegProcedure"
                           + " where procedureGuid in (" + rpGuids + "); "
                           + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = sysdate,domain='" + strDomain + "' "
                           + " where (rejectDoctor is null or rejectDoctor = '') and procedureGuid in (" + rpGuids + "); ";


                    sql += " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString() + " where procedureGuid in (" + rpGuids + "); ";
                }

                sql += " commit; end;";



                // Delete
                tagReportInfo rptInfo = ServerPubFun.GetReportInfo2(rpGuids); //ServerPubFun.GetReportInfo(reportGuid);

                ServerPubFun.OnReportDelete(rptInfo, ReportCommon.RP_Status.Repeatshot);

                using (RisDAL dal = new RisDAL())
                {
                    dal.ExecuteNonQuery(sql);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "DisqualifyImageDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("-1");
        }
Exemple #15
0
        public object Execute(object param)
        {
            try
            {
                #region get parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetLockDAO!"));
                }

                string action     = "";
                string lockType   = "";
                string lockGuid   = "";
                string owner      = "";
                string ownerIP    = "";
                string rpguids    = "";
                string patientid  = "";
                string localname  = "";
                string accno      = "";
                string reportGuid = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "LOCKTYPE")
                    {
                        lockType = paramMap[key] as string;

                        if (lockType == null)
                        {
                            lockType = "";
                        }
                    }
                    else if (key.ToUpper() == "LOCKGUID")
                    {
                        lockGuid = paramMap[key] as string;

                        if (lockGuid == null)
                        {
                            lockGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "ACTION")
                    {
                        action = paramMap[key] as string;

                        if (action == null)
                        {
                            action = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNER")
                    {
                        owner = paramMap[key] as string;

                        if (owner == null)
                        {
                            owner = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNERIP")
                    {
                        ownerIP = paramMap[key] as string;

                        if (ownerIP == null)
                        {
                            ownerIP = "";
                        }
                    }
                    else if (key.ToUpper() == "RPGUIDS")
                    {
                        rpguids = paramMap[key] as string;

                        if (rpguids == null)
                        {
                            rpguids = "";
                        }
                    }
                    else if (key.ToUpper() == "PATIENTID")
                    {
                        patientid = paramMap[key] as string;

                        if (patientid == null)
                        {
                            patientid = "";
                        }
                    }
                    else if (key.ToUpper() == "LOCALNAME")
                    {
                        localname = paramMap[key] as string;

                        if (localname == null)
                        {
                            localname = "";
                        }
                    }
                    else if (key.ToUpper() == "ACCNO")
                    {
                        accno = paramMap[key] as string;

                        if (accno == null)
                        {
                            accno = "";
                        }
                    }
                    else if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                }

                #endregion



                DataSet ds = new DataSet();

                //dal.BeginTransaction();

                try
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        DataTable dtLock = null;
                        string    strSQL = "";
                        if (!string.IsNullOrEmpty(lockGuid))
                        {
                            strSQL = string.Format("select Owner,OwnerIP,RPGuids,ModuleID from tSync where guid='{0}'", lockGuid);
                            dtLock = dal.ExecuteQuery(strSQL);
                        }

                        if (action.ToUpper() == "ADD")
                        #region ADD
                        {
                            #region only ReportGuid is arrived so should get some info of patient,order and rp
                            if (!string.IsNullOrEmpty(reportGuid))
                            {
                                string strFromRp      = string.Format("select procedureguid, orderguid from tregprocedure with(nolock) where reportguid ='{0}'", reportGuid);
                                string strFromOrder   = "select accno,patientguid from tregorder with(nolock) where orderguid ='{0}'";
                                string strFromPatient = "select patientid, localname from tregpatient with(nolock) where patientguid='{0}'";
                                //get rp info
                                DataTable dtRp = dal.ExecuteQuery(strFromRp);
                                rpguids = "";
                                foreach (DataRow dr in dtRp.Rows)
                                {
                                    rpguids += Convert.ToString(dr["ProcedureGuid"]) + "&" + owner + "&" + ownerIP + "|";
                                }
                                rpguids  = rpguids.TrimEnd(new char[] { '|' });
                                lockGuid = Convert.ToString(dtRp.Rows[0]["OrderGuid"]);
                                //get accno
                                DataTable dtOrder = dal.ExecuteQuery(string.Format(strFromOrder, lockGuid));
                                accno = Convert.ToString(dtOrder.Rows[0]["AccNo"]);
                                //get patient info
                                DataTable dtPatient = dal.ExecuteQuery(string.Format(strFromPatient, dtOrder.Rows[0]["PatientGuid"]));
                                patientid = Convert.ToString(dtPatient.Rows[0]["PatientID"]);
                                localname = Convert.ToString(dtPatient.Rows[0]["LocalName"]);
                                //lockGuid has value now~
                                strSQL = string.Format("select Owner,OwnerIP,RPGuids,ModuleID from tSync where guid='{0}'", lockGuid);
                                dtLock = dal.ExecuteQuery(strSQL);
                            }
                            #endregion

                            //#region RWF

                            //if (_rwfMode == -1)
                            //    _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");

                            //if (_rwfMode == 1)
                            //{
                            //    int rpStatus = CS.GCRIS.RWF.SCU.RwfScu.getRpStatus(lockGuid);

                            //    if (CS.GCRIS.RWF.SCU.RwfScu.needClaim(lockGuid))
                            //    {
                            //        if (!CS.GCRIS.RWF.SCU.RwfScu.claim(lockGuid, owner))
                            //        {
                            //            // failed to check.
                            //            strSQL = "select top 1 '2' syncType, '" + lockGuid + "' guid, 'CSBROKER' owner,"
                            //                + " 'CSBROKER' ownerIP, '0400' moduleID, p.patientID, p.localName, o.AccNo, '' RPGuids"
                            //                + " from tRegPatient p, tRegOrder o "
                            //                + " where p.patientguid=o.patientguid AND o.orderguid='" + lockGuid + "' ";

                            //            dal.ExecuteQuery(strSQL, ds, "tSync");

                            //            return ds;
                            //        }
                            //    }
                            //    else if (100 == rpStatus)
                            //    {
                            //        CS.GCRIS.RWF.SCU.RwfScu.nSetCompleted(lockGuid, owner);
                            //    }
                            //}

                            //#endregion

                            #region add lock in ris

                            if (dtLock == null || dtLock.Rows.Count == 0)
                            {
                                string domain = CommonGlobalSettings.Utilities.GetCurDomain();

                                //Not be locked
                                strSQL = string.Format("insert tSync(syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids,domain) " +
                                                       "values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')",
                                                       lockType, lockGuid, owner, ownerIP, "0400", patientid, localname, accno, rpguids, domain);
                            }
                            else
                            {
                                if (dtLock.Rows[0]["RPGuids"] == null || dtLock.Rows[0]["RPGuids"].ToString().Trim().Length == 0)
                                {
                                    //Lock by other panel
                                    strSQL = string.Format("select syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids from tSync where guid='{0}'", lockGuid);
                                }
                                else
                                {
                                    string   strOrgRpGuids = Convert.ToString(dtLock.Rows[0]["RPGuids"]);
                                    string   strOrgOwner   = Convert.ToString(dtLock.Rows[0]["owner"]);
                                    string   strOrgOwnerIP = Convert.ToString(dtLock.Rows[0]["ownerIP"]);
                                    string   strModuleID   = Convert.ToString(dtLock.Rows[0]["moduleID"]);
                                    char[]   sep1          = { '|' };
                                    char[]   sep2          = { '&' };
                                    string[] arrItems1     = rpguids.Split(sep1);
                                    bool     bLocked       = false;
                                    string   strLockInfo   = "";
                                    foreach (string strSegment in arrItems1)
                                    {
                                        string[] arritems2 = strSegment.Split(sep2);
                                        if (arritems2[0] == null)
                                        {
                                            continue;
                                        }

                                        string[] strOrgItems = strOrgRpGuids.Split(sep1);
                                        foreach (string str in strOrgItems)
                                        {
                                            if (str.Contains(arritems2[0]))
                                            {
                                                bLocked      = true;
                                                strLockInfo += str;
                                                strLockInfo += "|";
                                            }
                                        }
                                    }

                                    if (bLocked)
                                    {
                                        strLockInfo = strLockInfo.TrimEnd('|');
                                        //Lock by other by report panel
                                        string[] arrItem3 = strLockInfo.Split(sep1);
                                        if (arrItem3.Length > 0)
                                        {
                                            DataTable dt = new DataTable("tSync");
                                            dt.Columns.Add("Description", typeof(string));
                                            dt.Columns.Add("Owner", typeof(string));
                                            dt.Columns.Add("OwnerIP", typeof(string));
                                            dt.Columns.Add("ModuleID", typeof(string));
                                            foreach (string strSegment in arrItem3)
                                            {
                                                string[] arrItem4        = strSegment.Split(sep2);
                                                string   strRPGuid       = arrItem4[0];
                                                string   strLockUserGuid = arrItem4[1];
                                                string   strLockIP       = arrItem4[2];
                                                string   str             = string.Format("select RPDesc AS Description from tRegProcedure where ProcedureGuid='{0}'", strRPGuid);
                                                object   obj             = dal.ExecuteScalar(str);
                                                if (obj == null)
                                                {
                                                    obj = "";
                                                }
                                                DataRow dr = dt.NewRow();
                                                dr["Description"] = obj.ToString();
                                                dr["Owner"]       = strLockUserGuid;
                                                dr["OwnerIP"]     = strLockIP;
                                                dr["ModuleID"]    = strModuleID;
                                                dt.Rows.Add(dr);
                                            }
                                            ds.Tables.Add(dt);
                                            strSQL = "";
                                        }
                                        else
                                        {
                                            strSQL = string.Format("select syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids from tSync where guid='{0}'", lockGuid);
                                        }
                                    }
                                    else
                                    {
                                        if (strOrgOwner.Contains(owner))
                                        {
                                            strSQL = string.Format("Update tSync set RPGuids='{0}' where guid='{1}'", strOrgRpGuids + "|" + rpguids, lockGuid);
                                        }
                                        else
                                        {
                                            strSQL = string.Format("Update tSync set RPGuids='{0}',owner='{1}',ownerip='{2}' where guid='{3}'", strOrgRpGuids + "|" + rpguids, strOrgOwner + "|" + owner, strOrgOwnerIP + "|" + ownerIP, lockGuid);
                                        }
                                    }
                                }
                            }

                            ServerPubFun.RISLog_Info(0, "GetLockDAO_MSSQL, ADD, owner=" + owner + ", ownerIP=" + ownerIP,
                                                     (new System.Diagnostics.StackFrame()).GetFileName(),
                                                     (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                            if (strSQL.Trim().Length > 0)
                            {
                                dal.ExecuteQuery(strSQL, ds, "tSync");
                            }

                            #endregion
                        }
                        #endregion
                        else if (action.ToUpper() == "DELETE" || action.ToUpper() == "DEL")
                        #region Delete
                        {
                            #region RWF

                            if (_rwfMode == -1)
                            {
                                _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");
                            }

                            /*
                             * if (_rwfMode == 1)
                             * {
                             *  int rpStatus = CS.GCRIS.RWF.SCU.RwfScu.getRpStatus(lockGuid);
                             *  if (RWF_COMPLETED_VS_RIS_STATUS == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.spsComplete(lockGuid, owner);
                             *  }
                             *  else if (100 == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.nCreate(lockGuid, owner);
                             *  }
                             *  else if (50 == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.spsDefer(lockGuid, owner);
                             *  }
                             *  else
                             *  {
                             *      // do nothing
                             *  }
                             * }
                             */
                            #endregion

                            #region delete lock in ris

                            if (dtLock != null && dtLock.Rows.Count > 0)
                            {
                                string strOrgRpGuids = Convert.ToString(dtLock.Rows[0]["RPGuids"]);


                                string   strOrgOwner   = Convert.ToString(dtLock.Rows[0]["owner"]);
                                string   strOrgOwnerIP = Convert.ToString(dtLock.Rows[0]["ownerIP"]);
                                char[]   sep           = { '|' };
                                string[] arrItems      = rpguids.Split(sep);
                                bool     bLocked       = false;
                                foreach (string strRpGuid in arrItems)
                                {
                                    if (strOrgRpGuids.Contains(strRpGuid + "|"))
                                    {
                                        strOrgRpGuids = strOrgRpGuids.Replace(strRpGuid + "|", "");
                                    }
                                    else if (strOrgRpGuids.Contains(strRpGuid))
                                    {
                                        strOrgRpGuids = strOrgRpGuids.Replace(strRpGuid, "");
                                    }
                                }
                                strOrgRpGuids = strOrgRpGuids.TrimEnd('|');
                                if (strOrgRpGuids.Trim().Length == 0)
                                {
                                    strSQL = string.Format("delete from tSync where guid='{0}'", lockGuid);
                                }
                                else
                                {
                                    string[] arrItems1 = strOrgOwner.Split(sep);
                                    if (arrItems1.Length > 1)
                                    {
                                        foreach (string strOwner in arrItems1)
                                        {
                                            bool     bRPGuidContainOwner = false;
                                            string[] arr10 = strOrgRpGuids.Split('|');
                                            foreach (string strRPGuid10 in arr10)
                                            {
                                                string[] arr11 = strRPGuid10.Split('&');
                                                if (owner.ToUpper() == arr11[1].ToUpper())
                                                {
                                                    bRPGuidContainOwner = true;
                                                    break;
                                                }
                                            }

                                            bool     bOwnerContain = false;
                                            string[] arr12         = strOrgOwner.Split('|');
                                            foreach (string strOwner10 in arr12)
                                            {
                                                if (owner.ToUpper() == strOwner10.ToUpper())
                                                {
                                                    bOwnerContain = true;
                                                    break;
                                                }
                                            }

                                            if (bOwnerContain && !bRPGuidContainOwner)
                                            {
                                                if (strOrgOwner.Contains(owner + "|"))
                                                {
                                                    strOrgOwner = strOrgOwner.Replace(owner + "|", "");
                                                }
                                                else
                                                {
                                                    //strOrgOwner = strOrgOwner.Replace(owner, "");
                                                    strOrgOwner = "";
                                                    foreach (string strOwner10 in arr12)
                                                    {
                                                        if (owner.ToUpper() != strOwner10.ToUpper())
                                                        {
                                                            strOrgOwner += strOwner10;
                                                            strOrgOwner += "|";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        strOrgOwner = strOrgOwner.TrimEnd('|');

                                        string[] arrItems2 = strOrgOwnerIP.Split(sep);
                                        foreach (string strOwnerIP in arrItems2)
                                        {
                                            if (strOrgOwnerIP.Contains(ownerIP + "|") && !strOrgRpGuids.Contains(ownerIP))
                                            {
                                                strOrgOwnerIP = strOrgOwnerIP.Replace(ownerIP + "|", "");
                                            }
                                            else if (strOrgOwnerIP.Contains(ownerIP) && !strOrgRpGuids.Contains(ownerIP))
                                            {
                                                strOrgOwnerIP = strOrgOwnerIP.Replace(ownerIP, "");
                                            }
                                        }
                                        strOrgOwnerIP = strOrgOwnerIP.TrimEnd('|');
                                        strSQL        = string.Format("update tSync set owner='{0}',ownerip='{1}',rpguids='{2}' where guid='{3}'", strOrgOwner, strOrgOwnerIP, strOrgRpGuids, lockGuid);
                                    }
                                    else
                                    {
                                        strSQL = string.Format("update tSync set rpguids='{0}' where guid='{1}'", strOrgRpGuids, lockGuid);
                                    }
                                }



                                dal.ExecuteQuery(strSQL, ds, "tSync");
                            }
                            #endregion
                        }
                        #endregion
                        else
                        #region Query
                        {
                            string sql = "select * from tSync, tUser where tSync.Owner=tUser.UserGuid and tSync.SyncType="
                                         + lockType + " and tSync.Guid='" + lockGuid + "'";

                            dal.ExecuteQuery(sql, ds, "tSync");
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    //dal.RollbackTransaction();

                    System.Diagnostics.Debug.Assert(false, ex.Message);

                    ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                              (new System.Diagnostics.StackFrame()).GetFileName(),
                                              (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                    throw (ex);
                }



                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #16
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter!"));
                }

                string parentGuid = "", userGuid = "", type = "";

                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "PARENTGUID")
                    {
                        parentGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "USERGUID" || key.ToUpper() == "USERID")
                    {
                        userGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "TYPE")
                    {
                        type = inMap[key] as string;
                    }
                }

                parentGuid = parentGuid == null ? "" : parentGuid.Trim();
                userGuid   = userGuid == null ? "" : userGuid.Trim();
                type       = type == null ? "" : type.Trim();

                string sql = "", sql0 = "", sql1 = "";

                if (type.CompareTo("1") == 0)
                {
                    /*sql = " select * from tReportTemplateDirec left join tReportTemplate on tReportTemplate.templateGuid = tReportTemplateDirec.templateGuid \r\n"
                     + " where (tReportTemplateDirec.type = 0 or (tReportTemplateDirec.type = 1 and tReportTemplateDirec.UserGuid='" + userGuid + "')) \r\n";
                     +
                     + if (parentGuid.Length > 0)
                     + {
                     +  sql = " and tReportTemplateDirec.parentid = '" + parentGuid + "' \r\n";
                     + }
                     +
                     + sql += " order by tReportTemplateDirec.type, tReportTemplateDirec.itemorder \r\n";
                     */
                    sql = string.Format("select * from tReportTemplateDirec where ParentID = 'UserTemplate' and (type=0 or UserGuid = '{0}') order by ItemOrder", userGuid);
                }
                else if (type.CompareTo("2") == 0)
                {
                    sql0 = " select * from tPhraseTemplate where (type = 0 or type = 2 or (type = 1 and UserGuid='" + userGuid + "')) order by type, modalityType \r\n";
                }
                else if (type.CompareTo("3") == 0)
                {
                    sql1 = " select SELECT TemplateGuid,Type,TemplateName,IsDefaultByType,Version,ModalityType,IsDefaultByModality  from tPrintTemplate \r\n";
                }
                else
                {
                    sql = " select * from tReportTemplateDirec left join tReportTemplate on tReportTemplate.templateGuid = tReportTemplateDirec.templateGuid \r\n"
                          + " where (tReportTemplateDirec.type = 0 or tReportTemplateDirec.type = 2 or (tReportTemplateDirec.type = 1 and tReportTemplateDirec.UserGuid='" + userGuid + "')) and tReportTemplateDirec.DirectoryType='report' \r\n";

                    if (parentGuid.Length > 0)
                    {
                        sql = " and tReportTemplateDirec.parentid = '" + parentGuid + "' \r\n";
                    }

                    sql += " order by tReportTemplateDirec.type, tReportTemplateDirec.itemorder \r\n";

                    ////sql0 = " select * from tPhraseTemplate where (type = 0 or (type = 1 and UserGuid='" + userGuid + "')) order by type, modalityType \r\n";
                    sql0 = " select tReportTemplateDirec.*, tPhraseTemplate.TemplateGuid,tPhraseTemplate.TemplateName,tPhraseTemplate.TemplateInfo,tPhraseTemplate.ShortcutCode from tReportTemplateDirec left join tPhraseTemplate on tPhraseTemplate.templateGuid = tReportTemplateDirec.templateGuid \r\n"
                           + " where (tReportTemplateDirec.type = 0 or tReportTemplateDirec.type = 2 or (tReportTemplateDirec.type = 1 and tReportTemplateDirec.UserGuid='" + userGuid + "')) and tReportTemplateDirec.DirectoryType='phrase' order by tReportTemplateDirec.type, tReportTemplateDirec.itemorder \r\n";

                    sql1 = " SELECT TemplateGuid,Type,TemplateName,IsDefaultByType,Version,ModalityType,IsDefaultByModality from tPrintTemplate \r\n";
                }



                DataSet ds = new DataSet();

                using (RisDAL dal = new RisDAL())
                {
                    if (sql != null && sql.Length > 0)
                    {
                        DataTable dt = new DataTable("ReportTemplate");
                        dal.ExecuteQuery(sql, dt);
                        ds.Tables.Add(dt);
                    }

                    if (sql0 != null && sql0.Length > 0)
                    {
                        DataTable dt0 = new DataTable("Phrase");
                        dal.ExecuteQuery(sql0, dt0);
                        ds.Tables.Add(dt0);
                    }

                    if (sql1 != null && sql1.Length > 0)
                    {
                        DataTable dt1 = new DataTable("PrintTemplate");
                        dal.ExecuteQuery(sql1, dt1);
                        ds.Tables.Add(dt1);
                    }

                    return(ds);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportTemplateDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #17
0
        public object Execute(object param)
        {
            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListDAO!", "", 0);
                }

                using (RisDAL dal = new RisDAL())
                {
                    string condition = "", userGuid = "", panelName = GRIDNAME_DEFAULT;
                    int    nPagesize = 0, nCurpage = 0;
                    string strOrderBy   = "";
                    bool   bOfflineData = false;

                    foreach (string key in paramMap.Keys)
                    {
                        switch (key.ToUpper())
                        {
                        case "CONDITION":
                        {
                            condition = paramMap[key] as string;

                            if (condition == null)
                            {
                                condition = "";
                            }
                        }
                        break;

                        case "PAGESIZE":
                        {
                            nPagesize = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        break;

                        case "CURPAGE":
                        {
                            nCurpage = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        break;

                        case "USERID":
                        {
                            userGuid = paramMap[key] as string;
                        }
                        break;

                        case "PANELNAME":
                        {
                            panelName = paramMap[key] as string;
                        }
                        break;

                        case "SORTING":
                        {
                            strOrderBy = paramMap[key] as string;
                        }
                        break;

                        case "OFFLINEDATA":
                        {
                            bOfflineData = (System.Convert.ToString(paramMap[key]) == "1");
                        }
                        break;
                        }
                    }

                    condition = condition == null ? "" : condition;
                    userGuid  = userGuid == null ? "" : userGuid;
                    panelName = panelName == null ? "" : panelName;
                    nPagesize = nPagesize < 1 ? ReportCommon.ReportCommon.DEFAULT_PAGESIZE : nPagesize;
                    nCurpage  = nCurpage < 1 ? 0 : nCurpage;

                    #endregion

                    //#region RWF

                    //if (_rwfMode == -1)
                    //    _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");

                    //if (_rwfMode == 1)
                    //{
                    //    CS.GCRIS.RWF.SCU.RwfScu.queryWorklist(condition);

                    //    // ONLY for RWF test
                    //    condition = CS.GCRIS.RWF.SCU.RwfScu.composeSQLfromConditionMap(CS.GCRIS.RWF.SCU.RwfScu.parserCondition(condition));
                    //}

                    //#endregion

                    #region Compose SQL sentense

                    string sqlcol = GetSqlCol(panelName, userGuid).Trim();
                    if (!sqlcol.Contains("tRegProcedure.Status as RPStatus"))
                    {
                        sqlcol += ",tRegProcedure.Status as RPStatus";
                    }
                    if (!sqlcol.Contains("tRegProcedure.Optional3 as IsLocked"))
                    {
                        sqlcol += ",tRegProcedure.Optional3 as IsLocked";
                    }
                    if (!sqlcol.Contains("tRegProcedure.ExamSystem as tRegProcedure__ExamSystem"))
                    {
                        sqlcol += ",tRegProcedure.ExamSystem as tRegProcedure__ExamSystem";
                    }
                    if (!sqlcol.Contains("convert(varchar(max),tRegOrder.OrderMessage) as OrderMessageXml "))
                    {
                        sqlcol += ",convert(varchar(max),tRegOrder.OrderMessage) as OrderMessageXml ";
                    }
                    if (!sqlcol.Contains("tReport.CreaterName as tReport__CreaterName"))
                    {
                        sqlcol += ",tReport.CreaterName as tReport__CreaterName";
                    }
                    if (!sqlcol.Contains("tReport.SubmitterName as tReport__SubmitterName"))
                    {
                        sqlcol += ",tReport.SubmitterName as tReport__SubmitterName";
                    }
                    if (!sqlcol.Contains("tReport.FirstapproverName as tReport__FirstapproverName"))
                    {
                        sqlcol += ",tReport.FirstapproverName as tReport__FirstapproverName";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawDept as tRegOrder__FilmDrawDept"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawDept as tRegOrder__FilmDrawDept";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawRegion as tRegOrder__FilmDrawRegion"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawRegion as tRegOrder__FilmDrawRegion";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawComment as tRegOrder__FilmDrawComment"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawComment as tRegOrder__FilmDrawComment";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawerSign as tRegOrder__FilmDrawerSign"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawerSign as tRegOrder__FilmDrawerSign";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmDept as tReport__TakeFilmDept"))
                    {
                        sqlcol += ",tReport.TakeFilmDept as tReport__TakeFilmDept";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmRegion as tReport__TakeFilmRegion"))
                    {
                        sqlcol += ",tReport.TakeFilmRegion as tReport__TakeFilmRegion";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmComment as tReport__TakeFilmComment"))
                    {
                        sqlcol += ",tReport.TakeFilmComment as tReport__TakeFilmComment ";
                    }

                    sqlcol = sqlcol.Length > 0 ? sqlcol : "No Grid Column Setting!";

                    // 2015-11-06, Oscar removed (US28272)
                    //string plainColumns = sqlcol;

                    //plainColumns = removeBrackets(plainColumns);
                    //plainColumns = plainColumns.Replace(" AS ", " as ");
                    //int asTmp0 = 0;
                    //while ((asTmp0 = plainColumns.IndexOf(" as ")) > 0)
                    //{
                    //    int comma0 = plainColumns.LastIndexOf(',', asTmp0);

                    //    if (comma0 < 0)
                    //        plainColumns = " " + plainColumns.Substring(asTmp0 + 4);
                    //    else
                    //        plainColumns = plainColumns.Substring(0, comma0 + 1) + " " + plainColumns.Substring(asTmp0 + 4);
                    //}

                    //while ((asTmp0 = plainColumns.IndexOf(".")) > 0)
                    //{
                    //    int comma0 = plainColumns.LastIndexOf(',', asTmp0);

                    //    if (comma0 < 0)
                    //        plainColumns = " " + plainColumns.Substring(asTmp0 + 1);
                    //    else
                    //        plainColumns = plainColumns.Substring(0, comma0 + 1) + " " + plainColumns.Substring(asTmp0 + 1);
                    //}

                    string sql = "";

                    string strWhere = " from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock) \r\n"
                                      + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                                      + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                                      + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                                      + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                    string strWhereforArchive = " from RISArchive..tRegPatient tRegPatient with (nolock), RISArchive..tRegOrder tRegOrder with (nolock), RISArchive..tRegProcedure tRegProcedure with (nolock) \r\n"
                                                + " left join RISArchive..tReport tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                                                + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                                                + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                                                + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                    if (condition.Length > 0)
                    {
                        while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                        {
                            condition = condition.Substring(0, condition.Length - 3);
                        }

                        strWhere           += " and " + condition;
                        strWhereforArchive += " and " + condition;
                    }
                    if (strWhere.Length > 4096)
                    {
                        throw new Exception("The query conditions is too long!");
                    }

                    #endregion

                    #region Execute Query

                    DataSet ds = new DataSet();

                    //DataSet tmp = new DataSet();

                    if (0 == iWrittenCount++ % 100)
                    {
                        ServerPubFun.RISLog_Info(0, "GetReportsListDAO_MSSQL, curPage=" + nCurpage.ToString() + ", SQL=" + sql, "", 0);
                    }
                    else
                    {
                        ServerPubFun.RISLog_Info(0, "GetReportsListDAO_MSSQL, curPage=" + nCurpage.ToString() + ", condition=" + condition + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                    }

                    //{Bruce Deng 20071128
                    //dal.ExecuteQuery(sql, tmp, "ReportsList");
                    dal.Parameters.Clear();
                    dal.Parameters.AddInt("@PageIndex", nCurpage);
                    dal.Parameters.AddInt("@PageSize", nPagesize);
                    dal.Parameters.AddVarChar("@Columns", sqlcol, 8000);
                    dal.Parameters.AddVarChar("@Where", strWhere, 8000);
                    dal.Parameters.AddVarChar("@WhereArchive", bOfflineData ? strWhereforArchive : "", 8000);
                    //dal.Parameters.AddVarChar("@plainColumns", plainColumns, 8000);
                    dal.Parameters.AddVarChar("@OrderBy", bOfflineData ? strOrderBy.Replace(".", "__") : strOrderBy, 8000);
                    int nTotalCount = 0;
                    dal.Parameters.AddInt("@TotalCount", nTotalCount, ParameterDirection.Output);
                    DataTable dt1 = new DataTable();
                    dal.ExecuteQuerySP("SP_REPORT_PAGE", dt1);
                    dt1.TableName = "ReportList";

                    if (dal.Parameters["@TotalCount"].Value != null)
                    {
                        nTotalCount = Convert.ToInt32(dal.Parameters["@TotalCount"].Value);
                    }
                    //}

                    if (-1 == nTotalCount)
                    {
                        nTotalCount = dt1.Rows.Count;
                    }

                    if (dt1 != null)
                    {
                        ////DataTable dt = tmp.Tables[0].Clone();
                        //DataTable dt = new DataTable();
                        //dt.TableName = "ReportPage";
                        //foreach (DataColumn dc in dt1.Columns)
                        //{
                        //    dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                        //}

                        //if (dt1.Rows.Count > 0)
                        //{
                        //    if (dt1.Rows.Count <= (Int64)nCurpage * nPagesize)
                        //    {
                        //        int ipage = (dt1.Rows.Count - 1) / nPagesize;
                        //        for (int i = ipage * nPagesize; i < dt1.Rows.Count; i++)
                        //        {
                        //            DataRow dr = dt.NewRow();

                        //            foreach (DataColumn col in dt.Columns)
                        //            {
                        //                dr[col.ColumnName] = dt1.Rows[i][col.ColumnName];
                        //            }

                        //            dt.Rows.Add(dr);
                        //        }

                        //        nCurpage = ipage;
                        //    }
                        //    else
                        //    {
                        //        for (int i = nCurpage * nPagesize; i < (nCurpage + 1) * nPagesize && i < dt1.Rows.Count; i++)
                        //        {
                        //            DataRow dr = dt.NewRow();

                        //            foreach (DataColumn col in dt.Columns)
                        //            {
                        //                dr[col.ColumnName] = dt1.Rows[i][col.ColumnName];
                        //            }

                        //            dt.Rows.Add(dr);
                        //        }
                        //    }
                        //}
                        //else
                        //{
                        //    nCurpage = 0;
                        //}

                        //ds.Tables.Add(dt);
                        //ds.Tables.Add(dt1);

                        //if (dt1.Rows.Count > 0)
                        //{
                        //    if (dt1.Rows.Count <= (Int64)nCurpage * nPagesize)
                        //    {
                        //        int ipage = (dt1.Rows.Count - 1) / nPagesize;

                        //        nCurpage = ipage;
                        //    }
                        //}
                        //else
                        //{
                        //    nCurpage = 0;
                        //}

                        //StringBuilder sb = new StringBuilder();
                        //sb.AppendFormat("rownum > {0} AND rownum <= {1}", nCurpage * nPagesize, (nCurpage + 1) * nPagesize);

                        //dt1.DefaultView.RowFilter = sb.ToString();
                        //DataTable dt = dt1.DefaultView.ToTable("ReportPage");
                        DataTable dt = dt1.Copy();//.DefaultView.ToTable("ReportPage");
                        dt.TableName = "ReportPage";

                        ds.Tables.Add(dt);
                        ds.Tables.Add(dt1);
                    }


                    #endregion


                    Dictionary <string, object> outMap = new Dictionary <string, object>();

                    outMap.Add("DataSet", ds);
                    outMap.Add("CurPage", nCurpage);
                    outMap.Add("TotalCount", nTotalCount);

                    return(outMap);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListDAO_MSSQL, MSG=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                throw new Exception(ex.Message);
            }

            return(null);
        }
Exemple #18
0
        public object Execute(object param)
        {
            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListDAO!", "", 0);
                }

                using (RisDAL dal = new RisDAL())
                {
                    string condition = "", userGuid = "", panelName = GRIDNAME_DEFAULT;
                    int    nPagesize = 0, nCurpage = 0;

                    foreach (string key in paramMap.Keys)
                    {
                        if (key.ToUpper() == "CONDITION")
                        {
                            condition = paramMap[key] as string;

                            if (condition == null)
                            {
                                condition = "";
                            }
                        }
                        else if (key.ToUpper() == "PAGESIZE")
                        {
                            nPagesize = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        else if (key.ToUpper() == "CURPAGE")
                        {
                            nCurpage = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        else if (key.ToUpper() == "USERID")
                        {
                            userGuid = paramMap[key] as string;
                        }
                        else if (key.ToUpper() == "PANELNAME")
                        {
                            panelName = paramMap[key] as string;
                        }
                    }

                    condition = condition == null ? "" : condition;
                    userGuid  = userGuid == null ? "" : userGuid;
                    panelName = panelName == null ? "" : panelName;
                    nPagesize = nPagesize < 1 ? ReportCommon.ReportCommon.DEFAULT_PAGESIZE : nPagesize;
                    nCurpage  = nCurpage < 1 ? 0 : nCurpage;

                    #endregion

                    #region Compose SQL sentense

                    string sqlcol = GetSqlCol(panelName, userGuid).Trim();
                    sqlcol = sqlcol.Length > 0 ? sqlcol : "No Grid Column Setting!";

                    string sql = "";

                    if (nPagesize * (nCurpage + 1) >= 5000 || nPagesize * (nCurpage + 1) < 0)
                    {
                        sql += "select " + sqlcol + ",tRegProcedure.Status as RPStatus,tRegProcedure.Optional3 as IsLocked  \r\n"
                               + " from tRegPatient, tRegOrder, tRegProcedure \r\n"
                               + " left join tReport on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                               + " , tProcedureCode"
                               + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                               + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                               + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n"
                               + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);
                    }
                    else
                    {
                        sql += "select " + sqlcol + ",tRegProcedure.Status as RPStatus,tRegProcedure.Optional3 as IsLocked  \r\n"
                               + " from tRegPatient, tRegOrder, tRegProcedure \r\n"
                               + " left join tReport on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                               + " , tProcedureCode"
                               + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                               + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                               + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n"
                               + " and rownum < " + (nPagesize * (nCurpage + 1)).ToString()
                               + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);
                    }

                    if (condition.Length > 0)
                    {
                        while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                        {
                            condition = condition.Substring(0, condition.Length - 3);
                        }

                        sql += " and " + getOracleDateString(condition);
                    }

                    #endregion

                    #region Execute Query

                    DataSet ds = new DataSet();

                    //if (nCurpage < 10)
                    //{
                    //    sql = " select * from (" + sql + ") _ReportA where _rowindex between " + (nCurpage * nPagesize + 1).ToString() + " and " + ((nCurpage + 1) * nPagesize).ToString();

                    //    ReportCommon.ReportCommon.WriteDebugLog("CurPage=" + nCurpage.ToString() + "\r\n" + sql);

                    //    dal.ExecuteQuery(sql, ds, "ReportsList");
                    //}
                    //else
                    {
                        DataSet tmp = new DataSet();



                        dal.ExecuteQuery(sql, tmp, "ReportsList");

                        if (tmp != null && tmp.Tables.Count > 0)
                        {
                            //DataTable dt = tmp.Tables[0].Clone();
                            DataTable dt = new DataTable();

                            foreach (DataColumn dc in tmp.Tables[0].Columns)
                            {
                                dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                            }

                            if (tmp.Tables[0].Rows.Count > 0)
                            {
                                if (tmp.Tables[0].Rows.Count <= (Int64)nCurpage * nPagesize)
                                {
                                    int ipage = (tmp.Tables[0].Rows.Count - 1) / nPagesize;
                                    for (int i = ipage * nPagesize; i < tmp.Tables[0].Rows.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();

                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            dr[col.ColumnName] = tmp.Tables[0].Rows[i][col.ColumnName];
                                        }

                                        dt.Rows.Add(dr);
                                    }

                                    nCurpage = ipage;
                                }
                                else
                                {
                                    for (int i = nCurpage * nPagesize; i < (nCurpage + 1) * nPagesize && i < tmp.Tables[0].Rows.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();

                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            dr[col.ColumnName] = tmp.Tables[0].Rows[i][col.ColumnName];
                                        }

                                        dt.Rows.Add(dr);
                                    }
                                }
                            }
                            else
                            {
                                nCurpage = 0;
                            }

                            ds.Tables.Add(dt);
                        }
                    }

                    #endregion



                    Dictionary <string, object> outMap = new Dictionary <string, object>();

                    outMap.Add("DataSet", ds);
                    outMap.Add("CurPage", nCurpage);

                    return(outMap);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListDAO_ORACLE=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #19
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public object Execute(object param)
        {
            int    iRet = -1;
            string sql  = "";

            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListCountDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListCountDAO!", "", 0);
                }

                string condition    = "";
                bool   bOfflineData = false;

                foreach (string key in paramMap.Keys)
                {
                    switch (key.ToUpper())
                    {
                    case "CONDITION":
                    {
                        condition = paramMap[key] as string;

                        if (condition == null)
                        {
                            condition = "";
                        }
                    }
                    break;

                    case "OFFLINEDATA":
                    {
                        bOfflineData = (System.Convert.ToString(paramMap[key]) == "1");
                    }
                    break;
                    }
                }

                condition = condition == null ? "" : condition;

                #endregion

                #region Compose SQL sentense

                //sql = "select count(1) "
                //     + " from tRegPatient, tRegOrder, tRegProcedure "
                //     + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid "
                //     + " , tProcedureCode"
                //     + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid "
                //     + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid "
                //     + " and tProcedureCode.ProcedureCode = tRegProcedure.ProcedureCode "
                //     + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                //if (condition != null && condition.Length > 0)
                //{
                //    while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                //    {
                //        condition = condition.Substring(0, condition.Length - 3);
                //    }

                //    sql += " and " + condition;
                //}

                #endregion

                #region Execute Query

                using (RisDAL dal = new RisDAL())
                {
                    DataTable dt = new DataTable();

                    //if (0 == iWrittenCount++ % 100)
                    //{
                    //    ServerPubFun.RISLog_Info(0, "GetReportsListCountDAO_MSSQL, SQL=" + sql, "", 0);
                    //}
                    //else
                    //{
                    //    ServerPubFun.RISLog_Info(0, "GetReportsListCountDAO_MSSQL, condition=" + condition + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                    //}

                    //dal.ExecuteQuery(sql, dt);

                    //if (dt != null && dt.Rows.Count > 0)
                    //{
                    //    iRet = System.Convert.ToInt32(dt.Rows[0][0]);
                    //}

                    dal.Parameters.Clear();
                    dal.Parameters.AddVarChar("@condition", condition, 8000);
                    dal.Parameters.AddVarChar("@offlineCondition", bOfflineData ? "1" : "", 8000);
                    dal.Parameters.AddInt("@TotalCount", iRet, ParameterDirection.Output);

                    DataTable dt1 = new DataTable();
                    dal.ExecuteQuerySP("SP_REPORT_PAGE_COUNT", dt1);
                    dt1.TableName = "ReportList";

                    if (dal.Parameters["@TotalCount"].Value != null)
                    {
                        iRet = Convert.ToInt32(dal.Parameters["@TotalCount"].Value);
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListCountDAO_MSSQL, MSG=" + ex.Message + ", SQL=" + sql,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(iRet);
        }
Exemple #20
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in SaveReportDAO!"));
                }

                string[] reportGuids = null;
                string   curUserGuid = "", comments = "", snapShotSrvPath = "", modalityType = "", modality = "";
                int      logType = 0, cnt = 1, costTime = 0;
                string   strType = "", strMultiCostTime = null;
                string   strPrintTemplateGuid = "";

                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "LOGTYPE")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            logType = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "REPORTGUIDS" || key.ToUpper() == "REPORTGUID")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && (tmp = tmp.Trim(", ".ToCharArray())).Length > 0)
                        {
                            reportGuids = tmp.Split(',');
                        }
                    }
                    else if (key.ToUpper() == "COUNT")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            cnt = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "USERID" || key.ToUpper() == "USERGUID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "COMMENTS")
                    {
                        comments = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "SNAPSHOTSRVPATH")
                    {
                        snapShotSrvPath = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MODALITYTYPE")
                    {
                        modalityType = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MODALITY")
                    {
                        modality = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "COSTTIME")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            costTime = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "TYPE")
                    {
                        strType = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MULTICOSTTIME")
                    {
                        strMultiCostTime = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "PRINTTEMPLATEGUID")
                    {
                        strPrintTemplateGuid = inMap[key] as string;
                    }
                }

                string sql = "";

                string strDomain = CommonGlobalSettings.Utilities.GetCurDomain();

                if (strMultiCostTime != null && strMultiCostTime.Trim().Length > 0)
                {
                    string[] arrCostTime = strMultiCostTime.Split('|');

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Exam2Draft + ", '" + modalityType + "', "
                           + arrCostTime[0].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "') \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Draft2Submit + ", '" + modalityType + "', "
                           + arrCostTime[1].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Submit2Approve + ", '" + modalityType + "', "
                           + arrCostTime[2].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_ApproveStart2End + ", '" + modalityType + "', "
                           + arrCostTime[3].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";
                }
                else
                {
                    if (logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Exam2Draft) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Draft2Submit) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Submit2Approve) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_ApproveStart2End) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Exam2Print))
                    {
                        if (reportGuids.Length > 0)
                        {
                            sql = "insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                                  + " values('" + Guid.NewGuid().ToString() + "', " + logType.ToString() + ", '" + modalityType + "', "
                                  + costTime.ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')";
                        }
                    }
                    // 2015-06-08, Oscar added (US25173)
                    else if (logType == (int)ReportCommon.ReportLog_Type.EventLog_SubmitCostTime ||
                             logType == (int)ReportCommon.ReportLog_Type.EventLog_ApproveCostTime)
                    {
                        if (reportGuids.Length > 0)
                        {
                            sql += UpsertEventLog(logType, modalityType, costTime, curUserGuid, strDomain, reportGuids[0]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < reportGuids.Length; i++)
                        {
                            string tmp = reportGuids.GetValue(i) as string;
                            if (tmp != null && tmp.Length > 0)
                            {
                                if (cnt < 1)
                                {
                                    sql += " insert into tReportPrintLog(fileGuid, ReportGuid,Printer,PrintDt,Counts,Comments,snapShotSrvPath,Type,Domain) "
                                           + " values(newid(), '" + tmp + "', '" + curUserGuid + "', getdate(), "
                                           + cnt.ToString() + ", '" + comments + "', '" + snapShotSrvPath + "','" + strType + "','" + strDomain + "') \r\n";
                                }
                                else
                                {
                                    sql += " update tReport set isPrint=1,Optional1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', PrintTemplateGuid ='" + strPrintTemplateGuid + "' where reportGuid='" + tmp + "' \r\n"
                                           + " insert into tReportPrintLog(fileGuid, ReportGuid,Printer,PrintDt,Counts,Comments,snapShotSrvPath,Type,PrintTemplateGuid,Domain)"
                                           + " values(newid(), '" + tmp + "', '" + curUserGuid + "', getdate(), "
                                           + cnt.ToString() + ", '" + comments + "', '" + snapShotSrvPath + "','" + strType + "','" + strPrintTemplateGuid + "','" + strDomain + "') \r\n";
                                }
                            }
                        }
                    }
                }
                if (0 == iWrittenLog++ % 100)
                {
                    ServerPubFun.RISLog_Info(0, "RecordLogDAO, UserGuid=" + curUserGuid + ", SQL=" + sql,
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                }
                else
                {
                    ServerPubFun.RISLog_Info(0, "RecordLogDAO, UserGuid=" + curUserGuid + ", reportGuids=" + reportGuids.ToString(),
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                }

                if (sql.Length > 0)
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        dal.ExecuteNonQuery(sql);

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "RecordLogDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(false);
        }
Exemple #21
0
        public object Execute(object param, ref string strObjectGuids)
        {
            try
            {
                #region Parse the parameters

                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in ReportOpenPolicyDAO!"));
                }

                string RPGuids      = "";
                bool   bAssociated  = false;
                bool   bOfflineData = false;

                foreach (string key in inMap.Keys)
                {
                    switch (key.ToUpper())
                    {
                    case "RPGUIDS":
                    {
                        RPGuids = inMap[key] as string;
                    }
                    break;

                    case "ASSOCIATED":
                    {
                        bAssociated = (System.Convert.ToString(inMap[key]) == "1");
                    }
                    break;

                    case "OFFLINEDATA":
                    {
                        bOfflineData = (System.Convert.ToString(inMap[key]) == "1");
                    }
                    break;
                    }
                }

                #endregion

                string strSQL = "";

                bool bExistImage = true;
                using (RisDAL dal = new RisDAL())
                {
                    if (bAssociated)
                    {
                        string strTemp = "";
                        strSQL = string.Format(
                            "   SELECT OrderGuid,status,reportGuid FROM tregprocedure where procedureguid='{0}' ", RPGuids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]);

                        if (bOfflineData)
                        {
                            strSQL += string.Format(" UNION "
                                                    + " SELECT OrderGuid,status,reportGuid FROM RISArchive..tregprocedure where procedureguid='{0}' ", RPGuids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]);
                        }

                        DataTable dt1 = dal.ExecuteQuery(strSQL);
                        if (dt1 == null || dt1.Rows.Count < 1)
                        {
                            // RP not exists
                            return(2);
                        }

                        if (Convert.ToInt32(dt1.Rows[0]["status"]) != 50)
                        {
                            strObjectGuids = Convert.ToString(dt1.Rows[0]["ReportGuid"]);

                            if (string.IsNullOrEmpty(strObjectGuids))
                            {
                                return(2);
                            }
                            else
                            {
                                return(1);
                            }
                        }


                        strSQL = string.Format(
                            "   SELECT ProcedureGuid,IsExistImage  FROM   tregprocedure where status=50 and OrderGuid='{0}' "
                            , Convert.ToString(dt1.Rows[0]["OrderGuid"]));

                        if (bOfflineData)
                        {
                            strSQL += string.Format(" UNION "
                                                    + " SELECT ProcedureGuid,IsExistImage  FROM   RISArchive..tregprocedure where status=50 and OrderGuid='{0}' "
                                                    , Convert.ToString(dt1.Rows[0]["OrderGuid"]));
                        }

                        dt1 = dal.ExecuteQuery(strSQL);


                        foreach (DataRow dr in dt1.Rows)
                        {
                            string strRPGuid = Convert.ToString(dr["ProcedureGuid"]);
                            strTemp += strRPGuid;
                            strTemp += ",";
                            if (dr["IsExistImage"] is DBNull || dr["IsExistImage"] == null || Convert.ToInt32(dr["IsExistImage"]) == 0)
                            {
                                bExistImage = false;
                            }
                        }
                        strObjectGuids = strTemp.TrimEnd(',');
                        return(bExistImage ? 0 : 4);
                    }

                    //
                    if (RPGuids.Split(',').Length > 1)
                    {
                        RPGuids = RPGuids.Trim(", ".ToCharArray());
                        RPGuids = RPGuids.Replace(",", "','");
                        RPGuids = "'" + RPGuids + "'";
                        strSQL  = string.Format(
                            "  SELECT A.OrderGuid,A.Status,A.IsExistImage,A.ReportGuid from tRegProcedure A  where A.ProcedureGuid in({0})"
                            , RPGuids);

                        if (bOfflineData)
                        {
                            strSQL += string.Format(" UNION "
                                                    + " SELECT A.OrderGuid,A.Status,A.IsExistImage,A.ReportGuid from RISArchive..tRegProcedure A  where A.ProcedureGuid in({0})"
                                                    , RPGuids);
                        }
                    }
                    else
                    {
                        strSQL = string.Format(
                            "  SELECT A.OrderGuid,A.Status,A.IsExistImage,A.ReportGuid from tRegProcedure A where A.ProcedureGuid ='{0}'"
                            , RPGuids);

                        if (bOfflineData)
                        {
                            strSQL += string.Format(" UNION "
                                                    + " SELECT A.OrderGuid,A.Status,A.IsExistImage,A.ReportGuid from RISArchive..tRegProcedure A where A.ProcedureGuid ='{0}'"
                                                    , RPGuids);
                        }
                    }

                    DataTable dt2 = dal.ExecuteQuery(strSQL);

                    if (dt2 == null || dt2.Rows.Count == 0)
                    {
                        // RP NOT exists
                        return(2);
                    }


                    bool bSameOrder = true;

                    string    strExpression = "status>50";
                    DataRow[] drFound       = dt2.Select(strExpression);
                    if (drFound.Length != 0)
                    {
                        foreach (DataRow dr in drFound)
                        {
                            if (dr["ReportGuid"] != null && !(dr["ReportGuid"] is DBNull))
                            {
                                strObjectGuids += Convert.ToString(dr["ReportGuid"]);
                            }
                            strObjectGuids += ",";
                        }
                        strObjectGuids.TrimEnd(',');
                        return(1);
                    }
                    else
                    {
                        strObjectGuids = RPGuids;
                    }

                    strExpression = "IsExistImage=0";
                    drFound       = dt2.Select(strExpression);
                    if (drFound.Length > 0)
                    {
                        bExistImage = false;
                    }

                    if (dt2.Rows.Count > 1)
                    {
                        List <string> listOrderGuid = new List <string>();
                        foreach (DataRow dr in dt2.Rows)
                        {
                            string strOrderGuid = Convert.ToString(dr["OrderGuid"]);
                            if (listOrderGuid.Count == 0)
                            {
                                listOrderGuid.Add(strOrderGuid);
                                continue;
                            }
                            if (!listOrderGuid.Contains(strOrderGuid))
                            {
                                bSameOrder = false;
                                break;
                            }
                        }
                    }


                    if (!bSameOrder)
                    {
                        return(3);
                    }

                    if (!bExistImage)
                    {
                        return(4);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "ReportOpenPolicyDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(0);
        }
Exemple #22
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in DisqualifyImageDAO!"));
                }

                string rpGuids = "", reportGuid = "", curUserGuid = "", reason = "";
                string strDomain = CommonGlobalSettings.Utilities.GetCurDomain();
                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "USERID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "REASON")
                    {
                        reason = inMap[key] as string;
                    }
                }

                if ((reportGuid == null || reportGuid.Length < 1) &&
                    (rpGuids == null || rpGuids.Length < 1))
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (curUserGuid == null || curUserGuid.Length < 1)
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (reportGuid == null)
                {
                    reportGuid = "";
                }

                reportGuid = reportGuid.Trim(" ,".ToCharArray());

                if (rpGuids == null)
                {
                    rpGuids = "";
                }

                rpGuids = rpGuids.Trim(" ,".ToCharArray());

                reason = reason == null ? "" : reason.Length >= 512 ? reason.Substring(0, 512) : reason;

                string sql = " begin tran \r\n";

                using (RisDAL dal = new RisDAL())
                {
                    if (reportGuid != null && reportGuid.Length > 0)
                    {
                        string sqlGetRPs = "select procedureGuid from tRegProcedure where ReportGuid='" + reportGuid + "'";

                        DataTable dtTmp = dal.ExecuteQuery(sqlGetRPs);
                        if (dtTmp != null)
                        {
                            foreach (DataRow dr in dtTmp.Rows)
                            {
                                string tmpRP = System.Convert.ToString(dr[0]);
                                if (string.IsNullOrEmpty(tmpRP))
                                {
                                    continue;
                                }

                                sql += " if exists(select 1 from tReShot where procedureGuid ='" + tmpRP + "') \r\n"
                                       + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "',"
                                       + " rejectDt = getdate(),domain='" + strDomain + "' "
                                       + " where procedureGuid = '" + tmpRP + "' \r\n"
                                       + " else "
                                       + " insert tReShot(ProcedureGuid, reason, rejectDoctor, rejectDt, domain) "
                                       + " values ('" + tmpRP + "', '" + reason + "', '" + curUserGuid + "', getdate(), '" + strDomain + "') \r\n"
                                ;
                            }
                        }

                        //sql += " delete from tReShot where procedureGuid in (select procedureGuid from tRegProcedure where ReportGuid='" + reportGuid + "') \r\n"
                        //    + " insert tReShot(ProcedureGuid) select procedureGuid from tRegProcedure "
                        //    + " where reportGuid = '" + reportGuid + "' \r\n"
                        //    + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = getdate(),domain='" + strDomain + "' "
                        //    + " where (rejectDoctor is null or rejectDoctor = '')"
                        //    + " and procedureGuid in (select procedureGuid from tRegProcedure"
                        //    + "  where reportGuid = '" + reportGuid + "') \r\n";

                        sql += ""
                               + " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString() + ",reportguid=null where  "
                               + "  reportGuid = '" + reportGuid + "' \r\n"
                               + " delete from tReportlist where reportGuid = '" + reportGuid + "' \r\n"
                               + " delete from tReport where reportGuid = '" + reportGuid + "' \r\n";
                    }
                    else if (rpGuids != null && rpGuids.Length > 0)
                    {
                        string[] arrRPs = rpGuids.Split(",;".ToCharArray());

                        foreach (string tmpRP in arrRPs)
                        {
                            if (string.IsNullOrEmpty(tmpRP))
                            {
                                continue;
                            }

                            sql += " if exists(select 1 from tReShot where procedureGuid ='" + tmpRP + "') \r\n"
                                   + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "',"
                                   + " rejectDt = getdate(),domain='" + strDomain + "' "
                                   + " where procedureGuid = '" + tmpRP + "' \r\n"
                                   + " else "
                                   + " insert tReShot(ProcedureGuid, reason, rejectDoctor, rejectDt, domain) "
                                   + " values ('" + tmpRP + "', '" + reason + "', '" + curUserGuid + "', getdate(), '" + strDomain + "') \r\n"
                            ;
                        }

                        if (!rpGuids.Contains("'"))
                        {
                            rpGuids = rpGuids.Replace(",", "','");
                            rpGuids = rpGuids.Replace(";", "','");
                            rpGuids = "'" + rpGuids + "'";
                        }

                        //sql += " delete from tReShot where procedureGuid in (" + rpGuids + ") \r\n"
                        //+ " insert tReShot(ProcedureGuid) select procedureGuid from tRegProcedure"
                        //+ " where procedureGuid in (" + rpGuids + ") \r\n"
                        //+ " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = getdate(),domain='" + strDomain + "' "
                        //+ " where (rejectDoctor is null or rejectDoctor = '') and procedureGuid in (" + rpGuids + ") \r\n";

                        sql += " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString()
                               + " where procedureGuid in (" + rpGuids + ") \r\n";
                    }

                    sql += " commit";

                    ServerPubFun.RISLog_Info(0, "DisqualifyImageDAO_MSSQL, SQL=" + sql,
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                    // Delete
                    tagReportInfo rptInfo = ServerPubFun.GetReportInfo2(rpGuids); //ServerPubFun.GetReportInfo(reportGuid);

                    ServerPubFun.OnReportDelete(rptInfo, ReportCommon.RP_Status.Repeatshot);



                    dal.ExecuteNonQuery(sql);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "DisqualifyImageDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("-1");
        }
Exemple #23
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetLockDAO!"));
                }

                string userGuid              = "";
                string reportGuid            = "";
                string SignActions           = "";
                string certsn                = "";
                bool   IsGetDigitalSignImage = false;

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "USERGUID")
                    {
                        userGuid = paramMap[key] as string;

                        if (userGuid == null)
                        {
                            userGuid = "";
                        }
                    }
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }

                    if (key.ToUpper() == "ISGETDIGITALSIGNIMAGE")
                    {
                        IsGetDigitalSignImage = Convert.ToBoolean(paramMap[key]);
                    }

                    if (key.ToUpper() == "SIGNACTIONS")
                    {
                        SignActions = Convert.ToString(paramMap[key]);
                    }
                }



                DataSet ds = new DataSet();

                //dal.BeginTransaction();

                try
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        if (reportGuid.Trim().Length > 0)
                        {
                            string    strSQL = string.Format("SELECT Creater,Submitter,FirstApprover,SecondApprover FROM tReport WHERE REPORTGUID = '{0}'", reportGuid);
                            DataTable dt     = dal.ExecuteQuery(strSQL);


                            if (dt == null || dt.Rows.Count == 0)
                            {
                                return(null);
                            }

                            string strCreater = "", strFirstApprover = "", strSubmitter = "", strSecondApprover = "";
                            if (dt.Rows[0]["Creater"] != null)
                            {
                                strCreater = Convert.ToString(dt.Rows[0]["Creater"]);
                            }

                            if (dt.Rows[0]["FirstApprover"] != null)
                            {
                                strFirstApprover = Convert.ToString(dt.Rows[0]["FirstApprover"]);
                            }

                            if (dt.Rows[0]["Submitter"] != null)
                            {
                                strSubmitter = Convert.ToString(dt.Rows[0]["Submitter"]);
                            }

                            if (dt.Rows[0]["SecondApprover"] != null)
                            {
                                strSecondApprover = Convert.ToString(dt.Rows[0]["SecondApprover"]);
                            }

                            if (!IsGetDigitalSignImage)
                            {
                                if (strCreater.Length > 0)
                                {
                                    strSQL = string.Format("SELECT SignImage FROM tUser WHERE userguid = '{0}'", strCreater);
                                    DataTable dtCreater = dal.ExecuteQuery(strSQL);
                                    dtCreater.TableName = "CreaterSignImage";
                                    ds.Tables.Add(dtCreater);
                                }

                                if (strFirstApprover.Length > 0)
                                {
                                    strSQL = string.Format("SELECT SignImage FROM tUser WHERE userguid = '{0}'", strFirstApprover);
                                    DataTable dtFirstApprover = dal.ExecuteQuery(strSQL);
                                    dtFirstApprover.TableName = "FirstApproverSignImage";
                                    ds.Tables.Add(dtFirstApprover);
                                }

                                if (strSubmitter.Length > 0)
                                {
                                    strSQL = string.Format("SELECT SignImage FROM tUser WHERE userguid = '{0}'", strSubmitter);
                                    DataTable dtSubmitter = dal.ExecuteQuery(strSQL);
                                    dtSubmitter.TableName = "SubmitterSignImage";
                                    ds.Tables.Add(dtSubmitter);
                                }

                                if (strSecondApprover.Length > 0)
                                {
                                    strSQL = string.Format("SELECT SignImage FROM tUser WHERE userguid = '{0}'", strSecondApprover);
                                    DataTable dtSecondApprover = dal.ExecuteQuery(strSQL);
                                    dtSecondApprover.TableName = "SecondApproverSignImage";
                                    ds.Tables.Add(dtSecondApprover);
                                }
                            }
                            else
                            {
                                #region CA sign pic
                                string[] signActionsArr = SignActions.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                                if (signActionsArr.Length > 0)
                                {
                                    bool isSubmitAction, isApproveAction, isSecondApproveAction;
                                    isSubmitAction = isApproveAction = isSecondApproveAction = false;
                                    foreach (string act in signActionsArr)
                                    {
                                        if (act.Equals("submitreport", StringComparison.OrdinalIgnoreCase))
                                        {
                                            isSubmitAction = true;
                                        }
                                        else if (act.Equals("approvereport", StringComparison.OrdinalIgnoreCase))
                                        {
                                            isApproveAction = true;
                                        }
                                        else if (act.Equals("secondapprovereport", StringComparison.OrdinalIgnoreCase))
                                        {
                                            isSecondApproveAction = true;
                                        }
                                    }
                                    if (isSubmitAction)
                                    {
                                        strSQL = string.Format("SELECT signpic FROM tUserCerts WHERE certsn = (select top 1 certsn  from tsignedhistory where reportguid ='{0}' and action='submitreport' order by createdt desc)", reportGuid);
                                        dal.ExecuteQuery(strSQL, ds, "SubmitterSignImage");
                                    }

                                    if (isApproveAction)
                                    {
                                        strSQL = string.Format("SELECT signpic FROM tUserCerts WHERE certsn = (select top 1 certsn  from tsignedhistory where reportguid ='{0}' and action='ApproveReport' order by createdt desc)", reportGuid);
                                        dal.ExecuteQuery(strSQL, ds, "FirstApproverSignImage");
                                    }

                                    if (isSecondApproveAction)
                                    {
                                        strSQL = string.Format("SELECT signpic FROM tUserCerts WHERE certsn = (select top 1 certsn  from tsignedhistory where reportguid ='{0}' and action='SecondApproveReport' order by createdt desc)", reportGuid);
                                        dal.ExecuteQuery(strSQL, ds, "SecondApproverSignImage");
                                    }
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            string strSQL = string.Format("SELECT SignImage FROM tUser WHERE userguid = '{0}'", userGuid);

                            dal.ExecuteQuery(strSQL, ds, "SignImage");
                        }
                    }
                }
                catch (Exception ex)
                {
                    //dal.RollbackTransaction();

                    System.Diagnostics.Debug.Assert(false, ex.Message);

                    throw (ex);
                }

                //dal.CommitTransaction();



                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #24
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public object Execute(object param)
        {
            int    iRet = 0;
            string sql  = "";

            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    ServerPubFun.RISLog_Info(0, "No parameter in GeExamNumberDAODAO!", "", 0);
                }

                string patientid = "";
                string orderguid = "";
                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "PATIENTID")
                    {
                        patientid = paramMap[key] as string;
                    }
                    if (key.ToUpper() == "ORDERGUID")
                    {
                        orderguid = paramMap[key] as string;
                    }
                }
                patientid = patientid == null ? "" : patientid;
                orderguid = orderguid == null ? "" : orderguid;
                #endregion


                #region Execute Query
                using (RisDAL dal = new RisDAL())
                {
                    DataTable dt = new DataTable();
                    string    sp = @"SP_GetPatientExamNo";
                    dal.Parameters.AddVarChar("@PatientID", patientid, patientid.Length * 2);
                    dal.Parameters.AddVarChar("@OrderGuid", orderguid, orderguid.Length * 2);
                    object obj = dal.ExecuteScalarSP(sp);
                    if (obj != null || obj != DBNull.Value)
                    {
                        return(Convert.ToInt32(obj));
                    }
                }


                #endregion
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GeExamNumberDAO_MSSQL, MSG=" + ex.Message + ", SQL=" + sql,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                return(1);//default is 1
            }

            return(1);//default is 1
        }
Exemple #25
0
        /// <summary>
        /// Get Report Info by rp guid
        /// </summary>
        /// <param name="rpGuid"></param>
        /// <returns></returns>
        public static tagReportInfo GetReportInfo2(string rpGuid)
        {
            int    idx = rpGuid.IndexOf(',');
            string rp  = rpGuid;

            if (idx > 0 && idx < rpGuid.Length)
            {
                rp = rpGuid.Substring(0, idx);
            }
            rp = rp.Trim("' ".ToCharArray());


            string sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                         " select "
                         + "  tRegPatient.patientID, tRegPatient.localName, tRegPatient.EnglishName, tRegPatient.address, tRegPatient.telephone,"
                         + "  tRegPatient.isVip, tRegPatient.Comments tRegPatient__Comments, tRegPatient.remotePID tRegPatient__remotePID,"
                         + "  tRegPatient.Gender as tRegPatient__Gender, tRegPatient.Birthday as tRegPatient__Birthday,"
                         + "  tRegOrder.inhospitalNo, tRegOrder.clinicNo, tRegOrder.PatientType, tRegOrder.Observation, "
                         + "  tRegOrder.inHospitalRegion, tRegOrder.BedNo, tRegOrder.comments tRegOrder__orderComment,"
                         + "  tRegOrder.OrderGuid as tRegOrder__OrderGuid, tRegOrder.AccNo, tRegOrder.applyDept as tRegOrder__applyDept,"
                         + "  tRegOrder.applyDoctor as tRegOrder__applyDoctor, tRegOrder.VisitComment tRegOrder__VisitComment,"
                         + "  tRegOrder.remoteAccNo,"
                         + "  tRegProcedure.ProcedureGuid as tRegProcedure__ProcedureGuid, tRegProcedure.status as tRegProcedure__status, "
                         + "  tRegProcedure.charge, tRegProcedure.ModalityType, tRegProcedure.Modality, "
                         + "  tRegProcedure.Registrar, tRegProcedure.RegisterDt, tRegProcedure.Technician, "
                         + "  tRegProcedure.OperationStep, tRegProcedure.ExamineDt, tRegProcedure.comments tRegProcedure__comments, "
                         + "  tRegProcedure.isCharge, tRegProcedure.ProcedureCode tRegProcedure__ProcedureCode, "
                         + "  tRegProcedure.RPDesc tProcedureCode__Description, tRegProcedure.bodypart tProcedureCode__bodypart, "
                         + "  tReport.reportGuid, "
                         + "  tReport.ReportName, tReport.techInfo, tReport.wysText, tReport.wygText, "
                         + "  tReport.WYS, tReport.WYG, "
                         + "  tReport.creater as tReport__creater, tReport.createDt as tReport__createDt,"
                         + "  tReport.submitter as tReport__submitter, tReport.submitDt as tReport__submitDt,"
                         + "  tReport.firstApprover as tReport__firstApprover, tReport.firstApproveDt as tReport__firstApproveDt,"
                         + "  tReport.rejectDt as tReport__rejectDt"
                         + "  from tRegPatient with (nolock), "
                         + "  tRegOrder with (nolock), tRegProcedure with (nolock) "
                         + "  left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid "
                         + "  where tRegPatient.PatientGuid = tRegOrder.PatientGuid "
                         + "  and tRegOrder.OrderGuid = tRegProcedure.OrderGuid "
                         + " and tRegProcedure.procedureGuid = '" + rp + "'";

            DataTable dt = new DataTable("ReportInfo");



            tagReportInfo ri = new tagReportInfo();

            if (0 == iWrittenCount++ % 100)
            {
                ServerPubFun.RISLog_Info(0, "GetReportInfo2, SQL=" + sql,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }
            else
            {
                ServerPubFun.RISLog_Info(0, "GetReportInfo2, rpGuid=" + rpGuid,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }
            using (RisDAL dal = new RisDAL())
            {
                dal.ExecuteQuery(sql, dt);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];

                    ri.status           = ReportCommon.Converter.toInt(dr["tRegProcedure__status"]);
                    ri.dept             = dr["tRegOrder__applyDept"] as string;
                    ri.orderGuid        = dr["tRegOrder__OrderGuid"] as string;
                    ri.reportGuid       = dr["reportGuid"] as string;
                    ri.reportName       = dr["reportName"] as string;
                    ri.AccNO            = dr["AccNO"] as string;
                    ri.patientID        = dr["PatientID"] as string;
                    ri.patientName      = dr["EnglishName"] as string;
                    ri.patientLocalName = dr["LocalName"] as string;
                    // ri.patientAlias = dr["Alias"] as string;
                    ri.patientAddress = dr["Address"] as string;
                    ri.patientPhone   = dr["TelePhone"] as string;
                    // ri.patientMarriage = dr["Marriage"] as string;
                    ri.gender           = dr["tRegPatient__Gender"] as string;
                    ri.patientType      = dr["PatientType"] as string;
                    ri.remotePID        = dr["tRegPatient__remotePID"] as string;
                    ri.modality         = dr["Modality"] as string;
                    ri.modalityType     = dr["modalityType"] as string;
                    ri.operationStep    = dr["operationStep"] as string;
                    ri.reportCreater    = dr["tReport__creater"] as string;
                    ri.reportSubmitter  = dr["tReport__submitter"] as string;
                    ri.reportApprover   = dr["tReport__firstApprover"] as string;
                    ri.reportCreateDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__createDt"]);
                    ri.reportSubmitDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__submitDt"]);
                    ri.reportApproveDt  = ReportCommon.ReportCommon.GetDateTime(dr["tReport__firstApproveDt"]);
                    ri.reportRejectDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__rejectDt"]);
                    ri.birthday         = ReportCommon.ReportCommon.GetDateTime(dr["tRegPatient__birthday"]);
                    ri.registerDt       = ReportCommon.ReportCommon.GetDateTime(dr["registerDt"]);
                    ri.examineDt        = ReportCommon.ReportCommon.GetDateTime(dr["examineDt"]);
                    ri.inHospitalRegion = dr["inHospitalRegion"] as string;
                    ri.visitNo          = dr["clinicNo"] as string;
                    ri.bedNo            = dr["bedNo"] as string;
                    ri.isVIP            = ReportCommon.Converter.toInt(dr["isVip"]).ToString();
                    ri.inHospitalNo     = dr["inhospitalNo"] as string;
                    ri.patientComment   = dr["tRegPatient__Comments"] as string;
                    ri.remoteAccNo      = dr["remoteAccNo"] as string;

                    ri.applyDoctor       = dr["tRegOrder__applyDoctor"] as string;
                    ri.visitComments     = dr["tRegOrder__visitComment"] as string;
                    ri.observation       = dr["Observation"] as string;
                    ri.orderComments     = dr["tRegOrder__orderComment"] as string;
                    ri.technician        = dr["technician"] as string;
                    ri.procedureComments = dr["remoteAccNo"] as string;
                    ri.isCharge          = ReportCommon.Converter.toInt(dr["isCharge"]).ToString();

                    string tmp     = "";
                    double dChange = 0;
                    foreach (DataRow tmpDr in dt.Rows)
                    {
                        tmp = tmpDr["tProcedureCode__bodypart"] as string;
                        if (tmp != null)
                        {
                            ri.bodypart += tmp + ", ";
                        }

                        tmp = tmpDr["tRegProcedure__ProcedureCode"] as string;
                        if (tmp != null)
                        {
                            ri.procedureCode += tmp + ", ";
                        }

                        tmp = tmpDr["tProcedureCode__Description"] as string;
                        if (tmp != null)
                        {
                            ri.procedureDesc += tmp + ", ";
                        }

                        double dTmp = System.Convert.ToDouble(tmpDr["charge"]);
                        dChange += dTmp;
                    }
                    ri.bodypart      = ri.bodypart.Trim(", ".ToCharArray());
                    ri.procedureCode = ri.procedureCode.Trim(", ".ToCharArray());
                    ri.procedureDesc = ri.procedureDesc.Trim(", ".ToCharArray());
                    ri.charge        = dChange.ToString();

                    ri.reportCreater_LocalName   = ServerPubFun.GetLocalName(ri.reportCreater);
                    ri.reportSubmitter_LocalName = ServerPubFun.GetLocalName(ri.reportSubmitter);
                    ri.reportApprover_LocalName  = ServerPubFun.GetLocalName(ri.reportApprover);
                    ri.technician__LocalName     = ServerPubFun.GetLocalName(ri.technician);

                    ri.duration = System.Convert.ToString(ri.examineDt - ri.registerDt);

                    Byte[] buff = dr["wys"] as Byte[];
                    if (buff == null)
                    {
                        ri.wys = "";
                    }
                    else
                    {
                        ri.wys = ReportCommon.Converter.GetStringFromBytes(buff);
                    }

                    buff = dr["wyg"] as Byte[];
                    if (buff == null)
                    {
                        ri.wyg = "";
                    }
                    else
                    {
                        ri.wyg = ReportCommon.Converter.GetStringFromBytes(buff);
                    }

                    //buff = dr["wysText"] as Byte[];
                    //if (buff == null)
                    ri.wysText = dr["wysText"] as string;
                    //else
                    //  ri.wysText = ReportCommon.Converter.GetStringFromBytes(buff);

                    // buff = dr["wygText"] as Byte[];
                    //if (buff == null)
                    ri.wygText = dr["wygText"] as string;
                    //else
                    //  ri.wygText = ReportCommon.Converter.GetStringFromBytes(buff);

                    ri.techinfo = System.Convert.ToString(dr["techinfo"]);
                }
            }

            return(ri);
        }
Exemple #26
0
        private int getUnWrittenUnApprovedReportCount(string userGuid, string reportGuid)
        {
            int unWrittenUnApprovedReportCount = 0;

            try
            {
                using (RisDAL dal = new RisDAL())
                {
                    DataTable dtUnwrittenReportNoLock = new DataTable();
                    DataTable dtLockedRp                 = new DataTable();
                    DataTable dtLockedReportGuids        = new DataTable();
                    string    lockedSyncRpGuids          = "";
                    string    lockedRpGuids              = "";
                    string    lockedReportGuids          = "";
                    string    sqlCreatedAndCreaterIsSelf = "select count(1) from treport where reportguid = '{0}' and creater ='{1}' and status = 100";
                    string    sqlUnwrittenReportNoLock   = @"select ReportGuid,Status from treport where status =100 and (creater ='{0}' or (creater <> '{0}' and ReportGuid in('{1}')))";
                    string    sqlLockedRp                = string.Format("select rpguids from tsync where owner ='{0}' and moduleid='0400'", userGuid);
                    string    sqlLockedReportGuids       = "select distinct reportguid from tRegProcedure where (status =100 or status =105 or status =120)  and ProcedureGuid in ('{0}')";

                    if (!string.IsNullOrEmpty(reportGuid))
                    {
                        int result = Convert.ToInt32(dal.ExecuteScalar(string.Format(sqlCreatedAndCreaterIsSelf, reportGuid, userGuid)));
                        if (result == 1)
                        {
                            return(0);   //no limitation to open self 100 status and creater is self
                        }
                    }

                    dal.ExecuteQuery(sqlLockedRp, dtLockedRp);
                    foreach (DataRow dr in dtLockedRp.Rows)
                    {
                        lockedSyncRpGuids = Convert.ToString(dr["RPGuids"]);
                        if (lockedSyncRpGuids.Length > 0)
                        {
                            lockedRpGuids += lockedSyncRpGuids.Split("&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0] + ",";
                        }
                    }

                    if (lockedRpGuids.Length > 0)
                    {
                        lockedRpGuids = lockedRpGuids.TrimEnd(",".ToCharArray());
                        lockedRpGuids = lockedRpGuids.Replace(",", "','");
                    }

                    if (lockedRpGuids.Length > 0)
                    {
                        dal.ExecuteQuery(string.Format(sqlLockedReportGuids, lockedRpGuids), dtLockedReportGuids);
                        foreach (DataRow dr in dtLockedReportGuids.Rows)
                        {
                            lockedReportGuids += Convert.ToString(dr["ReportGuid"]) + ",";
                        }

                        if (lockedReportGuids.Length > 0)
                        {
                            lockedReportGuids = lockedReportGuids.TrimEnd(",".ToCharArray());
                            lockedReportGuids = lockedReportGuids.Replace(",", "','");
                        }
                    }
                    dal.ExecuteQuery(string.Format(sqlUnwrittenReportNoLock, userGuid, lockedReportGuids), dtUnwrittenReportNoLock);
                    //unwritten(created by self) and not locked + locked all reports - locked(status = 100,105,120)
                    unWrittenUnApprovedReportCount = dtUnwrittenReportNoLock.Rows.Count + dtLockedRp.Rows.Count - dtLockedReportGuids.Rows.Count;
                }
                return(unWrittenUnApprovedReportCount);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                return(unWrittenUnApprovedReportCount);
            }
        }
Exemple #27
0
        /// <summary>
        /// Get Width of table column
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static int GetColumnWidth(string tableName, string fieldName)
        {
            if (tableName == null || (tableName = tableName.Trim()).Length < 1 ||
                fieldName == null || (fieldName = fieldName.Trim()).Length < 1)
            {
                return(0);
            }

            if (_mapFieldWidth == null)
            {
                _mapFieldWidth = new Dictionary <string, int>();
            }

            if (_mapFieldWidth == null)
            {
                System.Diagnostics.Debug.Assert(false);
                return(0);
            }

            string key = tableName.ToUpper().Trim() + "," + fieldName.ToUpper().Trim();

            if (_mapFieldWidth.ContainsKey(key))
            {
                return(_mapFieldWidth[key]);
            }


            DataTable dt = new DataTable();

            try
            {
                using (RisDAL oKodak = new RisDAL())
                {
                    string sql = "select syscolumns.length as collength from sysobjects, syscolumns"
                                 + " where syscolumns.id=sysobjects.id and sysobjects.xtype='U'"
                                 + " and sysobjects.name='" + tableName + "' and syscolumns.name='" + fieldName + "'";

                    if (oKodak.DriverClassName.ToUpper() == "ORACLE")
                    {
                        sql = "select data_length as collength from user_tab_cols"
                              + " where table_name = '" + tableName.ToUpper() + "' and column_name = '" + fieldName.ToUpper() + "'";
                    }

                    dt = oKodak.ExecuteQuery(sql);

                    if (dt != null && dt.Rows.Count > 0 && dt.Columns.Count > 0)
                    {
                        _mapFieldWidth.Add(key, System.Convert.ToInt32(dt.Rows[0][0]));

                        return(_mapFieldWidth[key]);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false);

                RISLog_Error(0, "GetColumnWidth, MSG=" + ex.Message,
                             (new System.Diagnostics.StackFrame(true)).GetFileName(),
                             (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
            }
            finally
            {
                if (dt != null)
                {
                    dt.Dispose();
                }
            }

            return(0);
        }
Exemple #28
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetReportHistoryDAO!"));
                }

                string patientID = "", reportGuid = "", strType = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "PATIENTGUID" || key.ToUpper() == "PATIENTID")
                    {
                        patientID = paramMap[key] as string;

                        if (patientID == null)
                        {
                            patientID = "";
                        }
                    }
                    else if (key.ToUpper() == "REPORTGUID" || key.ToUpper() == "REPORTID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "TYPE")
                    {
                        strType = paramMap[key] as string;

                        if (strType == null)
                        {
                            strType = "";
                        }
                    }
                }

                string sql = "select distinct tRegPatient.PatientID, tRegPatient.LocalName, tRegOrder.AccNO,"
                             + " tRegOrder.createDt, tReport.reportName, tReportPrintLog.*,tPrintTemplate.TemplateName"
                             + " from tRegPatient, tRegOrder, tRegProcedure, "
                             + " tReport, tReportPrintLog"
                             + " left join tPrintTemplate"
                             + " on tReportPrintLog.PrintTemplateGuid = tPrintTemplate.TemplateGuid"
                             + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                             + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                             + " and tRegProcedure.reportGuid = tReport.reportGuid"
                             + " and tReport.reportGuid = tReportPrintLog.reportGuid";

                if (patientID != null && patientID.Length > 0)
                {
                    sql += " and tRegPatient.PatientID='" + patientID + "'";
                }

                if (reportGuid != null && reportGuid.Length > 0)
                {
                    sql += " and tReport.reportGuid='" + reportGuid + "'";
                }

                if (strType != null && strType.Length > 0)
                {
                    sql += " and tReportPrintLog.Type='" + strType + "'";
                }


                sql += " order by tRegOrder.createDt desc, tReportPrintLog.PrintDt desc";



                DataSet ds = new DataSet();
                using (RisDAL dal = new RisDAL())
                {
                    dal.ExecuteQuery(sql, ds, "ReportPrintLog");

                    Dictionary <string, object> outMap = new Dictionary <string, object>();

                    outMap.Add("DataSet", ds);
                    return(outMap);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportPrintLogDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Exemple #29
0
        public override int IsOnLine(string szUserGuid, string szRoleName, string szIpAddress, string szUrl, string szSessionID, bool IsLogined, bool IsWebAccess, bool IsHijackLogin, bool IsSelfService)
        {
            string Cmd = "";

            int    rt        = 0;
            RisDAL oKodakDAL = new RisDAL();

            try
            {
                if (IsWebAccess == false)
                {
                    oKodakDAL.Parameters.Clear();
                    oKodakDAL.Parameters.AddChar("UserID", szUserGuid);
                    oKodakDAL.Parameters.AddChar("UserRoleName", szRoleName);
                    oKodakDAL.Parameters.AddChar("Url", szUrl);
                    oKodakDAL.Parameters.AddChar("IpAddress", szIpAddress);
                    oKodakDAL.Parameters.AddChar("Session", szSessionID);
                    oKodakDAL.Parameters.AddInt("IsLogined", IsLogined == true ? 1 : 0);
                    oKodakDAL.Parameters.Add("ReturnValue", DbType.Int32);
                    oKodakDAL.Parameters["UserID"].Direction       = ParameterDirection.Input;
                    oKodakDAL.Parameters["UserRoleName"].Direction = ParameterDirection.Input;
                    oKodakDAL.Parameters["Url"].Direction          = ParameterDirection.Input;
                    oKodakDAL.Parameters["IpAddress"].Direction    = ParameterDirection.Input;
                    oKodakDAL.Parameters["Session"].Direction      = ParameterDirection.Input;
                    oKodakDAL.Parameters["IsLogined"].Direction    = ParameterDirection.Input;
                    oKodakDAL.Parameters["ReturnValue"].Direction  = ParameterDirection.Output;
                    oKodakDAL.ExecuteNonQuerySP("checkonline");
                    rt = Convert.ToInt32(oKodakDAL.Parameters["ReturnValue"].Value);
                    //rt = Convert.ToInt32(oKodakDAL.ExecuteScalarSP("checkonline"));
                }
                else
                {
                    oKodakDAL.Parameters.Clear();
                    oKodakDAL.Parameters.AddChar("UserID", szUserGuid);
                    oKodakDAL.Parameters.AddChar("UserRoleName", szRoleName);
                    oKodakDAL.Parameters.AddChar("Url", szUrl);
                    oKodakDAL.Parameters.AddChar("IpAddress", szIpAddress);
                    oKodakDAL.Parameters.AddChar("Session", szSessionID);
                    oKodakDAL.Parameters.Add("ReturnValue", DbType.Int32);
                    oKodakDAL.Parameters["UserID"].Direction       = ParameterDirection.Input;
                    oKodakDAL.Parameters["UserRoleName"].Direction = ParameterDirection.Input;
                    oKodakDAL.Parameters["Url"].Direction          = ParameterDirection.Input;
                    oKodakDAL.Parameters["IpAddress"].Direction    = ParameterDirection.Input;
                    oKodakDAL.Parameters["Session"].Direction      = ParameterDirection.Input;
                    oKodakDAL.Parameters["ReturnValue"].Direction  = ParameterDirection.Output;
                    oKodakDAL.ExecuteNonQuerySP("CHECKWEBONLINE");
                    rt = Convert.ToInt32(oKodakDAL.Parameters["ReturnValue"].Value);
                }
            }
            catch (Exception Ex)
            {
                logger.Error((long)ModuleEnum.Framework_Client, ModuleInstanceName.Framework, 1, Ex.Message,
                             string.Empty, (new System.Diagnostics.StackFrame(true)).GetFileName(),
                             (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
            }
            finally
            {
                if (oKodakDAL != null)
                {
                    oKodakDAL.Dispose();
                }
            }
            return(rt);
        }
Exemple #30
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetDrawerSignDAO!"));
                }



                DataSet ds = new DataSet();

                try
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        string   strReportGuids = paramMap["ReportGuid"] as string;
                        string[] arrItem        = strReportGuids.Split('|');

                        DataTable dtDrawSign = null;
                        strReportGuids = "";
                        foreach (string str in arrItem)
                        {
                            string strSQL = string.Format("select ReportGuid,IsDraw,DrawerSign,TakeFilmDept,"
                                                          + " TakeFilmRegion,TakeFilmComment "
                                                          //+ " ReportTextApprovedSign, ReportTextSubmittedSign,"
                                                          //+ " CombinedForCertification, SignCombinedForCertification "
                                                          + " from tReport where ReportGuid ='{0}'", str);
                            DataTable dt = dal.ExecuteQuery(strSQL);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                if (dtDrawSign == null)
                                {
                                    dtDrawSign = dt.Clone();
                                }
                                dtDrawSign.Rows.Add(dt.Rows[0].ItemArray);
                            }
                        }
                        ds.Tables.Add(dtDrawSign);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Assert(false, ex.Message);

                    ServerPubFun.RISLog_Error(0, "GetDrawerSignDAO=" + ex.Message,
                                              (new System.Diagnostics.StackFrame()).GetFileName(),
                                              (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                    throw (ex);
                }


                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetDrawerSignDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }