Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack && Master.SelectedPatientID == "")
        {
            GetPatientID();
        }

        CDataUtils   utils  = new CDataUtils();
        CCPAPResults cpap   = new CCPAPResults(Master);
        CIntake      intake = new CIntake();

        if (!IsPostBack)
        {
            //load questionnaires dropdown
            //cpap.LoadQuestionnaireCombo(cboQuestionnaireScores);

            //get graphic raw data
            htxtTxAdherence.Value    = cpap.GetTxAdherence();
            htxtAHI.Value            = cpap.GetAHI();
            htxtMaskLeak.Value       = cpap.GetMaskLeak();
            htxtQuestionnaires.Value = utils.GetJSONString(intake.GetPatIntakeScoresDS(Master));
        }

        cboSummaryTimeWindow.Attributes.Add("onchange", "patient.summary.timewindow(this);");
        //cboQuestionnaireScores.Attributes.Add("onchange", "patient.summary.renderQuestionnaires(this);");

        ShowSysFeedback();
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack &&
            Request.QueryString[0] != null &&
            Request.QueryString[1] != null)
        {
            EncounterID       = Request.QueryString[0].ToString();
            EncounterIntakeID = Convert.ToInt64(Request.QueryString[1]);

            CIntake rpt = new CIntake();
            DataSet ds  = rpt.GetIntakeReportDS(Master, EncounterID, EncounterIntakeID);
            if (ds != null &&
                ds.Tables.Count > 0 &&
                ds.Tables[0].Rows.Count > 0)
            {
                litReport.Text = ds.Tables[0].Rows[0]["REPORT_TEXT"].ToString();
            }
        }

        //show system feedback popup
        if (Master.StatusCode > 0 && !String.IsNullOrEmpty(Master.StatusComment))
        {
            ScriptManager.RegisterStartupScript(this.Page, typeof(string), "showerror", "parent.window.sysfeedback('" + Master.StatusComment + "')", true);
        }
    }
Esempio n. 3
0
    //------------------------------------------------------------------------------------
    protected bool Score(long lEncIntakeID, long lMID, long nScore, long lScoreType)
    {
        if (lScoreType == -1)
        {
            return true;
        }

        // interpretation
        String strInterpret = null;
        strInterpret = "";

        if (nScore > 11)
        {
            strInterpret = "'significant' or 'mild' depressive symptomatology";
        }

        //write intake score
        long lMapScore = nScore;

        CIntake intake = new CIntake();
        if (intake.InsertEncIntakeScore(Master, Master.SelectedEncounterID, lEncIntakeID, lMID, lScoreType, lMapScore, 0, strInterpret, 1, lGRP) == false)
        {
            return false;
        }

        return true;
    }
Esempio n. 4
0
    //------------------------------------------------------------------------------------
    protected bool Score(long lEncIntakeID, long lMID, long nScore, long lScoreType)
    {
        if (lScoreType == -1)
        {
            return true;
        }

        // interpretation
        String strInterpret = null;
        strInterpret = "";

        if (nScore > 11)
        {
            strInterpret = "excessive daytime sleepiness";
        }

        //write intake score
        long lMapScore = nScore;

        CIntake intake = new CIntake();
        if (intake.InsertEncIntakeScore(Master, Master.SelectedEncounterID, lEncIntakeID, lMID, lScoreType, lMapScore, 0, strInterpret, 1, lGRP) == false)
        {
            return false;
        }

        return true;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CIntake intake = new CIntake();
        CSec    usrsec = new CSec();

        bReadOnly = (usrsec.GetRightMode(Master, (long)SUATUserRight.ProcessNewPatientsUR) < (long)RightMode.ReadWrite);
        if (Master.IsPatientLocked)
        {
            bReadOnly = true;
        }

        ucIntakeModules.BaseMstr  = Master;
        ucIntakeModules.bReadOnly = bReadOnly;

        if (!Master.APPMaster.PatientHasOpenCase)
        {
            Master.StatusCode    = 1;
            Master.StatusComment = "Patient Does Not Have An Open Case! An Open Case Is Required To Assign Assessments.";
            return;
        }

        if (!IsPostBack)
        {
            ucIntakeModules.LoadModuleGroups();
            htxtSelectedModules.Value = ucIntakeModules.GetPatientModules();
        }

        if (Master.OnMasterSAVE())
        {
            string strSelectedModules = ucIntakeModules.GetAssignedModules();
            if (!bReadOnly && !Master.IsPatientLocked)
            {
                if (intake.AssignPatientModules(Master, Master.SelectedPatientID, Master.SelectedProviderID, strSelectedModules))
                {
                    htxtSelectedModules.Value = strSelectedModules;
                    divStatus.InnerHtml       = "<font color=\"green\"><img alt=\"\" src=\"Images/tick.png\">&nbsp;Assigned modules were saved for the patient!</font>";
                    ScriptManager.RegisterClientScriptBlock(upWrapperUpdatePanel, typeof(string), "saved", "clearStatusDiv(4);", true);
                }
            }
            else
            {
                if (bReadOnly)
                {
                    Master.StatusCode    = 1;
                    Master.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> You have <b>Read-Only Access</b> to this section.";
                }
                else if (Master.IsPatientLocked)
                {
                    Master.StatusCode    = 1;
                    Master.StatusComment = "<img alt=\"\" src=\"Images/lock16x16.png\" /> <b>Read-Only Access</b>: The patient's record is in use by " + Session["PAT_LOCK_PROVIDER"].ToString() + ".";
                }
            }
        }

        ShowSysFeedback();
    }
