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);
        }
Example #2
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);
            }
        }