public ActionResult Index()
        {
            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            // retrieve and set SessionForm params
            string    formIdent = "View_Test_Form";
            def_Forms frm       = formsRepo.GetFormByIdentifier(formIdent);

            if (frm == null)
            {
                return(Content("Could not find form with identifier \"" + formIdent + "\""));
            }
            def_FormResults fr = formsRepo.GetFormResultsByFormId(frm.formId).FirstOrDefault();

            if (fr == null)
            {
                fr = new def_FormResults()
                {
                    formId           = frm.formId,
                    formStatus       = 0,
                    sessionStatus    = 0,
                    dateUpdated      = DateTime.Now,
                    deleted          = false,
                    locked           = false,
                    archived         = false,
                    EnterpriseID     = 0,
                    GroupID          = 0,
                    subject          = 0,
                    interviewer      = 0,
                    assigned         = 0,
                    training         = false,
                    reviewStatus     = 0,
                    statusChangeDate = DateTime.Now
                };
                formsRepo.AddFormResult(fr);
            }


            SessionHelper.SessionForm.formId         = frm.formId;
            SessionHelper.SessionForm.formResultId   = fr.formResultId;
            SessionHelper.SessionForm.formIdentifier = frm.identifier;
            SessionHelper.LoginStatus.EnterpriseID   = 0;

            def_Parts prt = formsRepo.GetFormParts(frm)[0];

            SessionHelper.SessionForm.partId = prt.partId;
            Session["part"] = prt.partId;

            def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

            return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = SessionHelper.SessionForm.partId.ToString() }));
        }
        //                BuildItemResults(output, part, "SIS-Prof1_PageNotes_item");

        protected void BuildItemResults(PdfOutput output, def_Parts part, params object[] identifiersOrPairs)
        {
            foreach (object identOrPair in identifiersOrPairs)
            {
                if (identOrPair is string)
                {
                    string    ident = (string)identOrPair;
                    def_Items itm   = formsRepo.GetItemByIdentifier(ident);
                    formsRepo.GetEnterpriseItems(new def_Items[] { itm }.ToList(), formResults.EnterpriseID.Value);
                    if (itm == null)
                    {
                        throw new Exception("could not find item with identifier " + ident);
                    }
                    string rv = GetSingleResponse(itm);
                    output.appendItem(itm.label.Replace("*", ""), (rv == null) ? "" : rv.Replace("@", "@    "));
                }
                else if (identOrPair is LabelValuePair)
                {
                    LabelValuePair p = (LabelValuePair)identOrPair;
                    output.appendItem(p.label, p.value);
                }
                else
                {
                    throw new Exception("unrecognized object type in parameter \"identifieresOrPairs\", objects must be of type string or pair");
                }
            }
        }
        protected void buildTableWithItems(PdfOutput output, def_Parts part, int nColumns, string[] headers, params string[] identifiers)
        {
            int nRows = identifiers.Length / nColumns;

            string[][] vals = new string[nRows][];
            for (int row = 0; row < nRows; row++)
            {
                vals[row] = new string[nColumns];
                for (int col = 0; col < nColumns; col++)
                {
                    string    ident = identifiers[row * nColumns + col];
                    def_Items itm   = formsRepo.GetItemByIdentifier(/*formResults,*/ ident);                  //formsRepo.GetAllItems().First(t => t.identifier.Equals(ident));//getItemByIdentifier(part,ident);
                    if (itm == null)
                    {
                        throw new Exception("could not find item with identifer " + ident);
                    }
                    formsRepo.GetItemVariables(itm);
                    def_ItemVariables iv = itm.def_ItemVariables.FirstOrDefault();
                    if (iv == null)
                    {
                        throw new Exception("could not find any itemVariables for item with identifer " + ident);
                    }
                    def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);                    //iv.def_ResponseVariables.FirstOrDefault();
                    vals[row][col] = ((rv == null) ? "" : rv.rspValue);
                }
            }
            output.appendSimpleTable(headers, vals);
        }
        public ActionResult StartAssmnt()
        {
            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            // retrieve and set SessionForm params
            string paramFormId = Request["formId"] as string;

            SessionHelper.SessionForm.formId = Convert.ToInt32(paramFormId);

            string paramFormResultId = Request["formResultId"] as string;

            SessionHelper.SessionForm.formResultId = Convert.ToInt32(paramFormResultId);

            // get the sectionId of the first section of the first part based on the formId
            def_Forms frm = formsRepo.GetFormById(SessionHelper.SessionForm.formId);

            SessionHelper.SessionForm.formIdentifier = frm.identifier;

            def_Parts prt = formsRepo.GetFormParts(frm)[0];

            SessionHelper.SessionForm.partId = prt.partId;
            Session["part"] = prt.partId;

            def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

            return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = SessionHelper.SessionForm.partId.ToString() }));
        }
Esempio n. 5
0
        private void PrintSupplementalProtectionAndAdvocacyScale(PdfOutput output)
        {
            def_Parts part = formsRepo.GetPartByFormAndIdentifier(form, "Section 3. Supplemental Protection and Advocacy Scale");

            AppendPartHeader(output, part.identifier);
            foreach (def_Sections sct in formsRepo.GetSectionsInPart(part))
            {
                BuildDetailedResponseTable(part, output, sct);
            }
        }
Esempio n. 6
0
        private void PrintExceptionalMedicalNeeds(PdfOutput output)
        {
            def_Parts part = formsRepo.GetPartByFormAndIdentifier(form, "Section 1. Exceptional Medical and Behavioral Support Needs");

            AppendPartHeader(output, part.identifier);
            foreach (def_Sections sct in formsRepo.GetSectionsInPart(part))
            {
                PrintExceptMedNeedsTable(part, output, sct);
            }
        }
        public ActionResult NewBlankAssessment()
        {
            string formId = Request["formId"];

            SearchModel model = new SearchModel();

            if (model.create && model.edit)
            {
                /*
                 * **** Check if User has authorization to create an Assessment for this Group.
                 */
                // *** RRB 10/27/15 - the Create Assessment should be a method used here and from the 'Action' above.
                def_FormResults frmRes = FormResults.CreateNewFormResultFull(formId,
                                                                             SessionHelper.LoginStatus.EnterpriseID.ToString(),
                                                                             SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString(),
                                                                             "0",
                                                                             SessionHelper.LoginStatus.UserID.ToString());
                if (ventureMode)
                {
                    frmRes.assigned = SessionHelper.LoginStatus.UserID;
                }

                formsRepo.AddFormResult(frmRes);

                if (SessionHelper.SessionForm == null)
                {
                    SessionHelper.SessionForm = new SessionForm();
                }
                SessionForm sf = SessionHelper.SessionForm;

                /*
                 * if (sf == null)
                 * {
                 *  return RedirectToAction("Index", "Search", null);
                 * }
                 */
                // set SessionForm params
                sf.formId       = frmRes.formId;                    // TODO: How to determine which formid?
                sf.formResultId = frmRes.formResultId;

                // get the sectionId of the first section of the first part based on the formId
                def_Forms frm = formsRepo.GetFormById(sf.formId);
                def_Parts prt = formsRepo.GetFormParts(frm)[0];
                sf.partId       = prt.partId;
                Session["part"] = prt.partId;
                def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

                return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() }));
            }
            else
            {
                return(RedirectToAction("Index", "Search"));
            }
        }
 protected void buildTableWithItems(PdfOutput output, def_Parts part, int nColumns, params string[] identifiers)
 {
     string[] headers = new string[nColumns];
     for (int i = 0; i < nColumns; i++)
     {
         string    ident = identifiers[i];
         def_Items itm   = formsRepo.GetItemByIdentifier(/*formResults,*/ ident);              //formsRepo.GetAllItems().First(t => t.identifier.Equals(ident));//getItemByIdentifier(part,ident);
         if (itm == null)
         {
             throw new Exception("could not find item with identifer " + ident);
         }
         headers[i] = itm.label.Replace("*", "");
     }
     buildTableWithItems(output, part, nColumns, headers, identifiers);
 }
        public void defaultOrderSections()
        {
            if (customSectionOrderByIdentifiers == null)
            {
                customSectionOrderByIdentifiers = new List <string>();
            }

            List <def_FormParts> formParts = formsRepo.GetFormPartsByFormId(form.formId).OrderBy(fp => fp.order).Select(fp => fp).ToList();

            foreach (var fp in formParts)
            {
                def_Parts           part     = formsRepo.GetPartById(fp.partId);
                List <def_Sections> sections = formsRepo.GetSectionsInPart(part);
                foreach (var s in sections)
                {
                    customSectionOrderByIdentifiers.Add(s.identifier);
                }
            }
        }
Esempio n. 10
0
        public ActionResult CreateStubApplication(string ramsellId)
        {
            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            //createa new def_FormResult for the stub application
            AdapLAStubApp stubHelper = new AdapLAStubApp(formsRepo);
            int           newFrId    = stubHelper.CreateAndPrepopulateNewStubApp(ramsellId);
            def_Forms     stubForm   = stubHelper.GetStubForm();

            //setup session vars for viewing stub application screen(s)
            SessionHelper.SessionForm.formId         = stubForm.formId;
            SessionHelper.SessionForm.formResultId   = newFrId;
            SessionHelper.SessionForm.formIdentifier = AdapLAStubApp.stubFormIdentifier;
            SessionHelper.LoginStatus.EnterpriseID   = SessionHelper.LoginStatus.EnterpriseID;

            def_Parts prt = formsRepo.GetFormParts(stubForm)[0];

            SessionHelper.SessionForm.partId = prt.partId;
            Session["part"] = prt.partId;

            def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

            SessionHelper.SessionForm.sectionId = sct.sectionId;
            Session["section"] = sct.sectionId;

            //redirect to first section in newly-created stub app
            return(RedirectToAction("Template", "Results", new {
                sectionId = SessionHelper.SessionForm.sectionId.ToString(),
                partId = SessionHelper.SessionForm.partId.ToString()
            }));
        }
 protected void buildSubheaderWithResults(PdfOutput output, def_Parts part, string subheader, params object[] identifiersOrPairs)
 {
     output.appendSubHeader(subheader);
     BuildItemResults(output, part, identifiersOrPairs);
 }
