private void PrintGenericSection(PdfOutput output, def_Sections section, int indentLevel) { output.appendSectionBreak(); double indent = .5 + labelIndent * (indentLevel - 1); output.appendWrappedText(section.identifier, indent, 8 - indent, 12); output.drawY -= .2; formsRepo.GetSectionItems(section); foreach (def_SectionItems si in section.def_SectionItems) { if (si.subSectionId.HasValue) { PrintGenericSection(output, formsRepo.GetSubSectionById(si.subSectionId.Value), indentLevel + 1); } else { def_Items itm = formsRepo.GetItemById(si.itemId);//si.def_Items; indent = labelIndent * indentLevel; output.appendWrappedText(itm.label, indent, 8 - indent, output.boldFont); foreach (def_ItemVariables iv in itm.def_ItemVariables) { def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId); string s = (rv == null) ? "N/A" : rv.rspValue; indent = valueIndent + labelIndent * (indentLevel - 1); output.appendWrappedText(iv.identifier + ": " + s, indent, 8 - indent); } output.drawY -= .1; } } }
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() })); }
private void printD5AndD6(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { Dictionary <string, string> responses = GetResponsesByItemVariableIdentifier(sct); List <string> yesLabels = new List <string>(); foreach (string ivIdent in responses.Keys) { if (responses[ivIdent].Equals("Yes")) { def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(ivIdent); def_Items itm = formsRepo.GetItemById(iv.itemId); yesLabels.Add(itm.label); } } if (yesLabels.Count > 0) { string rsp = yesLabels[0]; for (int i = 1; i < yesLabels.Count; i++) { rsp += ", " + yesLabels[i]; } printGenericSectionHeader(sct, sectionLabelIndent); output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); output.drawY -= .1; } }
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() })); }
//ADAP_F3 protected void printF3(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { printGenericSectionHeader(sct, sectionLabelIndent); Dictionary <string, string> responses = GetResponsesByItemVariableIdentifierThroughLookupTables(sct); foreach (string ivIdent in responses.Keys) { if (String.IsNullOrWhiteSpace(responses[ivIdent])) { continue; } def_Items itm = formsRepo.GetItemByIdentifier(ivIdent + "_item"); itm = formsRepo.GetItemById(itm.itemId); //Get the version of the item as it appears on the form. if (ivIdent.EndsWith("IncomeProof") || ivIdent.EndsWith("EmployerForm")) { appendAdapAttachmentLink(itm.label, ivIdent, itemLabelIndent, responseIndent); } else { appendItemLabelAndResponses(itm, itemLabelIndent, responseIndent, responses); } } }
private void printH5(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { Dictionary <string, string> responses = GetResponsesByItemVariableIdentifier(sct); //if the client is female... if (responses["ADAP_D8_CurrGenderDrop"].Equals("Female")) { string rsp = responses["ADAP_H5_PregnantOpt"]; double drawY = output.drawY; printGenericSectionHeader(sct, sectionLabelIndent); output.drawY = drawY; output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); output.drawY -= .1; //if client is female and pregnant if (responses["ADAP_H5_PregnantOpt"].Equals("Yes")) { string label = formsRepo.GetItemByIdentifier("ADAP_H5_PregnantDue_item").label; rsp = responses["ADAP_H5_PregnantDue"]; double itemLabelHeight = output.appendWrappedText(label, itemLabelIndent, responseIndent - itemLabelIndent, output.boldFont); double drawYBelowItemLabel = output.drawY; output.drawY += itemLabelHeight; output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); output.drawY = Math.Min(drawYBelowItemLabel, output.drawY - .05); } } //if the client isn't female, no code runs here (meaning this section is ommitted from the report) }
private void tryPrintSingleLineLabel(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { Dictionary <string, string> responses = GetResponsesByItemVariableIdentifier(sct); List <string> positiveResponsesItemVariables = responses.Where(pair => pair.Value.Equals("Yes")).Select(pair => pair.Key).ToList(); //if there is exactly one response for this section, print it on the same line as the section header if (positiveResponsesItemVariables.Count == 1) { string ivIdent = positiveResponsesItemVariables.First(); def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(ivIdent); def_Items itm = formsRepo.GetItemById(iv.itemId); string label = itm.label; double drawY = output.drawY; printGenericSectionHeader(sct, sectionLabelIndent); output.drawY = drawY; output.appendWrappedText(label, responseIndent, 8 - responseIndent); output.drawY -= .1; } //otherewise, delegate to the standard section printing else { base.PrintGenericSection(output, sct, indentLevel, responses); } }
//ADAP_M1 private void printM1(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { printGenericSectionHeader(sct, sectionLabelIndent); string month = GetSingleResponse("ADAP_M1_Month"); string year = GetSingleResponse("ADAP_M1_Year"); string city = GetSingleResponse("ADAP_M1_DiagnosisLoc"); //try and convert the month response from number to month name, //and just leave it as the raw response if unsuccessful try { month = new System.Globalization.DateTimeFormatInfo() .GetMonthName(Convert.ToInt32(month)).ToString(); } catch (Exception e) { } string text = (String.IsNullOrWhiteSpace(month) ? "[no month entered]" : month) + ", " + (String.IsNullOrWhiteSpace(year) ? "[no year entered]" : year) + ", " + (String.IsNullOrWhiteSpace(city) ? "[no city entered]" : city); output.appendWrappedText(text, itemLabelIndent, 8 - itemLabelIndent); output.drawY -= .1; }
private int getCustomOrder(def_Sections sct) { if (customSectionOrderByIdentifiers.Contains(sct.identifier)) { return(customSectionOrderByIdentifiers.IndexOf(sct.identifier)); } return(-1); }
protected virtual void PrintGenericSection(PdfOutput output, def_Sections section, int indentLevel) { //pull out all responses for items in this section (doesn't include items in subsections) Debug.WriteLine("PrintGenericSection section: " + section.identifier); Dictionary <string, string> responsesByItemVariable = GetResponsesByItemVariableIdentifier(section); PrintGenericSection(output, section, indentLevel, responsesByItemVariable); }
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")); } }
public static TemplateAdapNavMenu getAdapNavMenuModel(SessionForm sf, IFormsRepository formsRepo) { TemplateAdapNavMenu result = new TemplateAdapNavMenu(); result.sctId = sf.sectionId; def_Sections currentSection = formsRepo.GetSectionById(result.sctId); if (currentSection != null) { result.currentSectionTitle = currentSection.title; } result.sectionIds = new Dictionary <string, int>(); result.sectionTitles = new Dictionary <string, string>(); foreach (Assmnts.def_Sections sct in getTopLevelSectionsInForm(sf.formId, formsRepo)) { //Assmnts.def_Sections sct = formsRepo.GetSectionByIdentifier(identifier); //if (sct == null) //{ // throw new Exception("could not find section with identifier \"" + identifier + "\""); //} result.sectionIds.Add(sct.identifier, sct.sectionId); result.sectionTitles.Add(sct.identifier, sct.title); } result.adapFormId = sf.formResultId; result.firstName = String.Empty; Assmnts.def_ResponseVariables firstNameRV = formsRepo.GetResponseVariablesByFormResultIdentifier(result.adapFormId, "ADAP_D1_FirstName"); if (firstNameRV != null) { result.firstName = firstNameRV.rspValue; } result.lastName = String.Empty; Assmnts.def_ResponseVariables lastNameRV = formsRepo.GetResponseVariablesByFormResultIdentifier(result.adapFormId, "ADAP_D1_LastName"); if (lastNameRV != null) { result.lastName = lastNameRV.rspValue; } result.ActiveUserName = SessionHelper.LoginStatus.FirstName + " " + SessionHelper.LoginStatus.LastName; result.adapPartId = sf.partId; result.access = UAS.Business.UAS_Business_Functions.hasPermission(0, "RptsExpts"); result.readOnly = sf.readOnlyMode; return(result); }
private void printD8(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { //append the "current gender" response in the same line as the section header double drawY = output.drawY; printGenericSectionHeader(sct, sectionLabelIndent); def_ItemVariables ivCurrGender = formsRepo.GetItemVariableByIdentifier("ADAP_D8_CurrGenderDrop"); string rspCurrGender = GetResponseThroughLookupTables(formResultId, ivCurrGender.def_Items, ivCurrGender); if (!String.IsNullOrWhiteSpace(rspCurrGender)) { output.drawY = drawY; output.appendWrappedText(rspCurrGender, responseIndent, 8 - responseIndent); output.drawY -= .1; } //if applicable, append the "gender at birth" label and response on one line def_Items itmBirthGenderLabel = formsRepo.GetItemByIdentifier("ADAP_D8_BirthGenderLabel_item"); def_ItemVariables ivBirthGender = formsRepo.GetItemVariableByIdentifier("ADAP_D8_BirthGenderDrop"); string rspBirthGender = GetResponseThroughLookupTables(formResultId, ivBirthGender.def_Items, ivBirthGender); if (!String.IsNullOrWhiteSpace(rspBirthGender)) { double itemLabelHeight = itmBirthGenderLabel == null ? 0 : output.appendWrappedText(itmBirthGenderLabel.label, itemLabelIndent, responseIndent - itemLabelIndent, output.boldFont); double drawYBelowItemLabel = output.drawY; output.drawY += itemLabelHeight; output.appendWrappedText(rspBirthGender, responseIndent, 8 - responseIndent); output.drawY = Math.Min(drawYBelowItemLabel, output.drawY - .05); } //Dictionary<string, string> responses = GetResponsesByItemVariableIdentifierThroughLookupTables(sct); //foreach (string prefix in new string[] { "ADAP_D8_CurrGender", "ADAP_D8_BirthGender" }) //{ // string ivIdent = prefix + "Drop"; // string labelItemIdent = prefix + "Label_item"; // def_Items labelItm = formsRepo.GetItemByIdentifier(labelItemIdent); // string rsp = responses.ContainsKey( ivIdent ) ? responses[ivIdent] : ""; // //append item label (if applicable), without actually moving drawY down the page // double itemLabelHeight = labelItm == null ? 0 : // output.appendWrappedText(labelItm.label, itemLabelIndent, responseIndent - itemLabelIndent, output.boldFont); // double drawYBelowItemLabel = output.drawY; // output.drawY += itemLabelHeight; // output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); // output.drawY = Math.Min(drawYBelowItemLabel, output.drawY - .05); //} }
public static bool RunSingleSectionOneOffValidation(IFormsRepository formsRepo, FormCollection frmCllctn, int sectionId, out List <string> validationErrorMessages) { bool invalid = false; validationErrorMessages = new List <string>(); def_Sections sct = formsRepo.GetSectionById(sectionId); #region Sections 2,3: if the Frequency is greater than zero, then the Duration and Type of support must be greater than zero. if ("SIS-A 2A,SIS-A 2B,SIS-A 2C,SIS-A 2D,SIS-A 2E,SIS-A 2F,SIS-A 3".Split(',').ToList().Contains(sct.identifier)) { formsRepo.SortSectionItems(sct); foreach (def_SectionItems si in sct.def_SectionItems) { if (si.subSectionId == null) { def_ItemVariables ivFreq = si.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith("_Fqy")).FirstOrDefault(); if (ivFreq == null) { throw new Exception("could not find fequency itemVariable (with suffix \"_Fqy\") for item \"" + si.def_Items.identifier + "\""); } string rspFreq = frmCllctn[ivFreq.identifier]; //def_ResponseVariables rvFreq = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivFreq.itemVariableId); if (rspFreq != null && rspFreq.Trim().Length > 0 && Convert.ToInt16(rspFreq) > 0) { foreach (string suffix in new string[] { "_TOS", "_DST" }) { def_ItemVariables ivSuff = si.def_Items.def_ItemVariables.Where(iv => iv.identifier.EndsWith(suffix)).FirstOrDefault(); if (ivSuff == null) { throw new Exception("could not find itemVariable with suffix \"" + suffix + "\" for item \"" + si.def_Items.identifier + "\""); } string rspSuff = frmCllctn[ivSuff.identifier]; //def_ResponseVariables rvSuff = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivSuff.itemVariableId); if (rspSuff == null || rspSuff.Trim().Length == 0 || Convert.ToInt16(rspSuff) == 0) { invalid = true; validationErrorMessages.Add(si.def_Sections.title + ", " + si.def_Items.label + ": you entered a Frequency greater than zero, so Daily Support Time and Type of Support must also be greater than zero."); } } } } } } #endregion return(invalid); }
public static void updateSection1ScoresNoSave( IFormsRepository formsRepo, def_Forms frm, int formResultId) { def_FormResults fr = formsRepo.GetFormResultById(formResultId); int entId = fr.EnterpriseID.HasValue ? fr.EnterpriseID.Value : 0; string sectionIdentifierPrefix = frm.identifier; //"SIS-A" or "SIS-C" foreach (string shortSectionName in new string[] { "1A", "1B" }) { string sectionIdentifier = sectionIdentifierPrefix + " " + shortSectionName; // e.g. "SIS-A 1A" def_Sections sct = formsRepo.GetSectionByIdentifier(sectionIdentifier); if (sct == null) { throw new Exception("Could not find section with identifier \"" + sectionIdentifier + "\""); } int rawTotal = 0; foreach (def_SectionItems si in formsRepo.GetSectionItemsBySectionIdEnt(sct.sectionId, entId)) { def_ItemVariables rawScoreIv = formsRepo.GetItemVariablesByItemId(si.itemId) .Where(iv => iv.identifier.EndsWith("Support")).SingleOrDefault(); //e.g. "Q1A1_ExMedSupport" if (rawScoreIv != null) { def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, rawScoreIv.itemVariableId); if (rv != null && !String.IsNullOrWhiteSpace(rv.rspValue)) { int rawScore; if (Int32.TryParse(rv.rspValue, out rawScore)) { rawTotal += rawScore; } else { Debug.WriteLine("* * * Skipping item on updating section 1 scores: " + "Could not parse integer from response value \"{0}\" for itemVariable \"{1}\". (formResultID {2})", rv.rspValue, rawScoreIv.identifier, formResultId); } } } } UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_" + shortSectionName + "_raw_total", rawTotal); } }
protected string buildSectionHeaderText(def_Sections section) { string fixedIdentifier; if (sectionIdentifierPrefixToRemove != null && section.identifier.StartsWith(sectionIdentifierPrefixToRemove)) { fixedIdentifier = section.identifier.Substring(sectionIdentifierPrefixToRemove.Length); } else { fixedIdentifier = section.identifier; } return("(" + fixedIdentifier + ") " + section.title); }
private void tryPrintSingleLineResponse(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { Dictionary <string, string> responses = GetResponsesByItemVariableIdentifierThroughLookupTables(sct); //create a filtered set of responses, ignoring all emtpy or "no" responses Dictionary <string, string> filteredResponses = new Dictionary <string, string>(responses); foreach (string key in filteredResponses.Keys.ToList()) { if (filteredResponses[key].Trim().Length == 0) { filteredResponses.Remove(key); } } if (filteredResponses.Count > 1) { foreach (string key in filteredResponses.Keys.ToList()) { if (filteredResponses[key].Equals("No")) { filteredResponses.Remove(key); } } } //if there is exactly one filtered response for this section, print it on the same line as the section header if (filteredResponses.Count == 1) { //certain sections with long titles need the responses printed farther to the right in the report if (sct.identifier.EndsWith("M2") || sct.identifier.EndsWith("I2")) { responseIndent += 1.5; } string rsp = filteredResponses.Values.First(); double drawY = output.drawY; printGenericSectionHeader(sct, sectionLabelIndent); output.drawY = drawY; output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); output.drawY -= .1; } //otherewise, delegate to the standard section printing else { base.PrintGenericSection(output, sct, indentLevel, responses); } }
private static string valErrMsg(IFormsRepository formsRepo, string sectionIdentifier, int subsectionNumber, string subsectionIdentifier, string message) { def_Sections section = formsRepo.GetSectionByIdentifier(sectionIdentifier); if (section == null) { throw new Exception("Validation: Building one-off validation error message: could not find section with identifier \"" + sectionIdentifier + "\""); } def_Sections sub = formsRepo.GetSectionByIdentifier(subsectionIdentifier); if (sub == null) { throw new Exception("Validation: Building one-off validation error message: could not find section with identifier \"" + subsectionIdentifier + "\""); } return(section.title + ": " + subsectionNumber + ". " + sub.title + ": " + message); }
/// <summary> /// Saves an HTML FormCollection to the FormsRepository /// </summary> /// <param name="frmCllctn"></param> /// <param name="sectionId"></param> /// <param name="formResultId"></param> /// <returns></returns> public bool SaveFormCollection(FormCollection frmCllctn, int sectionId, int formResultId) { //for debugging runtime //DateTime startTime = DateTime.Now; Debug.WriteLine("*** SaveFormCollection sectionId: " + sectionId.ToString() + " formResultId: " + formResultId.ToString()); def_Sections sctn = formsRepo.GetSectionById(sectionId); if (sctn != null) { SaveSectionsRecursively(sctn, frmCllctn, formResultId); } // All responses are now in Entity Framework, so Save all the Entities to the Forms Repository formsRepo.Save(); return(true); }
public static SubscaleCatagory GetSisASubscaleCatagoryForSection(def_Sections sct) { if (sct == null) { throw new Exception("Could not find a subscale catagory for NULL section"); } string s = sct.title.Replace(" ", "").ToLower(); foreach (SubscaleCatagory option in getSisASubscaleCatagories()) { foreach (string numonic in option.getNumonics()) { if (s.Contains(numonic.ToString().ToLower())) { return(option); } } } throw new Exception("Could not find a subscale catagory for section with title \"" + sct.title + "\""); }
/// <summary> /// Saves User Data associated with a Section by processing Items and SubSections (unlimited nesting). /// </summary> /// <param name="sctn"></param> /// <param name="frmCllctn"></param> /// <param name="formResultId"></param> private void SaveSectionsRecursively(def_Sections sctn, FormCollection frmCllctn, int formResultId) { try { SaveSectionItems(sctn, frmCllctn, formResultId); } catch (Exception ex) { Debug.WriteLine(ex.Message); } // Process the subSections (if any) foreach (def_SectionItems sctnItm in sctn.def_SectionItems) { if (sctnItm.subSectionId.GetValueOrDefault() > 0) { SaveSectionsRecursively(formsRepo.GetSubSectionById(sctnItm.subSectionId), frmCllctn, formResultId); } } return; }
//ADAP_C3 private void printC3(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { printGenericSectionHeader(sct, sectionLabelIndent); Dictionary <string, string> responses = GetResponsesByItemVariableIdentifierThroughLookupTables(sct); for (int i = 1; i <= 2; i++) { string prefix = "ADAP_C3_Phone" + i + "_"; if (responses.ContainsKey(prefix + "Num") && !String.IsNullOrWhiteSpace(responses[prefix + "Num"])) { foreach (string shortIdent in new string[] { "Num", "Type", "MayMsgYN" }) { def_Items itm = formsRepo.GetItemByIdentifier(prefix + shortIdent + "_item"); itm = formsRepo.GetItemById(itm.itemId); //Get the version of the item as it appears on the form. appendItemLabelAndResponses(itm, itemLabelIndent, responseIndent, responses); } } } }
//* * * OT 2-26-16 this should be refactored so that all the responses for the formResult are pulled once, all at one time, using a CommonExport function protected Dictionary <string, string> GetResponsesByItemVariableIdentifier(def_Sections sct) { Dictionary <string, string> result = new Dictionary <string, string>(); foreach (def_Items itm in formsRepo.GetSectionItems(sct)) { formsRepo.GetItemVariables(itm); foreach (def_ItemVariables iv in itm.def_ItemVariables) { if (result.ContainsKey(iv.identifier)) { continue; } result.Add(iv.identifier, GetResponse(formResultId, itm, iv)); } } Debug.WriteLine("GetResponsesByItemVariableIdentifier: " + sct.identifier + " result.Count: " + result.Count.ToString()); return(result); }
//ADAP_D7 (preferred language) private void printD7(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { //append the one response in the same line as the section header //if the user responded with "other", show the text they entered into the "other" textbox double drawY = output.drawY; printGenericSectionHeader(sct, sectionLabelIndent); def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier("ADAP_D7_LangDrop"); string rsp = GetResponseThroughLookupTables(formResultId, iv.def_Items, iv); if (rsp.StartsWith("Other")) { rsp = GetSingleResponse("ADAP_D7_LangOther"); } if (!String.IsNullOrWhiteSpace(rsp)) { output.drawY = drawY; output.appendWrappedText(rsp, responseIndent, 8 - responseIndent); output.drawY -= .1; } }
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() })); }
/// <summary> /// Override of FormResultPdfReport.PrintGenericSection /// /// This will delegate to the special-case section printing methods above, or use the base PrintGenericSection implimentation /// </summary> /// <param name="output"></param> /// <param name="section"></param> /// <param name="indentLevel"></param> override protected void PrintGenericSection(PdfOutput output, def_Sections section, int indentLevel) { if (sectionsToSkip.Contains(section.identifier)) { Debug.WriteLine("AdapPdfReport.PrintGenericSection Skip it: " + section.identifier); return; } else if (specialCaseSections.ContainsKey(section.identifier)) { if (output.drawY < 1.5) { output.appendPageBreak(); } if (indentLevel < 2) { output.appendSectionBreak(); } double sectionLabelIndent = .5 + labelIndent * (indentLevel - 1); double itemLabelIndent = labelIndent * indentLevel; double responseIndent = valueIndent + labelIndent * (indentLevel - 1); //print section content using special case handler specialCaseSections[section.identifier].Invoke(section, indentLevel, sectionLabelIndent, itemLabelIndent, responseIndent); } else { //print section header and content generically, excluding application comments except in the "finalCert" section Dictionary <string, string> responsesByItemVariable = GetResponsesByItemVariableIdentifierThroughLookupTables(section); if (section.identifier != "ADAP_finalCert") { responsesByItemVariable.Remove("ADAP_Application_Comments_txt"); } Debug.WriteLine("AdapPdfReport.base.PrintGenericSection: " + section.identifier); base.PrintGenericSection(output, section, indentLevel, responsesByItemVariable); } }
private void printC1(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { printGenericSectionHeader(sct, sectionLabelIndent); string prefix = "ADAP_C1_"; //append some responses generically foreach (string shortIdent in new string[] { "Address", "MayContactYN" }) { appendItemLabelAndResponses(formsRepo.GetItemByIdentifier(prefix + shortIdent + "_item"), itemLabelIndent, responseIndent, GetResponsesByItemVariableIdentifierThroughLookupTables(sct)); } //append city,state,zip,county all in one line string combinedResponse = ""; foreach (string shortIdent in new string[] { "City", "State", "Zip", "County" }) { string response = GetSingleResponse(prefix + shortIdent); if (combinedResponse.Length > 0) { combinedResponse += ", "; } combinedResponse += String.IsNullOrWhiteSpace(response) ? "[No " + shortIdent + " entered]" : response; } double itemLabelHeight = output.appendWrappedText("City, State, Zip, County", itemLabelIndent, responseIndent - itemLabelIndent, output.boldFont); double drawYBelowItemLabel = output.drawY; output.drawY += itemLabelHeight; output.appendWrappedText(combinedResponse, responseIndent, 8 - responseIndent); output.drawY = Math.Min(drawYBelowItemLabel, output.drawY - .05); // append address proof with hyperlink to the attachment (if attachment exists) if (!String.IsNullOrWhiteSpace(GetSingleResponse("ADAP_C1_AddressProof"))) { appendAdapAttachmentLink(formsRepo.GetItemByIdentifier("ADAP_C1_AddressProof_item").label, "ADAP_C1_AddressProof", itemLabelIndent, responseIndent); } }
//ADAP_I3 protected void printI3(def_Sections sct, int indentLevel, double sectionLabelIndent, double itemLabelIndent, double responseIndent) { printGenericSectionHeader(sct, sectionLabelIndent); Dictionary <string, string> responses = GetResponsesByItemVariableIdentifier(sct); foreach (string ivIdent in responses.Keys) { if (String.IsNullOrWhiteSpace(responses[ivIdent])) { continue; } def_Items itm = formsRepo.GetItemByIdentifier(ivIdent + "_item"); if (ivIdent == "ADAP_I3_Invoice") { appendAdapAttachmentLink(itm.label, ivIdent, itemLabelIndent, responseIndent); } else { appendItemLabelAndResponses(itm, itemLabelIndent, responseIndent, responses); } } }
public ActionResult Validate(FormCollection frmCllctn, TemplateItems ti) { //save response from formCollection into the DB ResultsController rc = new ResultsController(formsRepo); rc.ControllerContext = ControllerContext; rc.Save(frmCllctn, ti); int formResultId = SessionHelper.SessionForm.formResultId; SessionHelper.SessionForm.sectionId = -1; //Run generic validation AdapValidationErrorsModel model = new AdapValidationErrorsModel(); model.navMenuModel = AJBoggs.Adap.Templates.TemplateMenus.getAdapNavMenuModel(SessionHelper.SessionForm, formsRepo); model.validationMessages = new List <string>(); model.missingItemVariablesBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >(); def_Forms frm = formsRepo.GetFormById(SessionHelper.SessionForm.formId); List <ValuePair> allResponses = CommonExport.GetDataByFormResultId(formResultId); SharedValidation sv = new SharedValidation(allResponses); bool invalid = sv.DoGenericValidation(formsRepo, model, frm); //transfer generic validation results to an ADAP-specific model model.titlesOfMissingSubsectionsBySectionByPart = new Dictionary <int, Dictionary <int, List <string> > >(); foreach (int prtId in model.missingItemVariablesBySectionByPart.Keys) { model.titlesOfMissingSubsectionsBySectionByPart.Add(prtId, new Dictionary <int, List <string> >()); foreach (int sctId in model.missingItemVariablesBySectionByPart[prtId].Keys) { def_Sections sct = formsRepo.GetSectionById(sctId); formsRepo.SortSectionItems(sct); List <int> ssSectionIds = new List <int>(); foreach (def_SectionItems si in sct.def_SectionItems.Where(si => si.subSectionId.HasValue)) { ssSectionIds.Add(formsRepo.GetSubSectionById(si.subSectionId.Value).sectionId); } model.titlesOfMissingSubsectionsBySectionByPart[prtId].Add(sctId, new List <string>()); foreach (string itemVariableIdent in model.missingItemVariablesBySectionByPart[prtId][sctId]) { //for each item variable identifier returned by generic validation, //lookup the corresponding subsection's title for display on the ADAP "validation errors" screen def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(itemVariableIdent); def_Items itm = iv == null ? null : iv.def_Items; def_SectionItems si = itm == null ? null : formsRepo.getSectionItemsForItem(itm).Where(sit => ssSectionIds.Contains(sit.sectionId)).FirstOrDefault(); def_Sections sub = si == null ? null : si.def_Sections; if (sub != null && !model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Contains(sub.title)) { model.titlesOfMissingSubsectionsBySectionByPart[prtId][sctId].Add(sub.title); } } } } //run CO-ADAP one-off validation if (AdapCOOneOffValidation.RunOneOffValidation(sv, model)) { invalid = true; } //return the validation errors screen if any errors were found //model.validationMessages could have some warnings even if no errors were found, in which case "invalid" would be false here if (invalid) { return(View("~/Views/COADAP/ValidationErrors.cshtml", model)); } //if no problems were found, or if warnings were found but no errors, return the next section in the application if (model.validationMessages.Count == 0) { model.validationMessages.Add("No errors were found"); } int sectionId = Convert.ToInt16(frmCllctn["navSectionId"]); return(rc.Template(sectionId, model.validationMessages)); }
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() })); }