Esempio n. 6
0
    public string GetAssignedModules()
    {
        string strSelModules = String.Empty;
        string strDupCheck   = ",";

        CIntake intake = new CIntake();

        dsMods = intake.GetPatientModulesDS(BaseMstr, BaseMstr.SelectedPatientID);

        foreach (RepeaterItem ri in repGroup.Items)
        {
            Repeater repMod = (Repeater)ri.FindControl("repModules");
            if (repMod != null)
            {
                foreach (RepeaterItem itm in repMod.Items)
                {
                    HtmlInputCheckBox chkbx = (HtmlInputCheckBox)itm.FindControl("chkModule");

                    long   lStatus  = 0;
                    string strMID   = chkbx.Value.Split('|')[0];
                    string strGrpID = chkbx.Value.Split('|')[1];

                    if (dsMods != null)
                    {
                        DataRow[] drs = dsMods.Tables[0].Select("MID = " + strMID + " AND MODULE_GROUP_ID = " + strGrpID);
                        if (drs.Length > 0)
                        {
                            foreach (DataRow dr in drs)
                            {
                                if (!dr.IsNull("STATUS"))
                                {
                                    lStatus = Convert.ToInt32(dr["STATUS"]);
                                }
                            }
                        }
                    }

                    if (chkbx.Checked)
                    {
                        if (strDupCheck.IndexOf("," + chkbx.Value.Substring(0, chkbx.Value.Length - 1) + ",") < 0)
                        {
                            if (lStatus < 1)
                            {
                                strDupCheck   += chkbx.Value.Substring(0, chkbx.Value.Length - 1) + ",";
                                strSelModules += chkbx.Value + "^";
                            }
                        }
                    }
                }
            }
        }
        return(strSelModules);
    }
Esempio n. 7
0
//-------------------------------------------------------------------------------------
//INDEX = AVERAGE OF Q1, Q3, Q6
//BMI	= WEIGHT / HEIGHT * HEIGHT NOTE: HEIGHT and WEIGHT must be in Kg and Meters)
//AGE	= years
//GENDER = 1 for male, 0 for female
//X = 8.16 + (1.299 * INDEX) + (0.163 * BMI) - (0.028 * INDEX * BMI) + (0.032 * AGE) + (1.278 * GENDER)
//
//MAP SCORE  = EXP(x)  / (1 + EXP(x))
//LRMAP = EXP(x - 0.45)
//------------------------------------------------------------------------------------
    protected bool Score(long lEncIntakeID, long lMID, long nScore, long lScoreType)
    {
        if (lScoreType == -1)
        {
            return true;
        }

        CPatient pat = new CPatient();

        long lGender = pat.GetPatientGender(Master);
        double dGender = Convert.ToDouble(lGender);

        long lAge = pat.GetPatientAge(Master);
        double dAge = Convert.ToDouble(lAge);

        double dHeight = pat.GetPatientHeight(Master);
        double dWeight = pat.GetPatientWeight(Master);

        if ((lAge == 0) || (dHeight == 0) || (dWeight == 0))
        {
            return false;
        }

        double nAvgIndex = nScore / 3;
        double dBMI = dWeight / (dHeight * dHeight);

        double dX = -8.16 + (1.299 * nAvgIndex) + (0.163 * dBMI) - (0.028 * nAvgIndex * dBMI) + (0.032 * dAge) + (1.278 * dGender);

        double dMapScore = Math.Exp(dX) / (1 + Math.Exp(dX));


        //write intake score
        //long lMapScore = Convert.ToInt64(dMapScore);

        // interpretation
        String strInterpret = "";
        if (nScore > 11)
        {
            strInterpret = "excessive daytime sleepiness";
        }


        CIntake intake = new CIntake();
        if (intake.InsertEncIntakeScore(Master, Master.SelectedEncounterID, lEncIntakeID, lMID, lScoreType, dMapScore, 0, strInterpret, 1, lGRP) == false)
        {
            return false;
        }

        return true;
    }