Esempio n. 12
0
        protected void PrintProfilePage(PdfOutput output, int ageInYears)
        {
            List <def_Parts> prts = formsRepo.GetFormParts(form);
            def_Parts        part = prts[0];

            PdfOutput secondCol = output.getSecondColumnBranch();

            output.drawY -= .3;
            if (SessionHelper.LoginStatus.EnterpriseID == 44)
            {
                buildSubheaderWithResults(output, part, "Person Being Assessed",
                                          "itmNmeLst", "nmeFrst", "nmeMdl", "sis_cl_lang_item", "itmGender", "adrlne", "adrcty",
                                          "sis_cl_st1", "sis_cl_zip1", "sis_cl_phone_item",
                                          "sis_cl_dob_dt1", new LabelValuePair("Age", ageInYears.ToString()), "trkNum", new LabelValuePair("Medicaid Number", MaskMedicaidNumber(GetSingleResponse(formsRepo.GetItemByIdentifier("sis_cl_medicaidNum1")))),
                                          new LabelValuePair("SSN", MaskSSN(GetSingleResponse(formsRepo.GetItemByIdentifier("itmSsn")))));
            }
            else
            {
                buildSubheaderWithResults(output, part, "Person Being Assessed",
                                          "itmNmeLst", "nmeFrst", "nmeMdl", "sis_cl_lang_item", "itmGender", "adrlne", "adrcty",
                                          "sis_cl_st1", "sis_cl_zip1", "sis_cl_phone_item",
                                          "sis_cl_dob_dt1", new LabelValuePair("Age", ageInYears.ToString()), "trkNum", "sis_cl_medicaidNum1",
                                          new LabelValuePair("SSN", MaskSSN(GetSingleResponse(formsRepo.GetItemByIdentifier("itmSsn")))));
            }

            buildSubheaderWithResults(output, part, "Assessment Data", "intvwDate", "isp_begin_date_item", new LabelValuePair("SIS ID", formResults.formResultId.ToString()));
            secondCol.drawY -= .6;
            buildSubheaderWithResults(secondCol, part, "Interviewer Data",
                                      "sis_int_full_nm1", "sis_int_agency_nm1", "sis_int_addr_line11", "sis_int_city1",
                                      "sis_int_st1", "sis_int_zip", "sis_int_position_cd1", "sis_int_phone_num1",
                                      "sis_int_phone_num_ext1", "sis_int_email1");
            output.drawY -= .3;
            output.appendSectionBreak();
            output.appendSubHeader("Support Providers", "Essential supports for this individual are being provided by the following");
            buildTableWithItems(output, part, 4,
                                "sis_sup1_name_item", "sis_sup1_reln_item", "sis_sup1_phone_item", "sis_sup1_ext_item",
                                "sis_sup2_name_item", "sis_sup2_reln_item", "sis_sup2_phone_item", "sis_sup2_ext_item",
                                "sis_sup3_name_item", "sis_sup3_reln_item", "sis_sup3_phone_item", "sis_sup3_ext_item",
                                "sis_sup4_name_item", "sis_sup4_reln_item", "sis_sup4_phone_item", "sis_sup4_ext_item",
                                "sis_sup5_name_item", "sis_sup5_reln_item", "sis_sup5_phone_item", "sis_sup5_ext_item",
                                "sis_sup6_name_item", "sis_sup6_reln_item", "sis_sup6_phone_item", "sis_sup6_ext_item");
            output.drawY -= .3;
            output.appendSectionBreak();
            output.appendSubHeader("Respondent Data", "Information for the SIS ratings was provided by the following respondents:");
            //buildTableWithItems(output, part, 5,
            //    new string[] { "First Name", "Last Name", "Agency", "Email", "Language", },
            //    "sis_res1_firstn_item", "sis_res1_lastn_item", "sis_res1_agen_item", "sis_res1_email_item", "sis_res1_lang_item",
            //    "sis_res2_firstn_item", "sis_res2_lastn_item", "sis_res2_agen_item", "sis_res2_email_item", "sis_res2_lang_item",
            //    "sis_res3_firstn_item", "sis_res3_lastn_item", "sis_res3_agen_item", "sis_res3_email_item", "sis_res3_lang_item",
            //    "sis_res4_firstn_item", "sis_res4_lastn_item", "sis_res4_agen_item", "sis_res4_email_item", "sis_res4_lang_item",
            //    "sis_res5_firstn_item", "sis_res5_lastn_item", "sis_res5_agen_item", "sis_res5_email_item", "sis_res5_lang_item",
            //    "sis_res6_firstn_item", "sis_res6_lastn_item", "sis_res6_agen_item", "sis_res6_email_item", "sis_res6_lang_item",
            //    "sis_res7_firstn_item", "sis_res7_lastn_item", "sis_res7_agen_item", "sis_res7_email_item", "sis_res7_lang_item",
            //    "sis_res8_firstn_item", "sis_res8_lastn_item", "sis_res8_agen_item", "sis_res8_email_item", "sis_res8_lang_item",
            //    "sis_res9_firstn_item", "sis_res9_lastn_item", "sis_res9_agen_item", "sis_res9_email_item", "sis_res9_lang_item",
            //    "sis_res10_firstn_item", "sis_res10_lastn_item", "sis_res10_agen_item", "sis_res10_email_item", "sis_res10_lang_item");

            buildTableWithItems(output, part, 6,
                                new string[] { "First Name", "Last Name", "Relationship", "Agency", "Email", "Language", },
                                "sis_res1_firstn_item", "sis_res1_lastn_item", "sis_res1_reln_item", "sis_res1_agen_item", "sis_res1_email_item", "sis_res1_lang_item",
                                "sis_res2_firstn_item", "sis_res2_lastn_item", "sis_res2_reln_item", "sis_res2_agen_item", "sis_res2_email_item", "sis_res2_lang_item",
                                "sis_res3_firstn_item", "sis_res3_lastn_item", "sis_res3_reln_item", "sis_res3_agen_item", "sis_res3_email_item", "sis_res3_lang_item",
                                "sis_res4_firstn_item", "sis_res4_lastn_item", "sis_res4_reln_item", "sis_res4_agen_item", "sis_res4_email_item", "sis_res4_lang_item",
                                "sis_res5_firstn_item", "sis_res5_lastn_item", "sis_res5_reln_item", "sis_res5_agen_item", "sis_res5_email_item", "sis_res5_lang_item",
                                "sis_res6_firstn_item", "sis_res6_lastn_item", "sis_res6_reln_item", "sis_res6_agen_item", "sis_res6_email_item", "sis_res6_lang_item",
                                "sis_res7_firstn_item", "sis_res7_lastn_item", "sis_res7_reln_item", "sis_res7_agen_item", "sis_res7_email_item", "sis_res7_lang_item",
                                "sis_res8_firstn_item", "sis_res8_lastn_item", "sis_res8_reln_item", "sis_res8_agen_item", "sis_res8_email_item", "sis_res8_lang_item",
                                "sis_res9_firstn_item", "sis_res9_lastn_item", "sis_res9_reln_item", "sis_res9_agen_item", "sis_res9_email_item", "sis_res9_lang_item",
                                "sis_res10_firstn_item", "sis_res10_lastn_item", "sis_res10_reln_item", "sis_res10_agen_item", "sis_res10_email_item", "sis_res10_lang_item");


            output.drawY -= .3;

            output.appendSectionBreak();
            buildSubheaderWithResults(output, part, "Person who entered this information",
                                      "sis_entry_firstn_item", "sis_entry_lastn_item");

            if (options[OptionKey.includeComments])
            {
                output.appendSectionBreak();

                def_Items itm = formsRepo.GetItemByIdentifier("SIS-Prof1_PageNotes_item");
                if (itm == null)
                {
                    throw new Exception("could not find item with identifier " + "SIS-Prof1_PageNotes_item");
                }
                string rv = GetSingleResponse(itm);

                output.appendSubHeaderOnNewPageIfNecessary("Other Pertinent Information", rv);

                //BuildItemResults(output, part, "SIS-Prof1_PageNotes_item");
                output.drawY -= .3;
            }

            //output.appendWrappedText("Introduction to the SIS Report:", .36, 7.9, output.boldFont);
        }
        public ActionResult Template(int?sectionIdOverride = null, List <string> validationMessages = null)
        {
            mLogger.Debug("* * *  ResultsController:Template method  * * *");

            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            if (Session["form"] != null && !string.IsNullOrWhiteSpace(Session["form"].ToString()))
            {
                int formId = SessionHelper.SessionForm.formId;
                formId = int.Parse(Session["form"].ToString());
                def_Forms frm = formsRepo.GetFormById(formId);
                SessionHelper.SessionForm.formId         = formId;
                SessionHelper.SessionForm.formIdentifier = frm.identifier;
                var oldFrmResult = formsRepo.GetFormResultById(SessionHelper.SessionForm.formResultId);
                var newFrmResult = formsRepo.GetFormResultsByFormSubject(formId, oldFrmResult.subject).OrderByDescending(f => f.dateUpdated);
                if (newFrmResult.Any())
                {
                    // use most recent form result
                    SessionHelper.SessionForm.formResultId = newFrmResult.FirstOrDefault().formResultId;
                }

                Session["form"] = null;
                int part = int.Parse(Session["part"].ToString());
                SessionHelper.SessionForm.partId = part;
            }

            SessionForm sessionForm = SessionHelper.SessionForm;

            // set language ID in session based on meta-data (default to English) + other session vars
            CultureInfo   ci      = Thread.CurrentThread.CurrentUICulture;
            string        isoName = (ci == null) ? "en" : ci.TwoLetterISOLanguageName.ToLower();
            def_Languages lang    = formsRepo.GetLanguageByTwoLetterISOName(isoName);

            if (lang == null)
            {
                throw new Exception("could not find def_Language entry for iso code \"" + isoName + "\"");
            }
            else
            {
                sessionForm.langId = lang.langId;
            }



            // This is the master or top level sectionId, there can be mulitple subSections below this section.
            // The subSections will be in the SectionItems
            string sectionId = (sectionIdOverride == null) ? Request["sectionId"] as string : sectionIdOverride.ToString();

            mLogger.Debug("* * *  Results Template sectionId: {0}", sectionId);
            Session["section"] = sectionId;
            def_Sections sctn = formsRepo.GetSectionById(Convert.ToInt32(sectionId));

            sessionForm.sectionId = sctn.sectionId;

            // Create a new Assessments Model Template (AMT) that is used by the .cshtml template (Razor code)
            TemplateItems amt;

            if (sctn.href != null && (sctn.href.EndsWith("spprtNeedsScale.cshtml") || sctn.href.EndsWith("excptnlMedSpprtNeed.cshtml")))
            {
                amt = new QuestionListForm();
            }
            else
            {
                amt = new GeneralForm();
            }


            amt.thisSection   = sctn;
            amt.thisSectionId = sctn.sectionId;
            amt.formsRepo     = formsRepo;
            amt.formResultId  = sessionForm.formResultId;
            amt.currentUser   = SessionHelper.LoginInfo.LoginID;

            //amt.items = new List<def_Items>();
            amt.subSections = new List <def_Sections>();
            amt.fldLabels   = new Dictionary <string, string>();
            amt.itmPrompts  = new Dictionary <string, string>();
            amt.rspValues   = new Dictionary <string, string>();
            mLogger.Debug("* * *  ResultsController:Template sessionForm.formResultId: {0}", sessionForm.formResultId);
            def_FormResults fr = formsRepo.GetFormResultById(sessionForm.formResultId);

            mLogger.Debug("* * *  ResultsController:Template fr.formResultId: {0}", fr.formResultId);

            if (fr != null)
            {
                if (fr.formStatus == (byte)FormResults_formStatus.IN_PROGRESS)
                {
                    amt.inProgress = true;
                }
                if (fr.formStatus == (byte)FormResults_formStatus.NEW)
                {
                    amt.newAssmnt = true;
                }
            }



            //Start: added for enhancement Bug 13663 to be refactored

            amt.updatedDate = fr.dateUpdated;

            amt.formStatus = fr.formStatus;

            int statusMasterId = 0;

            def_StatusMaster statusMaster = formsRepo.GetStatusMasterByFormId(fr.formId);

            if (statusMaster != null)
            {
                statusMasterId = statusMaster.statusMasterId;

                def_StatusDetail statusdetails = formsRepo.GetStatusDetailBySortOrder(statusMasterId, fr.formStatus);

                amt.formSatusText = statusdetails.def_StatusText
                                    .Where(sd => sd.EnterpriseID == 8 && sd.langId == 1)
                                    .Select(z => z.displayText)
                                    .FirstOrDefault();
            }
            else
            {
                //This is used as currently we are showing In Progress for all items which do not have status
                amt.formSatusText = "In Progress";
            }

            amt.CanUserChangeStatus = true;

            if (UAS_Business_Functions.hasPermission(PermissionConstants.ASSIGNED, PermissionConstants.ASSMNTS))
            {
                amt.CanUserChangeStatus = false;
            }
            else if (amt.formSatusText.ToLower() == "needs review" || amt.formSatusText.ToLower().Contains("approved"))
            {
                if (!UAS_Business_Functions.hasPermission(PermissionConstants.APPROVE, PermissionConstants.ASSMNTS))
                {
                    amt.CanUserChangeStatus = false;
                }
            }
            else if (amt.formId == 18)
            {
                amt.CanUserChangeStatus = false;
            }



            var    formType    = formsRepo.GetResponseVariablesByFormResultIdentifier(fr.formResultId, "C1_FormType");
            string formVariant = string.Empty;

            if (formType != null && formType.rspValue != null && formType.rspValue != String.Empty)
            {
                formVariant          = formType.rspValue;
                amt.FormVariantTitle = formVariant;
            }
            else
            {
                formsEntities context = new Assmnts.formsEntities();

                amt.FormVariantTitle = context.def_FormVariants
                                       .Where(fv => fv.formID == fr.formId)
                                       .Select(fv => fv.title)
                                       .FirstOrDefault();
            }

            //get the subject id from form result id
            if (fr.subject != null)
            {
                int subject = (int)fr.subject;

                var elgEndDate = formsRepo.GetResponseVariablesBySubjectForm(subject, 18, "C1_ProgramEligibleEndDate");

                string endDate = elgEndDate != null ? elgEndDate.rspValue : string.Empty;

                amt.EligibilityEnddate = endDate;

                amt.formResultUser = authClient.GetUserDisplay(subject);

                amt.clientId = authClient.GetExistingAdapIdentifier(amt.formResultUser.UserID, 8);
            }



            //End: added for enhancement Bug 13663 to be refactored


            amt.formId = sessionForm.formId;

            formsRepo.SortSectionItems(sctn);                   // This is both loading and sorting the SectionItems.

            // Get the Items in the SubSections *** NOTE: this only goes ONE level deep ***  Should be made recursive for unlimited levels !!!
            // amt.sections = new List<def_Sections>();
            foreach (def_SectionItems sctnItm in sctn.def_SectionItems.OrderBy(si => si.order))
            {
                if (sctnItm.subSectionId.GetValueOrDefault(0) == 0 || sctnItm.display == false)
                {
                    continue;
                }
                // def_Sections subSctns = sctnItm.def_SubSections.def_Sections;
                def_Sections subSctns = formsRepo.GetSubSectionById(sctnItm.subSectionId);

                //do not add notes section to the section list, (if there is a notes item, it will later be set as amt.notesItem)
                if (subSctns.multipleItemsPerPage == false)
                {
                    continue;
                }

                formsRepo.SortSectionItems(subSctns);                       // Load and sort the SectionItems
                amt.subSections.Add(subSctns);
                // GetItemLabelsResponses(fr.formResultId, amt, formsRepo.GetSectionItems(sctnItm.def_SubSections.def_Sections));
            }

            // RRB 5/28/15 *** This is only necessary for the Profile screens
            //             *** Getting and sorting the SectionItems above is only necessary for Question forms
            //             ***   In fact, it may duplicate what is being done in the templates
            formsRepo.GetItemListIncludingSubSections(sctn, amt);
            //GetItemListIncludingSubSections(sctn, amt);

            // Get the Notes items
            formsRepo.GetItemListForNotes(sctn, amt);

            formsRepo.GetItemLabelsResponses(fr.formResultId, amt, amt.items);

            //determine whether or not this user will be shown itemvariable identifiers as tooltips
            //TODO this is a DEV mode only thing
            amt.showItemVariableIdentifiersAsTooltips = Convert.ToBoolean(ConfigurationManager.AppSettings["showItemVariableIdentifiersAsTooltips"]);            // true;//new UAS.Business.UAS_Business_Functions().hasPermission(7,"assmnts");

            //save response values in session variable to later determine which ones were modified
            ////List<string> keysToClear = new List<string>();
            ////foreach (string key in Session.Keys)
            ////    if (key.StartsWith("frmOriginal___"))
            ////        keysToClear.Add(key);
            ////foreach (string key in keysToClear)
            ////    Session.Remove(key);
            //DateTime oneHourFromNow = DateTime.Now.AddHours(1);
            //foreach (string key in amt.rspValues.Keys)
            //{
            //Response.Cookies["frmOriginal___" + key].Value = amt.rspValues[key];
            //Response.Cookies["frmOriginal___" + key].Expires = oneHourFromNow;
            //}

            mLogger.Debug("* * *  AFTER GetItemLabelsResponses amt.items.Count: {0}", amt.items.Count);

            mLogger.Debug("* * *  amt.rspValues.Count (Total): {0}", amt.rspValues.Count);

            //populate required and readonly dictionaries
            amt.fldRequired = new Dictionary <string, bool>();
            amt.fldReadOnly = new Dictionary <string, bool>();
            List <def_SectionItems> siList = formsRepo.GetSectionItemsBySectionIdEnt(sctn.sectionId, SessionHelper.LoginStatus.EnterpriseID);

            if (amt.items != null)
            {
                foreach (def_Items itm in amt.items)
                {
                    if (amt.fldRequired.ContainsKey(itm.identifier))
                    {
                        throw new Exception("Found duplicate item identifier \"" + itm.identifier + "\"");
                    }
                    def_SectionItems si = siList.FirstOrDefault(s => (!s.subSectionId.HasValue && s.itemId == itm.itemId));

                    amt.fldRequired.Add(itm.identifier, (si == null) ? false : si.requiredForm);
                    amt.fldReadOnly.Add(itm.identifier, (si == null) ? false : si.readOnly);
                }
            }

            amt.isProfile = false;

            string[] uriSegments      = sctn.href.Split('/');
            string   templateFileName = uriSegments[uriSegments.Count() - 1];

            switch (templateFileName)
            {
            case "idprof1.cshtml":
            case "idprof2.cshtml":
            case "idprof2_Child.cshtml":
                if (mLogger.IsDebugEnabled)
                {
                    mLogger.Debug("showing section item identifiers:");
                    foreach (def_SectionItems si in siList)
                    {
                        mLogger.Debug("\t{0}", si.def_Items.identifier);
                    }
                }
                amt.notesItem            = siList.Single(si => si.def_Items.identifier.EndsWith("PageNotes_item")).def_Items;
                sessionForm.templateType = TemplateType.StdSectionItems;
                amt.isProfile            = true;
                break;

            default:                                // "SIS/section1a":     Default to the item list
                sessionForm.templateType = TemplateType.MultipleCommonItems;
                break;
            }

            // Setup the Previous / Next screens
            amt.prevScreenTitle = amt.prevScreenHref = String.Empty;
            amt.nextScreenTitle = amt.nextScreenHref = String.Empty;

            def_Parts prt = formsRepo.GetPartById(Convert.ToInt32(Session["part"]));



            List <def_Sections> partSections = formsRepo.GetSectionsInPart(prt);

            mLogger.Debug("* * *  ResultsController:Template method  * * * partSections.Count: {0}", partSections.Count);

            //get a list of parts in the current form

            def_Forms        form          = formsRepo.GetFormById(amt.formId);
            List <def_Parts> partsInForm   = formsRepo.GetFormParts(form);
            List <int>       partIdsInForm = partsInForm.Select(p => p.partId).ToList();
            // List<def_Parts> partsInForm = formsRepo.getFormParts(fr.def_Forms);



            //these variables will be assigned int he loop below
            int currentSectionIndex = 0;
            int prevSectionIndex    = 0;
            int nextSectionIndex    = 0;

            //start by assuming the previous and next section will be in the same part
            int currentPartId = (prt == null) ? sessionForm.partId : prt.partId;

            amt.thisPartId = currentPartId;

            amt.navPartId = currentPartId.ToString();
            int prevPartId = currentPartId;
            int nextPartId = currentPartId;

            //in a special cases one of these will be set to true
            bool veryFirst = false;
            bool veryLast  = false;

            bool foundSectionId = false;

            //iterate through possible section ids
            for (int idx = 0; idx < partSections.Count; idx++)
            {
                if (partSections[idx].sectionId == sessionForm.sectionId)
                {
                    //found the current section id, start with some assumptions about previous and next section ids
                    foundSectionId      = true;
                    currentSectionIndex = idx;
                    prevSectionIndex    = idx - 1;
                    nextSectionIndex    = idx + 1;

                    //we may have to link to the last section of the previous part
                    if (prevSectionIndex < 0)
                    {
                        //special case where we're on the first section of the first part
                        if (partIdsInForm.IndexOf(prt.partId) == 0)                        //currentPartId == 1)
                        {
                            //veryFirst = true;
                            int partIndexInForm = partsInForm.Count();
                            List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(partsInForm[partIndexInForm - 1]);
                            prevPartId       = partsInForm[partIndexInForm - 1].partId;
                            prevSectionIndex = prevPartSections.Count - 1;
                        }
                        else
                        {
                            int partIndexInForm = partIdsInForm.IndexOf(prt.partId);
                            // occasionally a part with no sections may need to be skipped, which can happen with PartSectionsEnt records.
                            int listIndex = 0;
                            for (int i = 1; i < partIndexInForm; i++)
                            {
                                if (formsRepo.GetSectionsInPart(partsInForm[partIndexInForm - i]).Count() > 0)
                                {
                                    listIndex = partIndexInForm - i;
                                    break;
                                }
                            }

                            List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(partsInForm[listIndex]);
                            prevPartId       = partsInForm[listIndex].partId;
                            prevSectionIndex = prevPartSections.Count - 1;
                        }
                    }

                    // Oliver - same here the PartSections are ordered - just use the first one in the List.
                    // you can press F12 in Visual Studio and it will take you to the method.
                    // Data/Concrete/FormsRepository line 200
                    // The defined Interfaces are in Data/Abstract/IFormsRepository.cs

                    //we may have to link to he first section of the next part
                    if (nextSectionIndex > (partSections.Count - 1))
                    {
                        int partIndexInForm = partIdsInForm.IndexOf(prt.partId);
                        if (partIndexInForm == (partsInForm.Count() - 1))                          //formsRepo.GetPartById(nextPartId) == null)
                        {
                            //veryLast = true;
                            nextPartId       = partsInForm[0].partId;
                            nextSectionIndex = 0;
                        }
                        else
                        {
                            // occasionally a part with no sections may need to be skipped, which can happen with PartSectionsEnt records.
                            int listIndex = 0;
                            for (int i = 1; i < partsInForm.Count() - 1 - partIndexInForm; i++)
                            {
                                if (formsRepo.GetSectionsInPart(partsInForm[partIndexInForm + i]).Count() > 0)
                                {
                                    listIndex = partIndexInForm + i;
                                    break;
                                }
                            }

                            nextPartId       = partsInForm[listIndex].partId;
                            nextSectionIndex = 0;
                        }
                    }

                    break;
                }
            }

            if (!foundSectionId)
            {
                string msg = "current section id (" + sessionForm.sectionId + ") could not be found.\r\nListing candidates: (identifier / sectionId)";
                foreach (def_Sections sct in partSections)
                {
                    msg += (sct == null) ? "null" : ("\r\n" + sct.identifier + " / " + sct.sectionId);
                }
                throw new Exception(msg);
            }

            //print some debugging info
            if (mLogger.IsDebugEnabled)
            {
                mLogger.Debug("* * *  ResultsController:Template method  * * * " +
                              (veryFirst ? "this is the very first part/section" : "prevPartId: " + prevPartId.ToString() +
                               ", prevSectionIndex: " + prevSectionIndex.ToString()));
                mLogger.Debug("* * *  ResultsController:Template method  * * * " +
                              (veryLast ? "this is the very last part/section" : "nextPartId: " + nextPartId.ToString() +
                               ", nextSectionIndex: " + nextSectionIndex.ToString()));
            }
            if (partSections.Count > 0)
            {
                int    idxPeriod      = prt.identifier.IndexOf('.');
                string partShortTitle = (idxPeriod < 0) ? prt.identifier : prt.identifier.Substring(0, idxPeriod);
                // amt.thisScreenCaption = partShortTitle + " - " + partSections[thisIdx].identifier;
                amt.thisScreenCaption = partShortTitle + " - " + partSections[currentSectionIndex].identifier;
                amt.thisScreenTitle   = partSections[currentSectionIndex].title;

                if (!veryFirst)
                {
                    List <def_Sections> prevPartSections = formsRepo.GetSectionsInPart(formsRepo.GetPartById(prevPartId));
                    amt.prevScreenTitle     = prevPartSections[prevSectionIndex].title;
                    amt.prevScreenPartId    = prevPartId.ToString();
                    amt.prevScreenSectionId = prevPartSections[prevSectionIndex].sectionId.ToString();
                    amt.prevScreenHref      = "Template?partId=" + nextPartId + "&sectionId=" + amt.prevScreenSectionId;
                    //if (prevPartId != currentPartId)
                    //    amt.previousScreenHref = "Parts?formResultId=" + formsRepo.GetPartById(prevPartId).partId.ToString() + amt.previousScreenHref;
                }

                if (!veryLast)
                {
                    def_Parts tempPart = formsRepo.GetPartById(nextPartId);
                    if (tempPart != null)
                    {
                        List <def_Sections> tempPartSections = formsRepo.GetSectionsInPart(tempPart);
                        amt.nextScreenTitle     = tempPartSections[nextSectionIndex].title;
                        amt.nextScreenPartId    = nextPartId.ToString();
                        amt.nextScreenSectionId = tempPartSections[nextSectionIndex].sectionId.ToString();
                        amt.nextScreenHref      = "Template?partId=" + nextPartId + "&sectionId=" + amt.nextScreenSectionId;
                    }
                }
            }

            //pass a NavMenu model as a field in this items Model
            sessionForm.formIdentifier = form.identifier;
            amt.navMenuModel           = getNavMenuModel(sessionForm, amt);


            //Start: added for enhancement Bug 13663 to be refactored
            amt.navMenuModel.formResultUser      = amt.formResultUser;
            amt.navMenuModel.clientId            = amt.clientId;
            amt.navMenuModel.formSatusText       = amt.formSatusText;
            amt.navMenuModel.EligibilityEnddate  = amt.EligibilityEnddate;
            amt.navMenuModel.FormVariantTitle    = amt.FormVariantTitle;
            amt.navMenuModel.updatedDate         = amt.updatedDate;
            amt.navMenuModel.CanUserChangeStatus = amt.CanUserChangeStatus;
            amt.navMenuModel.formResultId        = amt.formResultId;
            //End: added for enhancement Bug 13663 to be refactored



            amt.ventureMode = SessionHelper.IsVentureMode;

            //special case for reports sections
            if ((sctn.identifier.EndsWith("Report") /*&& (Request["ignoreValidation"] as string) == null*/) ||
                sctn.href.Equals("~/Views/Templates/SIS/reportErrors.cshtml")
                )
            {
                if (!ValidateFormResult(fr, amt))
                {
                    return(View("~/Views/Templates/SIS/reportErrors.cshtml", amt));
                }
            }

            //add messages to the mdoel if necessary
            amt.validationMessages = validationMessages;             //validationMessages from method params, normally null

            //add a message to the model if necessary
            string message = Request["message"] as string;

            if (message != null)
            {
                if (amt.validationMessages == null)
                {
                    amt.validationMessages = new List <string>();
                }
                amt.validationMessages.Add(message);
            }

            // *** RRB 10/27/15 - added to fix problems with Venture and to be more efficient.
            if (!SessionHelper.IsVentureMode)
            {
                if (templateFileName.Equals("reportOptions.cshtml"))
                {
                    amt.reportOptions = AJBoggs.Sis.Reports.SisReportOptions.BuildPdfReportOptions(fr.EnterpriseID);
                }
            }

            // * * * OT 3/24/16 - for SIS supplemental questions, pre-populate sis_s41f with some item prompts from section 1A
            //  Don't do anything if there is already a response for sis_s41f
            //  (Bug 13132, #4 in description)
            if (sctn.identifier == "SQ" && amt.rspValues.ContainsKey("sis_s41f") && String.IsNullOrWhiteSpace(amt.rspValues["sis_s41f"]))
            {
                amt.rspValues["sis_s41f"] = String.Empty;

                //iterate through all section 1A items
                int          itmCount         = 0;
                bool         isSisCAssessment = fr.def_Forms.identifier.Equals("SIS-C");
                def_Sections sct1A            = formsRepo.GetSectionByIdentifier(isSisCAssessment ? "SIS-C 1A" : "SIS-A 1A");
                formsRepo.SortSectionItems(sct1A);
                foreach (def_SectionItems si in sct1A.def_SectionItems)
                {
                    def_Sections subSct = formsRepo.GetSubSectionById(si.subSectionId);
                    formsRepo.SortSectionItems(subSct);
                    foreach (def_SectionItems subSi in subSct.def_SectionItems)
                    {
                        //for items that have an itemVariable with suffix "_ExMedSupport", check if that itemVariable have a response of "2"
                        def_Items itm = subSi.def_Items;
                        itmCount++;
                        def_ItemVariables exMedSupIv = itm.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_ExMedSupport")).FirstOrDefault();
                        if (exMedSupIv != null)
                        {
                            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, exMedSupIv.itemVariableId);
                            if (rv != null && !String.IsNullOrWhiteSpace(rv.rspValue) && rv.rspValue == "2")
                            {
                                //append the item prompt to the pre-populated response for sis_s41f
                                amt.rspValues["sis_s41f"] += itmCount + ". " + itm.prompt + "\n";
                            }
                        }
                    }
                }
            }

            // *** OT 11/23/15 - added as test for Bug 12910 - Comparison: what changed from last approved application?
            //if we're on the ADAP form...
            if (form.identifier.Contains("ADAP"))
            {
                //get the previous formresult
                int?sortOrder = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder;
                int userId    = fr.subject.HasValue ? fr.subject.Value : -1;
                if (userId < 1)
                {
                    mLogger.Warn("subject < 1 for form result having formResultId = {0}.", fr.formResultId);
                }
                // * * * OT 1-19-16 added stipulation that "prevRes" is not the current formResult "fr"
                def_FormResults prevRes = null;
                if (sortOrder.HasValue && userId > 0)
                {
                    prevRes = formsRepo.GetEntities <def_FormResults>(
                        x => x.formId == fr.formId &&
                        x.formResultId != fr.formResultId &&
                        x.subject == userId &&
                        x.formStatus != sortOrder)
                              .OrderByDescending(x => x.dateUpdated)
                              .FirstOrDefault();
                }
                // * * * OT 1-19-16 in order to duplicate existing behavior and avoid crashes,
                // default to using the current formResult as the previous if no others are applicable
                if (prevRes == null)
                {
                    prevRes = fr;
                }

                List <string> remainingIdentifiers = amt.rspValues.Keys.ToList();

                IList <def_ItemResults> previousItemResults = formsRepo.GetItemResults(prevRes.formResultId);
                foreach (def_ItemResults ir in previousItemResults)
                {
                    foreach (def_ResponseVariables rv in ir.def_ResponseVariables)
                    {
                        if (rv.def_ItemVariables == null)
                        {
                            continue;
                        }

                        remainingIdentifiers.Remove(rv.def_ItemVariables.identifier);
                        string rspValue = HttpUtility.HtmlDecode(rv.rspValue);

                        amt.rspValues.Add("PREVIOUS_" + rv.def_ItemVariables.identifier, rspValue);
                    }
                }

                //populate amt with empty responses for fields Bmissing from previous formResult
                foreach (string ident in remainingIdentifiers)
                {
                    amt.rspValues.Add("PREVIOUS_" + ident, "");
                }
            }

            SessionHelper.ResponseValues = amt.rspValues;

            //Displays save message
            ViewBag.Notify        = "";
            ViewBag.NotifyMessage = "";
            if (Session["IsPageLoad"] != null)
            {
                if (!(bool)Session["IsPageLoad"])
                {
                    if (TempData["Savemsg"] != null && TempData["SavemsgHeader"] != null)
                    {
                        if (TempData["Savemsg"].ToString() != "" && TempData["SavemsgHeader"].ToString() != "")
                        {
                            ViewBag.Notify        = TempData["SavemsgHeader"].ToString();
                            ViewBag.NotifyMessage = TempData["Savemsg"].ToString();
                        }
                    }
                }
            }


            TempData["SavemsgHeader"] = "";
            TempData["Savemsg"]       = "";
            return(View(sctn.href, amt));
        }
