request.ass = CreateObject("component", "components.general.assessments").init(); request.pat = CreateObject("component", "components.general.patients").init(); request.soc_wizard = CreateObject("component", "components.general.soc_wizard").init(); AssForm = request.ass.get_assess(url.ID, url.assid); GetP = request.pat.get_pat(url.ID); /* Keep basic inline markup for download/print; strip everything else */ function socAllowBasicHtml(required string raw) { var s = Trim(ToString(arguments.raw)); if (!Len(s)) { return ""; } s = REReplaceNoCase(s, "", "", "all"); s = REReplaceNoCase(s, "", "", "all"); s = REReplaceNoCase(s, "", "", "all"); s = REReplaceNoCase(s, "", "", "all"); s = Replace(s, "", "%%SOC_B%%", "all"); s = Replace(s, "", "%%/SOC_B%%", "all"); s = Replace(s, "", "%%SOC_I%%", "all"); s = Replace(s, "", "%%/SOC_I%%", "all"); s = REReplaceNoCase(s, "", "%%SOC_BR%%", "all"); s = REReplaceNoCase(s, "<[^>]*>", "", "all"); s = Replace(s, "%%SOC_B%%", "", "all"); s = Replace(s, "%%/SOC_B%%", "", "all"); s = Replace(s, "%%SOC_I%%", "", "all"); s = Replace(s, "%%/SOC_I%%", "", "all"); s = Replace(s, "%%SOC_BR%%", "
", "all"); return s; } if (_isPtSocDownload) { nwTitles = { "1": "History", "2": "Mental Status", "3": "Nutrition; Pain", "4": "ADLs", "5": "PT Assessment", "6": "Assessment", "7": "Vitals; Wounds" }; } else if (_isOtSocDownload) { nwTitles = { "1": "History", "2": "Mental Status", "3": "Nutrition; Pain", "4": "ADLs", "5": "OT Assessment", "6": "Assessment", "7": "Vitals; Wounds" }; } else { nwTitles = { "1": "History", "2": "Mental Status", "3": "Nutrition; Pain", "4": "ADLs", "5": "Vitals; Wounds", "6": "Assessment" }; } blockNums = []; if (singleNw > 0) { ArrayAppend(blockNums, singleNw); } else { blocksQ = request.soc_wizard.get_new_wizard_blocks(blocksLookupReason); if (blocksQ.recordcount GT 0) { seenNw = StructNew(); for (bi = 1; bi <= blocksQ.recordcount; bi++) { bn = Int(Val(blocksQ.new_wizard[bi])); if (bn GTE 1 AND bn LTE _maxWizardBlock) { seenNw[ToString(bn)] = true; } } for (bi = 1; bi <= _maxWizardBlock; bi++) { if (StructKeyExists(seenNw, ToString(bi))) { ArrayAppend(blockNums, bi); } } } if (ArrayLen(blockNums) EQ 0) { for (bi = 1; bi <= _maxWizardBlock; bi++) { ArrayAppend(blockNums, bi); } } } qaSections = []; totalQ = 0; for (si = 1; si <= ArrayLen(blockNums); si++) { nw = blockNums[si]; get_ques = request.soc_wizard.get_all_ques_ans_new_wizard( assessment_reason = assessmentReason, new_wizard = nw, view_mode = "wizard" ); if (get_ques.recordcount EQ 0 AND NOT useUrlAssessmentReason AND Left(assessmentReason, 1) EQ "3") { get_ques = request.soc_wizard.get_all_ques_ans_new_wizard( assessment_reason = lookupReason, new_wizard = nw, view_mode = "wizard" ); } if (get_ques.recordcount EQ 0) { continue; } qaItems = []; qaByQid = StructNew(); qaQidOrder = []; for (rowIdx = 1; rowIdx <= get_ques.recordcount; rowIdx++) { labelName = Trim(get_ques.answer_label[rowIdx]); if (!Len(labelName)) { continue; } qidKey = ""; if (ListFindNoCase(get_ques.columnList, "question_id") GT 0 AND Len(Trim(ToString(get_ques.question_id[rowIdx])))) { qidKey = Trim(ToString(get_ques.question_id[rowIdx])); } else if (ListFindNoCase(get_ques.columnList, "ques_id") GT 0 AND Len(Trim(ToString(get_ques.ques_id[rowIdx])))) { qidKey = Trim(ToString(get_ques.ques_id[rowIdx])); } if (!Len(qidKey)) { qidKey = "lbl_" & labelName; } if (!StructKeyExists(qaByQid, qidKey)) { qText = get_ques.questions[rowIdx]; if (ListFindNoCase(get_ques.columnList, "question_display") GT 0 AND Len(Trim(get_ques.question_display[rowIdx]))) { qText = get_ques.question_display[rowIdx]; } qIdentPrefix = ""; if (ListFindNoCase(get_ques.columnList, "ques_identifier_2") GT 0 AND Len(Trim(ToString(get_ques.ques_identifier_2[rowIdx])))) { qIdentPrefix = get_ques.ques_identifier_2[rowIdx]; } else if (ListFindNoCase(get_ques.columnList, "ques_identifier_display") GT 0 AND Len(Trim(get_ques.ques_identifier_display[rowIdx]))) { qIdentPrefix = get_ques.ques_identifier_display[rowIdx]; } else if (ListFindNoCase(get_ques.columnList, "ques_identifier") GT 0 AND Len(Trim(ToString(get_ques.ques_identifier[rowIdx])))) { qIdentPrefix = get_ques.ques_identifier[rowIdx]; } titleBefore = ""; if (ListFindNoCase(get_ques.columnList, "title_display") GT 0) { titleBefore = get_ques.title_display[rowIdx]; } else if (ListFindNoCase(get_ques.columnList, "title_2") GT 0) { titleBefore = get_ques.title_2[rowIdx]; } else if (ListFindNoCase(get_ques.columnList, "title") GT 0) { titleBefore = get_ques.title[rowIdx]; } savedAnswer = ""; try { savedAnswer = Evaluate("AssForm." & labelName); } catch (any e) { savedAnswer = ""; } item = { questionId = qidKey, label = labelName, titleBefore = socAllowBasicHtml(titleBefore), questionText = socAllowBasicHtml(qText), identifierPrefix = socAllowBasicHtml(qIdentPrefix), answerType = LCase(Trim(get_ques.answer_type[rowIdx])), answerValue = Trim(ToString(savedAnswer)), answerHtml = socAllowBasicHtml(savedAnswer), optSeen = StructNew(), options = [] }; qaByQid[qidKey] = item; ArrayAppend(qaQidOrder, qidKey); } else { item = qaByQid[qidKey]; } optionValue = Trim(ToString(get_ques.answer[rowIdx])); optionLabel = optionValue; if (ListFindNoCase(get_ques.columnList, "answer_display") GT 0 AND Len(Trim(ToString(get_ques.answer_display[rowIdx])))) { optionLabel = Trim(ToString(get_ques.answer_display[rowIdx])); } optionLabel = socAllowBasicHtml(optionLabel); if (!StructKeyExists(item.optSeen, optionValue)) { item.optSeen[optionValue] = true; ArrayAppend(item.options, { value = optionValue, label = optionLabel }); } } qaItems = []; for (oi = 1; oi <= ArrayLen(qaQidOrder); oi++) { qk = qaQidOrder[oi]; ArrayAppend(qaItems, qaByQid[qk]); } if (ArrayLen(qaItems) EQ 0) { continue; } title = StructKeyExists(nwTitles, ToString(nw)) ? nwTitles[ToString(nw)] : ("Section " & nw); ArrayAppend(qaSections, { newWizard = nw, title = title, items = qaItems }); totalQ += ArrayLen(qaItems); }
<cfoutput>#HTMLEditFormat(assessmentReason)#</cfoutput> — all wizard sections

#assessmentReason# Download Template

Patient: #HTMLEditFormat(patientName)# | Assessment Reason: #HTMLEditFormat(assessmentReason)#

Total questions: #totalQ# | Sections: #ArrayLen(qaSections)#
No questions found for this assessment.

new_wizard #sec["newWizard"]# — #HTMLEditFormat(sec["title"])#

#qaItem.titleBefore#
#qIndex# (#qaItem.identifierPrefix#) #qaItem.questionText#
  • Selected #optionLabel#
#displayAnswerHtml# No answer