Esempio n. 8
0
    protected void OnClickExportCsv(object sender, EventArgs e)
    {
        CIntake rpt = new CIntake();
        DataSet ds  = rpt.GetIntakeReportCSVDS(
            Master,
            EncounterID,
            EncounterIntakeID);

        if (ds == null ||
            ds.Tables.Count < 1)
        {
            return;
        }

        DataTable dt = ds.Tables[0];

        StringBuilder sb = new StringBuilder();

        foreach (DataColumn dc in dt.Columns)
        {
            sb.Append("\"" + dc.ColumnName + "\",");
        }

        sb.Append(Environment.NewLine);

        foreach (DataRow dr in dt.Rows)
        {
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                sb.Append("\"" + dr[i].ToString() + "\",");
            }

            sb.Append(Environment.NewLine);
        }

        HttpResponse r = HttpContext.Current.Response;

        r.Clear();
        r.ClearContent();
        r.ClearHeaders();
        r.Buffer = true;
        r.AddHeader("Content-Disposition", "attachment;filename=PatientAssessment_" + DateTime.Now.ToString("MMddyy") + ".csv");
        r.ContentType = "text/csv";
        r.Charset     = "utf-8";
        r.Write(sb.ToString());
        r.End();
    }
Esempio n. 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CCPAPResults cpap   = new CCPAPResults(Master);
        CDataUtils   utils  = new CDataUtils();
        CIntake      intake = new CIntake();

        if (!IsPostBack)
        {
            rblGraphicsMode.SelectedIndex = (int)Master.GraphicOption;
            rblGraphicsMode_OnSelectedIndexChanged(null, EventArgs.Empty);

            htxtTxAdherence.Value = cpap.GetTxAdherence();
            htxtAHI.Value         = cpap.GetAHI();
            htxtBaselineAHI.Value = cpap.GetBaselineAHI();

            string strLeakType;
            htxtMaskLeak.Value       = cpap.GetMaskLeak(out strLeakType);
            htxtLeakType.Value       = strLeakType;
            htxtQuestionnaires.Value = utils.GetStringValueFromDS(intake.GetScoreDataStringDS(Master, Master.SelectedPatientID), "MID_DATA");

            CPatientEvent evt = new CPatientEvent(Master);
            evt.CheckPAPEvent();
            ClearTxSessionVars();
            loadPatient();

            cpap.LoadQuestionnaireCombo(cboQuestionnaireScores);
        }

        cboSummaryTimeWindow.Attributes.Add("onchange", "patient.summary.timewindow(this);");
        cboSummaryTimeWindow2.Attributes.Add("onchange", "patient.summary.graphs.timewindow(this);");
        cboQuestionnaireScores.Attributes.Add("onchange", "patient.summary.renderQuestionnaires(this);");

        ucPatEvt.BaseMstr = Master;

        //move to events tab if this is an event lookup
        if (!IsPostBack)
        {
            if (Session["EVENT_LOOKUP"] != null)
            {
                if ((bool)Session["EVENT_LOOKUP"])
                {
                    tcPatSummary.ActiveTabIndex = 1;
                    Session["EVENT_LOOKUP"]     = null;
                }
            }
        }
    }
Esempio n. 10
0
    public void LoadModuleGroups()
    {
        CIntake intake = new CIntake();
        DataSet ds     = intake.GetModGroups(BaseMstr);

        dsMods = intake.GetPatientModulesDS(BaseMstr, BaseMstr.SelectedPatientID);

        if (ds != null)
        {
            repGroup.DataSource = ds.Tables["groups"];
        }
        else
        {
            repGroup.DataSource = null;
        }
        Page.DataBind();
    }
Esempio n. 11
0
    protected bool Score(long lEncIntakeID, long lMID)
    {
        CIntake intake   = new CIntake();
        bool    bSuccess = intake.InsertEncIntakeScore(
            Master,
            Master.SelectedEncounterID,
            lEncIntakeID,
            lMID,
            lMID,
            lScore,
            0,
            strInterpretation,
            1,
            lGRP);

        return(bSuccess);
    }