Esempio n. 14
0
        //this is for the sections in the "Exceptional medical... needs" part
        private void PrintExceptMedNeedsTable(def_Parts part, PdfOutput output, def_Sections sct)
        {
            int nCols = 4;

            string[] headers = { sct.title, "", "Score", "Important \"To\" or \"For\"" };
            double[] indents = { .5, .75, 5.6, 6.75 };

            //headers
            output.drawY -= .1;
            for (int i = 0; i < nCols; i++)
            {
                output.DrawText(output.boldFont, output.fontSize, indents[i], output.drawY, headers[i]);
            }
            output.drawY += .13; output.appendSectionBreak();
            output.drawY -= PdfOutput.itemSpacing;

            indents = new double[] { .5, .75, 5.73, 6.75 };
            List <def_Items> itms = new List <def_Items>();

            formsRepo.SortSectionItems(sct);
            foreach (def_SectionItems si in sct.def_SectionItems)
            {
                if (si.subSectionId == null)    // NOTE: this case probably never occurs for this Part
                {
                    itms.Add(formsRepo.GetItemById(si.itemId));
                }
                else
                {
                    def_Sections sctn = formsRepo.GetSubSectionById(si.subSectionId);
                    formsRepo.SortSectionItems(sctn);
                    foreach (def_SectionItems ssi in sctn.def_SectionItems)
                    {
                        if (ssi.subSectionId == null)
                        {
                            itms.Add(formsRepo.GetItemById(ssi.itemId));
                        }
                    }
                }
            }
            int nRows = itms.Count() + 1;

            // Load the Values
            for (int row = 0; row < itms.Count; row++)
            {
                def_Items itm = itms[row];
                formsRepo.GetItemResultByFormResItem(formResultId, itm.itemId);
                def_ItemResults itmResults = itm.def_ItemResults.SingleOrDefault(ir => (ir.formResultId == formResultId));
                formsRepo.GetItemResultsResponseVariables(itmResults);
                foreach (def_ResponseVariables rv in itmResults.def_ResponseVariables)
                {
                    rv.def_ItemVariables = formsRepo.GetItemVariableById(rv.itemVariableId);
                }

                output.drawY -= .1;
                for (int col = 0; col < nCols; col++)
                {
                    string s = "ERROR";
                    switch (col)
                    {
                    case 0:
                        s = (row + 1).ToString();
                        break;

                    case 1:
                        s = itm.label;
                        break;

                    case 2:
                        def_ResponseVariables rv = itmResults.def_ResponseVariables.SingleOrDefault(r => r.def_ItemVariables.identifier.EndsWith("_ExMedSupport"));
                        s = ((rv == null) ? "" : rv.rspValue);
                        break;

                    case 3:
                        s = String.Empty;
                        break;
                    }
                    output.DrawText(output.contentFont, output.fontSize, indents[col], output.drawY, s);
                }
                output.drawY -= PdfOutput.itemSpacing * 2.5;
                if (output.drawY < 1)
                {
                    output.appendPageBreak();
                }
            }

            output.drawY -= .1;
            output.DrawText(output.boldFont, output.fontSize, indents[1], output.drawY, "Page Notes:");
            output.drawY -= PdfOutput.itemSpacing * 4;
            if (output.drawY < 1)
            {
                output.appendPageBreak();
            }
        }
