Beispiel #1
0
    protected void OnContinueExisting(object sender, CAppUserControlArgs e)
    {
        CPatChecklistDataItem di = new CPatChecklistDataItem();

        di.ProcedureDate    = CDataUtils.GetNullDate();
        di.AssignmentDate   = DateTime.Now;
        di.ChecklistID      = ucExistingChecklist.ChecklistID;
        di.ChecklistStateID = k_CHECKLIST_STATE_ID.Open;
        di.PatientID        = PatientID;
        di.StateID          = k_STATE_ID.Unknown;

        long lPatCLID            = 0;
        CPatChecklistData pcld   = new CPatChecklistData(BaseMstr.BaseData);
        CStatus           status = pcld.InsertPatChecklist(di, out lPatCLID);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (BaseMstr.MDWSTransfer)
        {
            //talk to the communicator to update the
            //patient checklist from mdws
            CCommunicator com = new CCommunicator();
            status = com.RefreshPatientCheckList(
                BaseMstr.DBConn,
                BaseMstr.BaseData,
                PatientID,
                lPatCLID);
            if (!status.Status)
            {
                ShowStatusInfo(status);
                return;
            }
        }

        CPatientChecklist pcl = new CPatientChecklist();

        status = pcl.LoadPatientChecklists(BaseMstr, PatientID, ddlPatChecklist);
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }
        ddlPatChecklist.SelectedValue = lPatCLID.ToString();

        status = LoadChecklist();
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        //set the UI permissions based on the user logged in
        SetPermissions(btnTIU.Enabled);
    }
    /// <summary>
    /// do the actual work of assigning the checklist
    /// </summary>
    /// <param name="state"></param>
    public void DoWork(Object state)
    {
        //thread hashcount work
        lock (HashCount)
        {
            if (!HashCount.ContainsKey(Thread.CurrentThread.GetHashCode()))
            {
                HashCount.Add(Thread.CurrentThread.GetHashCode(), 0);
            }

            HashCount[Thread.CurrentThread.GetHashCode()] = ((int)HashCount[Thread.CurrentThread.GetHashCode()]) + 1;
        }

        //do the real work here
        //////////////////////////////////////////////////////////////

        //create a new connection for the thread
        CDataDBConn conn = new CDataDBConn();

        conn.Connect();
        CData data = new CData(
            conn,
            this.ClientIP,
            this.UserID,
            this.SessionID,
            this.WebSession,
            this.MDWSTransfer);


        CPatChecklistData     pcl          = new CPatChecklistData(data);
        string                strPatientID = PatientID;
        CPatChecklistDataItem di           = new CPatChecklistDataItem();

        di.ProcedureDate    = CDataUtils.GetNullDate();
        di.AssignmentDate   = DateTime.Now;
        di.ChecklistID      = ChecklistID;
        di.ChecklistStateID = k_CHECKLIST_STATE_ID.Open;
        di.PatientID        = strPatientID;
        di.StateID          = k_STATE_ID.Unknown;

        long lPatCLID = 0;

        Status = pcl.InsertPatChecklist(di, out lPatCLID);
        if (Status.Status)
        {
            if (MDWSTransfer)
            {
                //talk to the communicator to update the
                //patient checklist from mdws
                CCommunicator com = new CCommunicator();
                Status = com.RefreshPatientCheckList(
                    conn,
                    data,
                    strPatientID,
                    lPatCLID);
            }

            if (Status.Status)
            {
                CPatientChecklistLogic pcll = new CPatientChecklistLogic(data);
                Status = pcll.RunLogic(lPatCLID);
            }
        }

        //cleanup the database connection
        conn.Close();

        //signals we are done.
        Interlocked.Increment(ref ThreadCount);
        if (ThreadCount == ThreadMax)
        {
            if (eventX != null)
            {
                eventX.Set();
                ThreadCount = 0;
                ThreadMax   = 0;
            }
        }
    }