Esempio n. 12
0
    protected bool WriteScores() 
    {
        long lScoreType = 3016;

        nScore = (((nScore1 / 2) + (nScore2 / 3) + (nScore3 / 3) + nScore4 + nScore5) / 5) * 5;

        double[] dScores = new double[6] {
            nScore,
            (nScore1 / 2),
            (nScore2 / 3),
            (nScore3 / 3),
            nScore4,
            nScore5
        };

        string[] strInterpretation = new string[6] { 
            "TOTAL SCORE",
            "GENERAL PRODUCTIVITY",
            "ACTIVITY LEVEL",
            "VIGILANCE",
            "SOCIAL OUTCOME",
            "INTIMACY AND SEXUAL RELATIONSHIPS"
        };


        CIntake intake = new CIntake();
        for (int s = 0; s < dScores.Length; s++)
        {
            bool bSuccess = intake.InsertEncIntakeScore(
                Master,
                Master.SelectedEncounterID,
                lEncIntakeID,
                lMID,
                lScoreType,
                dScores[s],
                0,
                strInterpretation[s],
                s+1,
                lGRP);

            if (!bSuccess)
                return bSuccess;
        }

        return true;
    }
Esempio n. 13
0
    public string GetPatientModules()
    {
        string  strPatientModules = String.Empty;
        CIntake intake            = new CIntake();
        DataSet dsMods            = intake.GetPatientModulesDS(BaseMstr, BaseMstr.SelectedPatientID);

        if (dsMods != null)
        {
            foreach (DataTable dt in dsMods.Tables)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    strPatientModules += dr["MID"].ToString() + "|";
                    strPatientModules += dr["MODULE_GROUP_ID"].ToString() + "|^";
                }
            }
        }
        return(strPatientModules);
    }
Esempio n. 14
0
    //------------------------------------------------------------------------------------
    protected bool Score(long lEncIntakeID, long lMID, long nScore, long lScoreType)
    {
        if (lScoreType == -1)
        {
            return true;
        }

        // interpretation
        String strInterpret = null;

        if (nScore < 8)
        {
            strInterpret = "absence of insomnia";
        }
        else if ((nScore > 7) && (nScore < 15))
        {
            strInterpret = "sub-threshold insomnia";
        }

        else if ((nScore > 14) && (nScore < 22))
        {
            strInterpret = "moderate insomnia";
        }

        else if (nScore > 21)
        {
            strInterpret = "severe insomnia";
        }

        //write intake score
        long lMapScore = nScore;

        CIntake intake = new CIntake();
        if (intake.InsertEncIntakeScore(Master, Master.SelectedEncounterID, lEncIntakeID, lMID, lScoreType, lMapScore, 0, strInterpret, 1, lGRP) == false)
        {
            return false;
        }

        return true;
    }
Esempio n. 15
0
    protected void GetPrevResponses()
    {
        CDataUtils utils  = new CDataUtils();
        CIntake    intake = new CIntake();

        DataSet ds = intake.GetSymptomsFUResponsesDS(Master);

        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                htxtResponses.Value = utils.GetJSONString(ds);
            }
            else
            {
                mvSymptoms.SetActiveView(vwMessage);
            }
        }
        else
        {
            mvSymptoms.SetActiveView(vwMessage);
        }
    }