Esempio n. 15
0
        // This is for the sets of items that have 3 numerical response values
        private void BuildDetailedResponseTable(def_Parts part, PdfOutput output, def_Sections sct)
        {
            int nCols = 6;

            string[] headers = { sct.title, "", "Freq", "Time", "Type", "Important \"To\" or \"For\"" };
            double[] indents = { .5, .75, 5.3, 5.6, 5.95, 6.75 };

            //headers
            output.drawY -= .1;
            for (int i = 0; i < nCols; i++)
            {
                output.DrawText(output.boldFont, output.fontSize, indents[i], output.drawY, headers[i]);
            }
            output.drawY += .13; output.appendSectionBreak();
            output.drawY -= PdfOutput.itemSpacing;

            indents = new double[] { .5, .75, 5.38, 5.73, 6.05, 6.75 };
            List <def_Items> itms = formsRepo.GetSectionItems(sct);

            // Values
            for (int row = 0; row < itms.Count; row++)
            {
                def_Items       itm        = itms[row];
                def_ItemResults itmResults = formsRepo.GetItemResultByFormResItem(formResultId, itm.itemId);
                formsRepo.GetItemResultsResponseVariables(itmResults);
                foreach (def_ResponseVariables rv in itmResults.def_ResponseVariables)
                {
                    rv.def_ItemVariables = formsRepo.GetItemVariableById(rv.itemVariableId);
                }

                output.drawY -= .1;
                for (int col = 0; col < nCols; col++)
                {
                    string s = "ERROR";
                    switch (col)
                    {
                    case 0:
                        s = (row + 1).ToString();
                        break;

                    case 1:
                        s = itm.label;
                        break;

                    case 2:
                    case 3:
                    case 4:
                        s = null;
                        string suffix = SupportNeedsColumnSuffixes[col - 2];
                        try
                        {
                            //Debug.WriteLine("\titemvariableId= " + ivEnum.Current.itemVariableId);
                            s = itmResults.def_ResponseVariables.SingleOrDefault(rv => rv.def_ItemVariables.identifier.EndsWith(suffix)).rspValue;
                        }
                        catch (System.NullReferenceException ex)
                        {
                            Debug.Print("for itemId " + itm.itemId + ", could not find responseVariable linked to itemVariableIdentifier with suffix \"" + suffix + "\"");
                            Debug.Print("   NullReferenceException: " + ex.Message);
                        }
                        s = String.IsNullOrEmpty(s) ? "N/A" : s;
                        break;

                    case 5:
                        s = String.Empty;
                        break;
                    }
                    output.DrawText(output.contentFont, output.fontSize, indents[col], output.drawY, s);
                }
                output.drawY -= PdfOutput.itemSpacing * 2.5;
                if (output.drawY < 1)
                {
                    output.appendPageBreak();
                }
            }

            output.drawY -= .1;
            output.DrawText(output.boldFont, output.fontSize, indents[1], output.drawY, "Page Notes:");
            output.drawY -= PdfOutput.itemSpacing * 4;
            if (output.drawY < 1)
            {
                output.appendPageBreak();
            }
        }
        public ActionResult GoAction(FormCollection formCollection)
        {
            string      recId             = formCollection["recId"];
            string      paramFormResultId = formCollection["sisId"];
            string      paramFormId       = formCollection["formId"];
            string      category          = formCollection["CategoryID"];
            SearchModel model             = new SearchModel();

            if (SessionHelper.SessionForm == null)
            {
                // return RedirectToAction("Index", "Search", null);
                SessionHelper.SessionForm = new SessionForm();
            }
            SessionForm sf = SessionHelper.SessionForm;

            if (String.IsNullOrWhiteSpace(category))
            {
                return(RedirectToAction("Index", "Search"));
            }
            else if (category.ToLower().Equals("edit") && model.edit)
            {
                // retrieve and set SessionForm params
                sf.formId       = Convert.ToInt32(paramFormId);
                sf.formResultId = Convert.ToInt32(paramFormResultId);

                def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId);

                if (!formResult.locked || (formResult.locked && model.editLocked))
                {
                    // get the sectionId of the first section of the first part based on the formId
                    def_Forms frm = formsRepo.GetFormById(sf.formId);
                    def_Parts prt = formsRepo.GetFormParts(frm)[0];
                    sf.partId       = prt.partId;
                    Session["part"] = prt.partId;
                    def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.EDIT, "Initiate editing of assessment.");
                    }
                    return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() }));
                }
            }
            else if (category.ToLower().Equals("review"))
            {
                // retrieve and set SessionForm params
                sf.formId       = Convert.ToInt32(paramFormId);
                sf.formResultId = Convert.ToInt32(paramFormResultId);

                def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId);

                if (model.editLocked)
                {
                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.REVIEW, "Assessment accessed for review.");
                    }

                    if (model.unlock == true)
                    {
                        formsRepo.LockFormResult(formResult.formResultId);
                    }

                    if (formResult.reviewStatus != (int)ReviewStatus.REVIEWED && formResult.reviewStatus != (int)ReviewStatus.APPROVED && formResult.reviewStatus != (int)ReviewStatus.PRE_QA)
                    {
                        def_FormResults preQAcopy = AssessmentCopy.CopyAssessment(formsRepo, formResult.formResultId);

                        if (WebServiceActivity.IsWebServiceEnabled())
                        {
                            WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.REVIEW, "formResultId=" + preQAcopy.formResultId.ToString());
                        }
                    }

                    ReviewStatus.ChangeStatus(formsRepo, formResult, ReviewStatus.REVIEWED, "Initiate review of assessment");

                    // get the sectionId of the first section of the first part based on the formId
                    def_Forms frm = formsRepo.GetFormById(sf.formId);
                    def_Parts prt = formsRepo.GetFormParts(frm)[0];
                    sf.partId       = prt.partId;
                    Session["part"] = prt.partId;
                    def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];


                    return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() }));
                }
            }
            else if (category.ToLower().Equals("approve"))
            {
                // retrieve and set SessionForm params
                sf.formId       = Convert.ToInt32(paramFormId);
                sf.formResultId = Convert.ToInt32(paramFormResultId);

                def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId);

                if (model.editLocked)
                {
                    ReviewStatus.ChangeStatus(formsRepo, formResult, ReviewStatus.APPROVED, "Approve review of assessment");

                    if (WebServiceActivity.IsWebServiceEnabled())
                    {
                        WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.APPROVE, "formResultId=" + formResult.formResultId.ToString());
                    }
                }
            }
            else if (category.ToLower().Equals("create"))
            {
                if (model.create == true)
                {
                    string          formId = String.IsNullOrEmpty(paramFormId) ? "1" : paramFormId;
                    def_FormResults frmRes = FormResults.CreateNewFormResultFull(formId,
                                                                                 SessionHelper.LoginStatus.EnterpriseID.ToString(),
                                                                                 SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString(),
                                                                                 recId,
                                                                                 SessionHelper.LoginStatus.UserID.ToString()
                                                                                 );
                    string strFormResultId = String.Empty;
                    try
                    {
                        int formRsltId = formsRepo.AddFormResult(frmRes);
                        strFormResultId = formRsltId.ToString();
                        Debug.WriteLine("GoAction create FormResultId strFormResultId:" + strFormResultId);
                    }
                    catch (Exception excptn)
                    {
                        Debug.WriteLine("GoAction Defws.CreateNewFormResultFull formsRepo.AddFormResult  exception:" + excptn.Message);
                        Debug.WriteLine("   GoAction formId:" + formId
                                        + "   entId: " + SessionHelper.LoginStatus.EnterpriseID.ToString()
                                        + "   GroupId: " + SessionHelper.LoginStatus.appGroupPermissions[0].groupPermissionSets[0].GroupID.ToString()
                                        + "   recId: " + recId.ToString()
                                        + "   UserId: " + SessionHelper.LoginStatus.UserID.ToString()
                                        );
                    }

                    if ((!String.IsNullOrEmpty(strFormResultId)) && !String.IsNullOrEmpty(recId))
                    {
                        int intRecId;

                        if (int.TryParse(recId, out intRecId))
                        {
                            using (var context = DataContext.getSisDbContext())
                            {
                                // Contact tempContact = new Contact();
                                Contact tempContact = (from c in context.Contacts
                                                       where c.ContactID == intRecId
                                                       select c).FirstOrDefault();

                                // Address tempAddress = new Address();
                                Address tempAddress = (from a in context.Addresses
                                                       where (a.ContactID == tempContact.ContactID) &&
                                                       (a.AddressType == "R")
                                                       select a).FirstOrDefault();

                                Dictionary <string, string> responsesByIdentifier = new Dictionary <string, string>();
                                responsesByIdentifier.Add("sis_cl_first_nm", tempContact.FirstName);
                                responsesByIdentifier.Add("sis_cl_last_nm", tempContact.LastName);

                                if (tempAddress != null)
                                {
                                    responsesByIdentifier.Add("sis_cl_addr_line1", tempAddress.Address1);
                                    responsesByIdentifier.Add("sis_cl_city", tempAddress.City);
                                    responsesByIdentifier.Add("sis_cl_st", tempAddress.StateCode);
                                    responsesByIdentifier.Add("sis_cl_zip", tempAddress.Zip);
                                }

                                string msg = formsRepo.CreateNewResponseValues(strFormResultId, responsesByIdentifier);
                                Debug.WriteLine("GoAction CreateNewResponseValues strFormResultId: " + strFormResultId + "    msg: " + msg);
                            }
                        }

                        // Retrieve and set SessionForm params
                        sf.formId       = 1; // Temporary
                        sf.formResultId = Convert.ToInt32(strFormResultId);

                        // Get the sectionId of the first section of the first part based on the formId
                        def_Forms frm = formsRepo.GetFormById(sf.formId);
                        def_Parts prt = formsRepo.GetFormParts(frm)[0];
                        sf.partId       = prt.partId;
                        Session["part"] = prt.partId;
                        def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

                        return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() }));
                    }
                }
            }
            else if (category.ToLower().Equals("delete"))
            {
                if (model.delete == true)
                {
                    formsRepo.FormResultDeleteLogically(Convert.ToInt32(paramFormResultId));

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.DELETE, "Delete assessment.");
                    }


                    if (ventureMode == false && WebServiceActivity.IsWebServiceEnabled())
                    {
                        WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.DELETE, "formResultId=" + paramFormResultId);
                        def_FormResults preQAcopy = ReviewStatus.GetLatestPreQACopy(formsRepo, Convert.ToInt32(paramFormResultId));

                        if (preQAcopy != null)
                        {
                            formsRepo.FormResultDeleteLogically(preQAcopy.formResultId);
                            WebServiceActivity.CallWebService(formsRepo, (int)WebServiceActivity.webServiceActivityFunctions.DELETE, "formResultId=" + preQAcopy.formResultId.ToString());
                        }
                    }
                }
            }
            else if (category.ToLower().Equals("lock"))
            {
                if (model.unlock == true)
                {
                    formsRepo.LockFormResult(Convert.ToInt32(paramFormResultId));
                }
            }
            else if (category.ToLower().Equals("unlock"))
            {
                if (model.unlock == true)
                {
                    formsRepo.UnlockFormResult(Convert.ToInt32(paramFormResultId));
                }
            }
            else if (category.ToLower().Equals("archive"))
            {
                if (model.archive == true)
                {
                    formsRepo.ArchiveFormResult(Convert.ToInt32(paramFormResultId));

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.ARCHIVE, "Archive assessment.");
                    }
                }
            }
            else if (category.ToLower().Equals("unarchive"))
            {
                if (model.archive == true)
                {
                    formsRepo.UnarchiveFormResult(Convert.ToInt32(paramFormResultId));

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.UNARCHIVE, "Unarchive assessment.");
                    }
                }
            }
            else if (category.ToLower().Equals("upload"))
            {
                def_FormResults fr = formsRepo.GetFormResultById(Convert.ToInt32(paramFormResultId));

                if (fr.formStatus == (byte)FormResults_formStatus.COMPLETED)
                {
                    SessionHelper.Write("uploadFormResultId", Convert.ToInt32(paramFormResultId));
                    return(RedirectToAction("UploadSingle", "DataSync"));
                }
            }
            else if (category.ToLower().Equals("undelete"))
            {
                if (model.undelete == true)
                {
                    formsRepo.FormResultUndelete(Convert.ToInt32(paramFormResultId));

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, Convert.ToInt32(paramFormResultId), (int)AccessLogging.accessLogFunctions.UNDELETE, "Undelete assessment.");
                    }
                }
            }
            else if (category.ToLower().Equals("planning") && model.edit)
            {
                // retrieve and set SessionForm params
                sf.formId       = Convert.ToInt32(paramFormId);
                sf.formResultId = Convert.ToInt32(paramFormResultId);

                def_FormResults formResult = formsRepo.GetFormResultById(sf.formResultId);

                if (!formResult.locked || (formResult.locked && model.editLocked))
                {
                    // get the sectionId of the first section of the first part based on the formId
                    def_Forms frm = formsRepo.GetFormById(sf.formId);
                    def_Parts prt = formsRepo.GetPartByFormAndIdentifier(frm, "Other");
                    sf.partId       = prt.partId;
                    Session["part"] = prt.partId;
                    def_Sections sct = formsRepo.GetSectionsInPart(prt)[0];

                    if (ventureMode == false)
                    {
                        AccessLogging.InsertAccessLogRecord(formsRepo, sf.formResultId, (int)AccessLogging.accessLogFunctions.EDIT, "Initiate editing of interview planning.");
                    }
                    return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = sf.partId.ToString() }));
                }
            }

            return(RedirectToAction("Index", "Search"));
        }