Esempio n. 16
0
    protected string GetModuleGroupHTML()
    {
        CIntake intake  = new CIntake();
        string  strHTML = String.Empty;

        bool bInsertHeader = false;
        long lModGroup     = -1;

        DataSet dsIntakes = intake.GetPatIntakeAssignedDS(Master);

        if (dsIntakes == null)
        {
            return(String.Empty);
        }
        if (dsIntakes.Tables[0].Rows.Count < 1)
        {
            return("<h4>You don't have questionnaires assigned at this moment!</h4>");
        }

        for (int a = 0; a < dsIntakes.Tables[0].Rows.Count; a++)
        {
            DataRow dr = dsIntakes.Tables[0].Rows[a];

            bool bShowModule = true;
            // This date calculation is now handled directly in the stored procedure

            //if (!dr.IsNull("SCHEDULED_DATE"))
            //{
            //    if (DateTime.Today < Convert.ToDateTime(dr["SCHEDULED_DATE"]).AddDays(-_DAYS_PRIOR))
            //    {
            //        bShowModule = false;
            //    }
            //}


            // ---------

            if (bShowModule)
            {
                if (!dr.IsNull("MODULE_GROUP_ID"))
                {
                    long lMG = Convert.ToInt32(dr["MODULE_GROUP_ID"]);
                    if (lModGroup != lMG)
                    {
                        lModGroup     = lMG;
                        bInsertHeader = true;
                    }
                    else
                    {
                        bInsertHeader = false;
                    }

                    //write header
                    if (bInsertHeader)
                    {
                        strHTML += "<div class=\"module-group\">";
                        if (!dr.IsNull("MODULE_GROUP_DESCR"))
                        {
                            strHTML += String.Format("<h2>{0}</h2>", dr["MODULE_GROUP_DESCR"].ToString());
                        }
                        strHTML += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                    }

                    //write modules list
                    string strTRClass = "class=\"pending\"";
                    long   lStatus    = 0;
                    if (!dr.IsNull("STATUS"))
                    {
                        lStatus    = Convert.ToInt32(dr["STATUS"]);
                        strTRClass = (lStatus != 0) ? String.Empty : "class=\"pending\"";
                    }

                    if (lStatus != 2) //skipped module
                    {
                        strHTML += "<tr id=\"trmid_" + dr["MID"].ToString() + "\" " + strTRClass + ">";
                        strHTML += "<td>";
                        if (lStatus == 1)
                        {
                            strHTML += "<img alt=\"module done\" src=\"Images/tick.png\">";
                        }
                        else
                        {
                            strHTML += "<img alt=\"module not-done\" src=\"Images/error.png\">";
                        }
                        strHTML += "</td>";
                        strHTML += "<td>";
                        if (lStatus == 1)
                        {
                            strHTML += "<span>";
                        }
                        else
                        {
                            strHTML += "<a ";
                            strHTML += "href=\"mid" + dr["MID"].ToString() + ".aspx?grp=" + dr["MODULE_GROUP_ID"].ToString() + "\" >";
                        }
                        strHTML += dr["MODULE"].ToString();
                        if (lStatus == 1)
                        {
                            strHTML += "</span>";
                        }
                        else
                        {
                            strHTML += "</a>";
                        }
                        strHTML += "</td>";
                        strHTML += "</tr>";
                    }

                    //write footer
                    if (a == dsIntakes.Tables[0].Rows.Count - 1)
                    {
                        strHTML += "</table>";
                        strHTML += "</div>";
                    }
                    else
                    {
                        if (a < dsIntakes.Tables[0].Rows.Count - 1)
                        {
                            if (Convert.ToInt32(dsIntakes.Tables[0].Rows[a + 1]["MODULE_GROUP_ID"]) != lModGroup)
                            {
                                strHTML += "</table>";
                                strHTML += "</div>";
                            }
                        }
                    }
                }
            }

            // ---------
        }

        return(strHTML);
    }
Esempio n. 17
0
    //save the first view
    protected bool SaveDemographics()
    {
        Session["PAT_DEMOGRAPHICS_DS"] = null;
        Session["PATIENTNAME"]         = null;

        long lHomePhoneMsg = 0;
        long lEmailMsg     = 0;

        if (rblHomePhoneMsg.SelectedIndex > -1)
        {
            lHomePhoneMsg = Convert.ToInt32(rblHomePhoneMsg.SelectedValue);
        }

        if (rblEmailMessage.SelectedIndex > -1)
        {
            lEmailMsg = Convert.ToInt32(rblEmailMessage.SelectedValue);
        }

        //check data entry for errors
        string strMessage = CheckPatientDemoErrors();

        if (!string.IsNullOrEmpty(strMessage))
        {
            Master.StatusCode    = 1;
            Master.StatusComment = strMessage;
            //ShowSysFeedback();
            return(false);
        }

        ConvertPatientDemographics();

        CPatient pat = new CPatient();

        // if new patient then insert else update
        if (m_bNewPatient)
        {
            m_strNewPatientID   = Master.APPMaster.GetNewPatientID();
            m_strNewEncounterID = Master.APPMaster.GetNewEncounterID();

            //insert the actual record
            bool bStatus = pat.InsertPatientDemographics(
                Master,
                m_strNewPatientID,
                m_strNewEncounterID,
                txtFirstName.Text,
                txtMiddleName.Text,
                txtLastName.Text,
                m_strFMPSSN,
                m_strFMPSSNConfirm,
                m_strGender,
                m_strDOB,
                cboProvider.SelectedValue,
                txtAddress1.Text,
                txtAddress2.Text,
                txtCity.Text,
                txtPostCode.Text,
                txtHomePhone.Text,
                txtCelPhone.Text,
                txtWorkPhone.Text,
                txtPatEmail.Text,
                cboState.SelectedValue,
                Convert.ToInt32(cboCallPreference.SelectedValue),
                lHomePhoneMsg,
                lEmailMsg);

            if (!bStatus)
            {
                //ShowSysFeedback();
                return(false);
            }

            //reset these so the RFR tab will show
            Master.APPMaster.PatientHasOpenCase = true;

            Master.SetVSValue("IsNewPatient", false);
            Master.SetVSValue("ReloadPage", true);

            //set the selected patient id, basically they are
            //"looked up" at this point...
            Master.SelectedPatientID = m_strNewPatientID;

            //Add all patient events
            CPatientEvent evt = new CPatientEvent(Master);
            evt.AddAllEvents();

            //add patient step
            CPatientTxStep patstep = new CPatientTxStep(Master);
            patstep.InsertPatientStep(0);

            //get current (new) treatment id
            CEncounter enc             = new CEncounter();
            long       lNewTreatmentID = 1;
            enc.GetCurrentTreatmentID(Master, m_strNewPatientID, out lNewTreatmentID);
            Master.SelectedTreatmentID = lNewTreatmentID;

            //assign initial questionnaires
            CIntake intake = new CIntake();
            intake.AssignInitialAssessments(Master, m_strNewPatientID);

            if (!SaveEthnicityRaceSource())
            {
                //ShowSysFeedback();
                return(false);
            }

            return(true);
        }
        else
        {
            bool bStatus = pat.UpdatePatientDemographics(
                Master,
                txtFirstName.Text,
                txtMiddleName.Text,
                txtLastName.Text,
                m_strFMPSSN,
                m_strFMPSSNConfirm,
                m_strGender,
                m_strDOB,
                cboProvider.SelectedValue,
                txtAddress1.Text,
                txtAddress2.Text,
                txtCity.Text,
                txtPostCode.Text,
                txtHomePhone.Text,
                txtCelPhone.Text,
                txtWorkPhone.Text,
                txtPatEmail.Text,
                cboState.SelectedValue,
                Convert.ToInt32(cboCallPreference.SelectedValue),
                lHomePhoneMsg,
                lEmailMsg);

            if (!bStatus)
            {
                return(false);
            }

            if (!SaveEthnicityRaceSource())
            {
                return(false);
            }
        }

        return(true);
    }