Esempio n. 17
0
        protected void PrintSupportNeedsGraph(PdfOutput output, int ageInYears)
        {
            Debug.WriteLine("PrintSupportNeedsGraph() method.");

            new Assessments(formsRepo).UpdateAssessmentScores(formResults);

            def_Parts prt = formsRepo.GetPartByFormAndIdentifier(form, "Section 2. Supports Needs Index");

            formsRepo.GetPartSections(prt);
            int row = 0, nRows = prt.def_PartSections.Count();

            double[]      percentiles       = new double[nRows];
            string[][]    supNeedsTableVals = new string[nRows][];
            List <string> subscaleLabels    = new List <string>();

            Debug.WriteLine("     Print Part 3");
            foreach (def_PartSections ps in prt.def_PartSections)
            {
                // Debug.WriteLine("     ps.sectionId: " + ps.sectionId.ToString());
                def_Sections sct = formsRepo.GetSectionById(ps.sectionId);
                subscaleLabels.Add(sct.title);
                Debug.WriteLine("     sct.sectionId: " + sct.sectionId.ToString());


                //pull subscale scores from database
                string sctNumberLetter = sct.title.Substring(0, sct.title.IndexOf('.'));
                double totalRawScore   = getScoreResponse("scr_" + sctNumberLetter + "_raw");
                double standardScore   = getScoreResponse("scr_" + sctNumberLetter + "_std");
                double rawScoreAvg     = getScoreResponse("scr_" + sctNumberLetter + "_avg");
                double percentile      = getScoreResponse("scr_" + sctNumberLetter + "_pct");
                double confidenceLow   = Math.Max(0, standardScore - 1);
                double confidenceHigh  = standardScore + 1;

                percentiles[row] = percentile;
                string rowLabel = sct.title.Replace("ActivitiesHI", "");
                rowLabel = rowLabel.Replace("and Neighborhood", "...");
                supNeedsTableVals[row] = new string[] {
                    rowLabel,
                    (form.formId == 1) ? totalRawScore.ToString() : String.Format("{0:0.##}", rawScoreAvg),
                    standardScore.ToString(),
                    percentile.ToString(),
                    confidenceLow + "-" + confidenceHigh
                };

                row++;
            }

            //pull overall scores from database
            double totalRawScoreTotal       = getScoreResponse("scr_total_rawscores_all_SIS_sections");
            double standardScoreTotal       = getScoreResponse("scr_standard_score_total");
            double compositeIndex           = getScoreResponse("scr_support_needs_index");
            double compositePercentile      = getScoreResponse("scr_sni_percentile_rank");
            double totalRating              = getScoreResponse("scr_total_rating");
            double meanRating               = Math.Round((double)totalRating / 7, 2); //usd only for SIS-C reports

            AppendPartHeader(output, "Support Needs Profile - Graph");

            output.appendWrappedText("The graph provides a visual presentation of the six life activity areas from section 2. ", .5, 7.5);

            output.drawY -= .1;
            output.appendWrappedText("The graph reflects the pattern and intensity of the individual’s level of support. "
                                     + "The intent of the graph is to provide an easy means to prioritize the life activity areas in consideration "
                                     + "of setting goals and developing the Individual Support Plan. ", .5, 7.5);

            output.drawY -= .15;

            if (options[OptionKey.includeScores])
            {
                output.appendSimpleTable(
                    new string[] { "Activities Subscale", (form.formId == 1) ? "Total Raw Score" : "Average Raw Score",
                                   "Standard Score", "Percentile", "Confidence Interval (95%)" },
                    supNeedsTableVals,
                    new double[] { 0, .35, .35, .3, .35 });
                output.drawY -= PdfOutput.itemSpacing;

                if (form.identifier.Equals("SIS-A"))
                {
                    //for SIS-A, add a row to the bottom of the table, with totals
                    output.DrawLine(.75, output.drawY + .05, 7.75, output.drawY + .05, .01);
                    output.appendSimpleTable(
                        new string[] { "Total:",
                                       totalRawScoreTotal.ToString(),
                                       standardScoreTotal.ToString(), "", "" },
                        new string[0][],
                        new double[] { 0, .35, .35, .3, .35 },
                        new double[] { .08, .35, .35, .3, .35 }
                        );

                    output.drawY -= .2;
                }
                else
                {
                    //for SIS-C
                    output.appendItem("Overall Mean Rating", String.Format("{0:0.##}", meanRating), 2);
                }

                output.appendItem("SIS Support Needs Index", compositeIndex.ToString(), 2);
                output.appendItem("Percentile", compositePercentile.ToString(), 2);
                output.drawY -= PdfOutput.itemSpacing;
            }

            //AppendPartHeader(output, "Support Needs Profile");
            AppendReportChart(output, subscaleLabels.ToArray(), percentiles, compositePercentile);

            if (!options[OptionKey.includeScores])
            {
                return;
            }

            if (form.identifier.Equals("SIS-A"))
            {
                Debug.WriteLine("     Print Part 4");
                prt = formsRepo.GetPartByFormAndIdentifier(form, "Section 3. Supplemental Protection and Advocacy Scale");
                formsRepo.GetPartSections(prt);
                List <def_Sections> scts   = formsRepo.GetSectionsInPart(prt);
                def_Sections        proSct = scts[0];
                if (proSct == null)
                {
                    throw new Exception("could not find any sections in part \"Section 3. Supplemental Protection and Advocacy Scale\"");
                }

                List <def_Items> proItms = formsRepo.GetSectionItems(proSct);  // getItemsInSection(proSct);
                // RRB 3/17/15 - this is hokey, but not sure how else to do it at this point w/o the SectionItems.
                //                  should be checking SectionItems.subSectionId != null
                // Prune out the subSections (this is
                for (int i = 0; i < proItms.Count; i++)
                {
                    if (proItms[i].itemId == 1)
                    {
                        proItms.Remove(proItms[i]);
                    }
                }

                int        nProItms        = proItms.Count();
                string[][] supProTableVals = new string[nProItms][];
                for (int i = 0; i < nProItms; i++)
                {
                    def_Items itm      = proItms[i];
                    int       rawScore = 0;
                    // def_ItemResults itmResults = itm.def_ItemResults.SingleOrDefault(ir => ir.formResultId == formResultId);
                    def_ItemResults itmResults = formsRepo.GetItemResultByFormResItem(formResultId, itm.itemId);
                    for (int j = 0; j < 3; j++)
                    {
                        string suffix   = SupportNeedsColumnSuffixes[j];
                        string rspValue = null;

                        try
                        {
                            rspValue = itmResults.def_ResponseVariables.SingleOrDefault(rv => rv.def_ItemVariables.identifier.EndsWith(suffix)).rspValue;
                        }
                        catch (System.NullReferenceException ex)
                        {
                            Debug.Print("for itemId " + itm.itemId + ", could not find responseVariable linked to itemVariableIdentifier with suffix \"" + suffix + "\"");
                        }

                        try
                        {
                            rawScore += Int16.Parse(rspValue);
                        }
                        catch (Exception ex)
                        {
                            Debug.Print("could not parse integer from response value \"" + rspValue + "\"");
                        }
                    }

                    supProTableVals[i]    = new string[2];
                    supProTableVals[i][0] = itm.label;
                    supProTableVals[i][1] = rawScore.ToString();
                }

                output.drawY -= PdfOutput.itemSpacing;
                AppendPartHeader(output, "Section 3: Supplemental Protection and Advocacy Scale");
                output.appendSimpleTable(new string[] { "Protection and Advocacy Activities", "Raw Score" }, supProTableVals, new double[] { 0, .2 });

                output.drawY -= .2;
                output.appendWrappedText("The support needs profile reflects the pattern and intensity of the "
                                         + "individual’s support. The information provided in sections 1, 2, and 3, can be beneficial "
                                         + "in the development of the individual’s support plan.", .5, 7.5);
            }
        }