Esempio n. 18
0
    // scores the assessment based on the responses selected
    // and stores the scores in the database
    protected bool Score(long lEncIntakeID, long lMID, long lScoreType)
    {
        // get selected response values
        double dSF1 = 0.0;
        switch (Convert.ToInt64(Request.Form["grpRadio_1"].Split(cSplitChars)[2]))
        {
            case 1:
                dSF1 = 5;
                break;
            case 2:
                dSF1 = 4.4;
                break;
            case 3:
                dSF1 = 3.4;
                break;
            case 4:
                dSF1 = 2;
                break;
            case 5:
                dSF1 = 1;
                break;
        };
        long lSF2a = Convert.ToInt64(Request.Form["grpRadio_2"].Split(cSplitChars)[2]);
        long lSF2b = Convert.ToInt64(Request.Form["grpRadio_3"].Split(cSplitChars)[2]);
        long lSF3a = Convert.ToInt64(Request.Form["grpRadio_4"].Split(cSplitChars)[2]);
        long lSF3b = Convert.ToInt64(Request.Form["grpRadio_5"].Split(cSplitChars)[2]);
        long lSF4a = Convert.ToInt64(Request.Form["grpRadio_6"].Split(cSplitChars)[2]);
        long lSF4b = Convert.ToInt64(Request.Form["grpRadio_7"].Split(cSplitChars)[2]);
        long lSF5 = 6 - Convert.ToInt64(Request.Form["grpRadio_8"].Split(cSplitChars)[2]);
        long lSF6a = 6 - Convert.ToInt64(Request.Form["grpRadio_9"].Split(cSplitChars)[2]);
        long lSF6b = 6 - Convert.ToInt64(Request.Form["grpRadio_10"].Split(cSplitChars)[2]);
        long lSF6c = Convert.ToInt64(Request.Form["grpRadio_11"].Split(cSplitChars)[2]);
        long lSF7 = Convert.ToInt64(Request.Form["grpRadio_12"].Split(cSplitChars)[2]);

        // create scales
        double dPF = lSF2a + lSF2b;
        double dRP = lSF3a + lSF3b;
        double dBP = lSF5;
        double dGH = dSF1;
        double dVT = lSF6b;
        double dSF = lSF7;
        double dRE = lSF4a + lSF4b;
        double dMH = lSF6a + lSF6c;

        dPF = (dPF - 2) / 4 * 100;
        dRP = (dRP - 2) / 8 * 100;
        dBP = (dBP - 1) / 4 * 100;
        dGH = (dGH - 1) / 4 * 100;
        dVT = (dVT - 1) / 4 * 100;
        dSF = (dSF - 1) / 4 * 100;
        dRE = (dRE - 2) / 8 * 100;
        dMH = (dMH - 2) / 8 * 100;

        // transform to z-scores
        double dPF_Z = (dPF - 81.18122) / 29.10588;
        double dRP_Z = (dRP - 80.52856) / 27.13526;
        double dBP_Z = (dBP - 81.74015) / 24.53019;
        double dGH_Z = (dGH - 72.19795) / 23.19041;
        double dVT_Z = (dVT - 55.59090) / 24.84380;
        double dSF_Z = (dSF - 83.73973) / 24.75775;
        double dRE_Z = (dRE - 86.41051) / 22.35543;
        double dMH_Z = (dMH - 70.18217) / 20.50597;

        // create physical and mental health composite scores
        double dAggPhys = (dPF_Z * 0.42402)
            + (dRP_Z * 0.35119)
            + (dBP_Z * 0.31754)
            + (dGH_Z * 0.24954)
            + (dVT_Z * 0.02877)
            + (dSF_Z * -.00753)
            + (dRE_Z * -.19206)
            + (dMH_Z * -.22069);
        double dAggMent = (dPF_Z * -.22999)
            + (dRP_Z * -.12329)
            + (dBP_Z * -.09731)
            + (dGH_Z * -.01571)
            + (dVT_Z * 0.23534)
            + (dSF_Z * 0.26876)
            + (dRE_Z * 0.43407)
            + (dMH_Z * 0.48581);

        // transform composite and scale scores to t-scores
        double dAggPhys_T = 50 + (dAggPhys * 10);
        double dAggMent_T = 50 + (dAggMent * 10);
        double dPF_T = 50 + (dPF_Z * 10);
        double dRP_T = 50 + (dRP_Z * 10);
        double dBP_T = 50 + (dBP_Z * 10);
        double dGH_T = 50 + (dGH_Z * 10);
        double dVT_T = 50 + (dVT_Z * 10);
        double dSF_T = 50 + (dSF_Z * 10);
        double dRE_T = 50 + (dRE_Z * 10);
        double dMH_T = 50 + (dMH_Z * 10);

        // move scores and descriptions to an array for easy insertion
        int[] dEncIntakeScores = new int[10] {
            Convert.ToInt32(Math.Round(dAggPhys_T)),
            Convert.ToInt32(Math.Round(dAggMent_T)),
            Convert.ToInt32(Math.Round(dPF_T)),
            Convert.ToInt32(Math.Round(dRP_T)),
            Convert.ToInt32(Math.Round(dBP_T)),
            Convert.ToInt32(Math.Round(dGH_T)),
            Convert.ToInt32(Math.Round(dVT_T)),
            Convert.ToInt32(Math.Round(dSF_T)),
            Convert.ToInt32(Math.Round(dRE_T)),
            Convert.ToInt32(Math.Round(dMH_T))};
        string[] dEncIntakeInperpretation = new string[10] {
            "NEMC PHYSICAL HEALTH T-SCORE - SF12",
            "NEMC MENTAL HEALTH T-SCORE - SF12",
            "NEMC PHYSICAL FUNCTIONING T-SCORE",
            "NEMC ROLE LIMITATION PHYSICAL T-SCORE",
            "NEMC PAIN T-SCORE",
            "NEMC GENERAL HEALTH T-SCORE",
            "NEMC VITALITY T-SCORE",
            "NEMC ROLE LIMITATION EMOTIONAL T-SCORE",
            "NEMC SOCIAL FUNCTIONING T-SCORE",
            "NEMC MENTAL HEALTH T-SCORE"};

        CIntake intake = new CIntake();
        for (int nIndex = 0; nIndex < dEncIntakeScores.Length; nIndex++)
        {
            bool bSuccess = intake.InsertEncIntakeScore(
                Master,
                Master.SelectedEncounterID,
                lEncIntakeID,
                lMID,
                lScoreType,
                dEncIntakeScores[nIndex],
                0,
                dEncIntakeInperpretation[nIndex],
                nIndex+1,
                lGRP);

            if (!bSuccess)
                return bSuccess;
        }

        return true;
    }