Esempio n. 18
0
        public ActionResult ShowEligibility()
        {
            if (!SessionHelper.IsUserLoggedIn)
            {
                return(RedirectToAction("Index", "Account", null));
            }

            if (SessionHelper.SessionForm == null)
            {
                SessionHelper.SessionForm = new SessionForm();
            }

            // retrieve and set SessionForm params
            string     formIdent = "CA-ADAP-DASHBOARD", entName = "California";
            def_Forms  frm = formsRepo.GetFormByIdentifier(formIdent);
            Enterprise ent = new AuthenticationClient().GetEnterpriseByName(entName);

            if (frm == null)
            {
                return(Content("Could not find form with identifier \"" + formIdent + "\""));
            }

            if (ent == null)
            {
                return(Content("Could not find enterprise with name \"" + entName + "\""));
            }

            //  Get the FormResult to get the subject of the current Application
            def_FormResults fr = formsRepo.GetFormResultById(SessionHelper.SessionForm.formResultId);

            if (fr == null)
            {
                return(Content("Could not find the current Application  \"" + SessionHelper.SessionForm.formResultId.ToString() + "\""));
            }

            // Get the Eligibility Form for the subject
            IEnumerable <def_FormResults> frElgList = formsRepo.GetFormResultsByFormSubject(frm.formId, fr.subject);
            def_FormResults frElg = null;

            if ((frElgList == null) || frElgList.Count <def_FormResults>() == 0)
            {
                mLogger.Debug("Couldn't find a current FormResult for Eligibility.  Create one.");
                frElg = new def_FormResults()
                {
                    formId               = frm.formId,
                    formStatus           = 0,
                    sessionStatus        = 0,
                    dateUpdated          = DateTime.Now,
                    deleted              = false,
                    locked               = false,
                    archived             = false,
                    EnterpriseID         = ent.EnterpriseID,
                    GroupID              = fr.GroupID, // User the same Enrollment Center
                    subject              = fr.subject,
                    interviewer          = fr.interviewer,
                    assigned             = fr.assigned,
                    training             = false,
                    reviewStatus         = 0,
                    statusChangeDate     = DateTime.Now,
                    LastModifiedByUserId = fr.LastModifiedByUserId
                };

                AuthenticationClient authClient = new AuthenticationClient();
                var groupIds = authClient.GetGroupsInUserPermissions(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.UserID).Select(x => x.GroupID);
                var groupId  = groupIds.FirstOrDefault();

                Dictionary <string, string> uasItemDictionary = new Dictionary <string, string>();
                var uasData = authClient.GetUser(fr.subject.Value);

                var adapId = authClient.GetExistingAdapIdentifier(uasData.UserID, uasData.EnterpriseID);

                // ADAP ID
                if (!String.IsNullOrWhiteSpace(adapId))
                {
                    uasItemDictionary.Add("C1_MemberIdentifier_item", adapId);
                }

                Applications appl = new Applications(formsRepo);

                //Populate from UAS
                //Populate items where Source = UAS in json file
                frElg = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, groupId, uasData.UserID, frm.formId, uasItemDictionary);

                int newFrmRsltId = formsRepo.AddFormResult(frElg);
                mLogger.Debug("New Eligibility FormResult created: {0}", newFrmRsltId);
            }
            else
            {
                frElg = frElgList.First <def_FormResults>();
            }


            SessionHelper.SessionForm.formId         = frElg.formId;
            SessionHelper.SessionForm.formResultId   = frElg.formResultId;
            SessionHelper.SessionForm.formIdentifier = formIdent;
            // SessionHelper.LoginStatus.EnterpriseID = ent.EnterpriseID;


            def_Parts prt = formsRepo.GetFormParts(frm)[0];

            SessionHelper.SessionForm.partId = prt.partId;
            Session["part"] = prt.partId.ToString();
            def_Sections sct = formsRepo.GetSectionsInPart(prt)[1];

            Session["section"] = sct.sectionId.ToString();

            return(RedirectToAction("Template", "Results", new { sectionId = sct.sectionId.ToString(), partId = SessionHelper.SessionForm.partId.ToString() }));
        }