Esempio n. 19
0
    protected void CheckPatientStep()
    {
        CPatientTxStep patstep = new CPatientTxStep(Master);

        patstep.UpdatePatientSteps();

        bool bHasPendingQuestionnaires = false;

        //check if patient have peding follow-up questionnaires
        CIntake intake    = new CIntake();
        DataSet dsIntakes = intake.GetPatIntakeAssignedDS(Master);

        if (dsIntakes != null)
        {
            DataRow[] drs = dsIntakes.Tables[0].Select("STATUS = 0");
            bHasPendingQuestionnaires = (drs.GetLength(0) > 0);
        }

        //completed profile
        if ((Master.PatientTxStep & (long)PatientStep.SavedProfile) == 0)
        {
            //Redirect patient to the profile page
            Response.Redirect("pat_profile.aspx", true);
        }
        else
        {
            //check if patient is redirected here by completing follow up questionnaires
            if (Session["COMPLETED_FOLLOWUP"] != null)
            {
                if (Convert.ToInt32(Session["COMPLETED_FOLLOWUP"]) == 1)
                {
                    Session["COMPLETED_FOLLOWUP"] = null;
                    mvPortalSteps.SetActiveView(vCompletedFollowUp);
                    return;
                }
                else if (Convert.ToInt32(Session["COMPLETED_FOLLOWUP"]) == 2)
                {
                    Session["COMPLETED_FOLLOWUP"] = null;
                    mvPortalSteps.SetActiveView(vCompletedCSQ);
                    return;
                }
            }

            //Step 2 check (USER_STORY #2851)

            //if patient has not started or completed the baseline questionnaires
            if ((Master.PatientTxStep & (long)PatientStep.CompletedBaseline) == 0)
            {
                if ((Master.PatientTxStep & (long)PatientStep.StartedBaseline) == 0)
                {
                    //show "Getting Started" view
                    if (Request.UrlReferrer != null)
                    {
                        string strRefPage = Request.UrlReferrer.ToString().ToLower();
                        if (strRefPage.IndexOf("pat_profile.aspx") > -1)
                        {
                            spSubmitTxt.Visible = true;
                        }
                    }

                    mvPortalSteps.SetActiveView(vStep2);
                    return;
                }
                else
                {
                    //show complete baseline questionnaire view
                    mvPortalSteps.SetActiveView(vStartedBaseline);
                    return;
                }
            }

            //if patient has not competed videos
            if ((Master.PatientTxStep & (long)PatientStep.CompletedVideos) == 0)
            {
                if ((Master.PatientTxStep & (long)PatientStep.StartedVideos) == 0)
                {
                    if (Request.UrlReferrer != null)
                    {
                        //show videos message
                        string strRefPage = Request.UrlReferrer.ToString().ToLower();
                        strRefPage = strRefPage.Substring(strRefPage.LastIndexOf('/'));
                        Regex reREF = new Regex("mid\\d*.aspx", RegexOptions.IgnoreCase);

                        bool bFromQuestionnaire = reREF.IsMatch(strRefPage);

                        if (strRefPage.IndexOf("patient_assessment.aspx") > -1 || bFromQuestionnaire)
                        {
                            pQCongratulations.Visible = true;
                            pQuestWelcome.Visible     = false;
                        }
                    }

                    mvPortalSteps.SetActiveView(vCompletedBaselineQ);
                    return;
                }
                else
                {
                    //show started videos view
                    mvPortalSteps.SetActiveView(vStartedVideos);
                    return;
                }
            }

            if ((Master.PatientTxStep & (long)PatientStep.HasCPAPData) == 0)
            {
                if ((Master.PatientTxStep & (long)PatientStep.CompletedVideos) > 0 &&
                    (Master.NotificationTxStep & (long)PatientStep.CompletedVideos) == 0)
                {
                    if (!bHasPendingQuestionnaires)
                    {
                        if (Request.UrlReferrer != null)
                        {
                            string strRefPage = Request.UrlReferrer.ToString().ToLower();
                            strRefPage = strRefPage.Substring(strRefPage.LastIndexOf('/'));

                            if (strRefPage.IndexOf("education.aspx") > -1)
                            {
                                pVidWelcome.Visible = false;
                                //spVidCongratulations.Visible = true;
                            }
                        }

                        patstep.UpdateNotificationSteps((long)PatientStep.CompletedVideos);
                        mvPortalSteps.SetActiveView(vCompletedVideos);
                        return;
                    }
                    else
                    {
                        patstep.UpdateNotificationSteps((long)PatientStep.CompletedVideos);
                        GetListPendingQuestionnaires(dsIntakes, bHasPendingQuestionnaires);
                        mvPortalSteps.SetActiveView(vPendingQuestionnaires);
                        return;
                    }
                }
                else if ((Master.PatientTxStep & (long)PatientStep.CompletedVideos) > 0 &&
                         (Master.NotificationTxStep & (long)PatientStep.CompletedVideos) > 0)
                {
                    if (bHasPendingQuestionnaires)
                    {
                        GetListPendingQuestionnaires(dsIntakes, bHasPendingQuestionnaires);
                        mvPortalSteps.SetActiveView(vPendingQuestionnaires);
                        return;
                    }
                }
            }

            if (bHasPendingQuestionnaires)
            {
                GetListPendingQuestionnaires(dsIntakes, bHasPendingQuestionnaires);
                mvPortalSteps.SetActiveView(vPendingQuestionnaires);
                return;
            }

            //Redirect patient to treatment results page
            Response.Redirect("portal_revamp.aspx");
        }
    }