Esempio n. 19
0
        protected void PrintSupplementalQuestions(PdfOutput output)
        {
            def_Parts part = formsRepo.GetPartByFormAndIdentifier(form, "Supplemental Questions");

            AppendPartHeader(output, part.identifier);

            def_Sections topSct = formsRepo.GetSectionsInPart(part).FirstOrDefault();

            if (topSct == null)
            {
                throw new Exception("not sections found in part with partId " + part.partId);
            }

            List <def_Sections> sectionList = new List <def_Sections>();

            formsRepo.SortSectionItems(topSct);
            foreach (def_SectionItems sctnItm in topSct.def_SectionItems)
            {
                if (sctnItm.display == false)
                {
                    continue;
                }
                def_Sections subSctns = formsRepo.GetSubSectionById(sctnItm.subSectionId);// sctnItm.def_SubSections.def_Sections;
                sectionList.Add(subSctns);
            }

            int  grayCount          = 0;
            bool showWhiteQuestions = true;

            foreach (def_Sections sct in sectionList)
            {
                formsRepo.SortSectionItems(sct);
                foreach (def_SectionItems si in sct.def_SectionItems)
                {
                    if (si.display == false)
                    {
                        continue;
                    }

                    //if this is a "gray" question... (high-level questions pertaining to a set of "white" questions)
                    if (si.subSectionId == null)
                    {
                        grayCount++;
                        if (grayCount > 1)
                        {
                            output.drawY -= .5;
                        }
                        def_Items         itm = si.def_Items;
                        def_ItemVariables iv  = itm.def_ItemVariables.FirstOrDefault();
                        if (iv == null)
                        {
                            throw new Exception("no item variable for question with itemId " + si.itemId);
                        }
                        def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);//iv.def_ResponseVariables.FirstOrDefault();
                        if (rv == null)
                        {
                            continue;
                        }

                        //don't show the white questions if the response value is false
                        if (iv.baseTypeId == 1 && (rv.rspValue.ToLower().Equals("false") || rv.rspValue.Equals("0")))
                        {
                            showWhiteQuestions = false;
                        }
                        else
                        {
                            showWhiteQuestions = true;
                        }

                        if (output.drawY < .5)
                        {
                            output.appendPageBreak();
                        }

                        if (!itm.label.Equals("Page Notes"))
                        {
                            double y = output.drawY;
                            output.appendWrappedText(grayCount + ".", .8, 6, output.boldFont);
                            output.drawY = y;
                        }
                        output.appendWrappedText(itm.label, 1, 7, output.boldFont);
                        output.appendWrappedText(GetSupplementalResponseText(iv, rv), 1.5, 6, output.boldFont);
                        output.drawY -= PdfOutput.itemSpacing;
                    }

                    // if this is a "white" question-set
                    else
                    {
                        if (!showWhiteQuestions)
                        {
                            continue;
                        }
                        foreach (def_SectionItems ssi in si.def_SubSections.def_Sections.def_SectionItems)
                        {
                            def_Items itm = ssi.def_Items;
                            if (itm == null)
                            {
                                throw new Exception("no item for setionItems with sectionItemId " + ssi.sectionItemId);
                            }
                            def_ItemVariables iv = itm.def_ItemVariables.FirstOrDefault();
                            if (iv == null)
                            {
                                throw new Exception("no item variable for item with itemId " + itm.itemId);
                            }
                            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);

                            try
                            {
                                output.appendWrappedText(itm.label, 1.1, 6);
                            }
                            catch (ApplicationException e)
                            {
                                string msg = "Exception appending label \"" +
                                             itm.label + "\" for item with itemId " + itm.itemId + "\nchars:";
                                foreach (char c in itm.label.ToCharArray())
                                {
                                    msg += " " + c + "(" + ((int)c) + ")";
                                }
                                throw new Exception(msg, e);
                            }

                            output.appendWrappedText(GetSupplementalResponseText(iv, rv), 1.5, 6);
                            output.drawY -= PdfOutput.itemSpacing;
                        }
                    }
                }
            }
        }