<cfoutput>

	<cfquery name="geskillsprobs" dbtype="query">
		SELECT * FROM getskillproblem1
		WHERE <cfif skilltable EQ "VOL">(Skill = 'VOL' OR Skill = 'HSKP')<cfelse>Skill = <cfqueryparam value="#skilltable#" cfsqltype="CF_SQL_VARCHAR"></cfif>
			AND Description NOT LIKE '(%'
		ORDER BY Order_ID ASC, Header_No ASC, Item_ID ASC
	</cfquery>

	<cfquery name="getwounds" datasource="#Application.DataSrc#">
		SELECT * FROM #Request.prefix_db_agency#.pWoundsVitals
		WHERE Assmt_ID IN (<cfqueryparam value="#request.assesment_ids#" cfsqltype="CF_SQL_INTEGER" list="yes">)
			AND status = 0
		GROUP BY ID
	</cfquery>
	<cfset woundid = ValueList(getwounds.Description) />
	<table class="table display table-striped table-bordered table-hover severitytbl" id="sample_1_#skilltable##Assmt_ID#">
		<thead class="portlet box green" style="color: white;">
			<tr>
				<th style="text-align:center;width:30%;">OASIS Item</th>
				<th style="text-align:center;width:30%;">Severity</th>
				<th style="text-align:center;width:10%;">Skill</th>
				<!--- <th style="text-align:center;width:0%;display:none;">Careplan</th> --->
				<th style="text-align:center;width:10%;">By</th>
				<!--- <th style="text-align:center;width:5%;">Modify by</th> --->
				<th style="text-align:center;width:5%;">Date</th>
				<th style="text-align:center;width:10%;">Action</th>
			</tr>
		</thead>
		<tbody>
			<cfset x = 1 />
			<cfset prev_description = "" />
			<cfif geskillsprobs.recordcount gt 0>
				<cfloop query="geskillsprobs">
					<cfif CGI.REMOTE_ADDR EQ '121.200.49.65'>
						<!--- <cfif woundid DOES NOT contain geskillsprobs.ques_id AND geskillsprobs.M0_No EQ 'SK' AND FindNoCase("##", geskillsprobs.Description)>
							<cfdump var="#geskillsprobs.ques_id#"> - <cfoutput>#FindNoCase("##", geskillsprobs.Description)#</cfoutput><br>
						</cfif> --->
					</cfif>
					<cfset Diagnosis = "diagnosis" />
					<cfset thedescription = replace(Description, ' ', '_', 'ALL') />
					<cfset theid2 = "#geskillsprobs.Problem_ID#_#Diagnosis#_#thedescription#" />
					<cfset theid2 = replace(theid2, ' ', '_', 'ALL') />
					<cfset theid2 = #geskillsprobs.Problem_ID# />
					<cfquery name="GetSuperusers" dbtype="query">
						SELECT * FROM GetallSuperusers
						WHERE User_ID = <cfqueryparam value="#Created_by#" CFSQLType="CF_SQL_INTEGER">
					</cfquery>
					<cfset ordernumber = ListToArray(M0_No, '~')>
					<cfset Dx_Order = 0 />
					<cfset OASIS_item = ''>
					<cfif arrayIsDefined(ordernumber, 2)>
						<cfset Dx_Order = #ordernumber[2]# />
					</cfif>
					<cfset Dx_Order = #geskillsprobs.dx_order# />
					<cfif arrayIsDefined(ordernumber, 1)>
						<cfset OASIS_item = #ordernumber[1]# />
					<cfelse>
						<cfset OASIS_item = #M0_No# />
					</cfif>
					<cfset tblrowcolor = '' />
					<cfif Skill EQ "SN">
						<cfset tblrowcolor = '##FFEDFF' />
					<cfelseif Skill EQ "PT">
						<cfset tblrowcolor = '##D1F3D1' />
					<cfelseif Skill EQ "OT">
						<cfset tblrowcolor = '##FFDEBD' />
					<cfelseif Skill EQ "ST">
						<cfset tblrowcolor = '##ECD9FF' />
					<cfelseif Skill EQ "MSW">
						<cfset tblrowcolor = '##DFDFFF' />
					<cfelseif Skill EQ "HHA">
						<cfset tblrowcolor = '##FFFFCF' />
					<cfelseif Skill EQ "other">
						<cfset tblrowcolor = 'white' />
					</cfif>
					<cfset tblrowcolor = '' />
					<cfset problem_description = Left(geskillsprobs.Description, 8) />
					<cfif ListContains(request.colorlist, problem_description) GT 0>
						<cfset tblrowcolor = 'pink' />
					</cfif>

					<cfset problems_edit = false />
					<cfif <!--- (session.eaRole contains 'field'
						AND FindNoCase(assessmentreason, empassignedassessment) EQ 1) OR --->
						session.eaRole contains 'Project Manager' OR session.eaRole contains 'Quality'><!--- OR
						session.employeeid EQ Record_Created_By OR session.employeeid EQ Created_by --->
						<cfset problems_edit = true />
					</cfif>

					<tr id="diagnosis_table_#AutoProblem_ID#" class="ui-state-default" style="background-color:#tblrowcolor#">
						<input type="hidden" name="problemtype" id="problemtype#AutoProblem_ID#" value="0">
						<cfset Encrypted_Diagnosis_ID = encrypt(#AutoProblem_ID#, "54kczhzgHTj4a8n+SRZPyg==", "AES", "Hex") />
						<cfset bgcolor = '' />
						<cfif Skill EQ "SN" OR Skill EQ "">
							<cfif getcareplan.SN GT 0 AND authskills CONTAINS 'SN'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.SN GT 0 AND authskills DOES NOT CONTAIN 'SN'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.SN EQ 0 AND authskills DOES NOT CONTAIN 'SN'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<cfif Skill EQ "PT">
							<cfif getcareplan.PT GT 0 AND authskills CONTAINS 'PT'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.PT GT 0 AND authskills DOES NOT CONTAIN 'PT'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.PT EQ 0 AND authskills DOES NOT CONTAIN 'PT'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<cfif Skill EQ "OT">
							<cfif getcareplan.OT GT 0 AND authskills CONTAINS 'OT'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.OT GT 0 AND authskills DOES NOT CONTAIN 'OT'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.OT EQ 0 AND authskills DOES NOT CONTAIN 'OT'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<cfif Skill EQ "ST">
							<cfif getcareplan.ST GT 0 AND authskills CONTAINS 'ST'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.ST GT 0 AND authskills DOES NOT CONTAIN 'ST'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.ST EQ 0 AND authskills DOES NOT CONTAIN 'ST'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<cfif Skill EQ "MSW">
							<cfif getcareplan.MSW GT 0 AND authskills CONTAINS 'MSW'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.MSW GT 0 AND authskills DOES NOT CONTAIN 'MSW'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.MSW EQ 0 AND authskills DOES NOT CONTAIN 'MSW'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<cfif Skill EQ "HHA">
							<cfif getcareplan.HHA GT 0 AND authskills CONTAINS 'HHA'>
								<cfset bgcolor = '##00800099' />
							<cfelseif getcareplan.HHA GT 0 AND authskills DOES NOT CONTAIN 'HHA'>
								<cfset bgcolor = 'yellow' />
							<cfelseif getcareplan.HHA EQ 0 AND authskills DOES NOT CONTAIN 'HHA'>
								<cfset bgcolor = 'pink' />
							<cfelse>
								<cfset bgcolor = 'orange' />
							</cfif>
						</cfif>
						<td style="vertical-align:left;">#geskillsprobs.Description#</td>
						<td style="vertical-align:left;">
							<SELECT id="Answer#AutoProblem_ID#" name="Answer" class="form-control hide" onchange="severity_update('#AutoProblem_ID#','#Assmt_ID#','severity','#bgcolor#');">
								<OPTION VALUE="#geskillsprobs.Answer#">#geskillsprobs.Answer#</OPTION>
								<OPTION VALUE="0-Asymptomatic, no treatment needed at this time" <cfif #Answer# EQ "0-Asymptomatic, no treatment needed at this time">SELECTED</cfif>>0-Asymptomatic, no treatment needed at this time</OPTION>
								<OPTION VALUE="1-Symptoms well controlled with current therapy" <cfif #Answer# EQ "1-Symptoms well controlled with current therapy">SELECTED</cfif>>1-Symptoms well controlled with current therapy</OPTION>
								<OPTION VALUE="2-Symptoms controlled with difficulty, affecting daily functioning; patient needs ongoing monitoring" <cfif #Answer# EQ "2-Symptoms controlled with difficulty, affecting daily functioning; patient needs ongoing monitoring">SELECTED</cfif>>2-Symptoms controlled with difficulty, affecting daily functioning; patient needs ongoing monitoring</OPTION>
								<OPTION VALUE="3-Symptoms poorly controlled, patient needs frequent adjustment in treatment and dose monitoring" <cfif #Answer# EQ "3-Symptoms poorly controlled, patient needs frequent adjustment in treatment and dose monitoring">SELECTED</cfif>>3-Symptoms poorly controlled, patient needs frequent adjustment in treatment and dose monitoring</OPTION>
								<OPTION VALUE="4-Symptoms poorly controlled, history of re-hospitalizations" <cfif #Answer# EQ "4-Symptoms poorly controlled, history of re-hospitalizations">SELECTED</cfif>>4-Symptoms poorly controlled, history of re-hospitalizations</OPTION>
							</SELECT>#Answer# <b><cfif Answer NEQ ''>#Header#</cfif> <!--- <cfif system_description NEQ '' AND Item_ID NEQ 0>#system_description#<cfelse></cfif> ---></b>
						</td>
						<td style="vertical-align:left;">
							<cfif problems_edit EQ true>
								<div class="form-group">
									<div class="radio-list" style="margin-left: 20px; white-space: nowrap;">
										<cfif LEFT(geskillsprobs.Description, 4) EQ 'GG01' OR Path_ID GT 0>
											<cfset careplan_check = 'check_careplan'>
										<cfelse>
											<cfset careplan_check = 'severity_update'>
										</cfif>
										<cfif LEFT(geskillsprobs.Description, 4) EQ 'GG01'>
											<cfif assessment_reason NEQ 'Hospice admission' AND Left(assessment_reason, 10) NEQ 'Palliative'>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill#AutoProblem_ID#" value="PT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "PT">checked</cfif>> PT</label>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill1#AutoProblem_ID#" value="OT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "OT">checked</cfif>> OT</label>
											</cfif>
										<cfelse>
											<cfif (Skill EQ 'HHA' AND geskillsprobs.Description DOES NOT CONTAIN 'M18') OR Skill NEQ 'HHA'>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill#AutoProblem_ID#" value="SN" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "SN">checked</cfif>> SN</label>
												<cfif assessment_reason NEQ 'Hospice admission' AND Left(assessment_reason, 10) NEQ 'Palliative'>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill2#AutoProblem_ID#" value="PT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "PT">checked</cfif>> PT</label>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill3#AutoProblem_ID#" value="OT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "OT">checked</cfif>> OT</label>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill4#AutoProblem_ID#" value="ST" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "ST">checked</cfif>> ST</label>
												</cfif>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill5#AutoProblem_ID#" value="MSW" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "MSW">checked</cfif>> MSW</label>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill6#AutoProblem_ID#" value="HHA" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "HHA">checked</cfif>> HHA</label>
											</cfif>
											<cfif geskillsprobs.Description CONTAINS 'M18' AND Skill EQ 'HHA'>
												<cfif assessment_reason NEQ 'Hospice admission' AND Left(assessment_reason, 10) NEQ 'Palliative'>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill#AutoProblem_ID#" value="SN" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "SN">checked</cfif>> SN</label>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill#AutoProblem_ID#" value="PT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "PT">checked</cfif>> PT</label>
													<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill1#AutoProblem_ID#" value="OT" onclick="#careplan_check#('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#','#Path_ID#');" <cfif #Skill# EQ "OT">checked</cfif>> OT</label>
												</cfif>
											</cfif>
											<cfif assessment_reason EQ 'Hospice admission'>
												<!--- <label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill#AutoProblem_ID#" value="CH" onclick="severity_update('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#');" <cfif #Skill# EQ "CH">checked</cfif>> CH</label> --->
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill7#AutoProblem_ID#" value="HHA" onclick="severity_update('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#');" <cfif #Skill# EQ "HHA">checked</cfif>> HHA</label>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill8#AutoProblem_ID#" value="BV" onclick="severity_update('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#');" <cfif #Skill# EQ "BV">checked</cfif>> BV</label>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill9#AutoProblem_ID#" value="SC" onclick="severity_update('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#');" <cfif #Skill# EQ "SC">checked</cfif>> SC</label>
												<label class="radio-inline"><input type="radio" name="Skills#AutoProblem_ID#" id="Skill10#AutoProblem_ID#" value="VOL" onclick="severity_update('#AutoProblem_ID#','#Assmt_ID#','skill','#bgcolor#');" <cfif #Skill# EQ "VOL" OR #Skill# EQ "HSKP">checked</cfif>> VOL</label>
											</cfif>
										</cfif>
									</div>
								</div>
							<cfelse>
								#Skill#
							</cfif>
							<input type="hidden" name="Assign#Assmt_ID#" id="Assign#AutoProblem_ID#" value="#Assign#">
						</td>
						<!--- <td style="vertical-align:left;text-align: center;display:none;"><input type="checkbox" name="Careplan#Assmt_ID#" id="Careplan#AutoProblem_ID#" onchange="severity_update('#AutoProblem_ID#','#Assmt_ID#','careplan','#bgcolor#');" value="#AutoProblem_ID#" checked></td> --->
						<td style="text-align: center;">#REReplace(created_employee, " ", "<br/>")#</td>
						<!--- <td style="text-align: center;">#REReplace(modified_employee, " ", "<br/>")#</td> --->
						<td>#DateFormat(Date_Create, "mm/dd/yy")#</td>
						<td style="vertical-align:middle;text-align:center;">
							<cfif problems_edit EQ true>
								<i onClick="Edit_diagnoses('#geskillsprobs.AutoProblem_ID#','#Assmt_ID#',0)" class="fa fa-edit" style="cursor:pointer; font-size:22px;vertical-align:middle;"></i>
								&nbsp;<span><img src="/images/icon24.png" onclick="GraphResultdiagnosis('#theid2#','page=patient&cat=careplan&AID=#Assmt_ID#&ATID=#Assmt_ID#&PID=#session.cs.patientid#&code=#Skill#&detail=#Description#','#Problem_ID#','id_diagnosis');"></span>
								<cfif prev_description EQ geskillsprobs.Description>
									<i onClick="M0230deletediagnasis('#geskillsprobs.AutoProblem_ID#','#Assmt_ID#')" class="fa fa-trash-o" style="cursor:pointer; font-size:22px;vertical-align:middle;"></i>
								</cfif>
							</cfif>
						</td>
						<cfset prev_description = #geskillsprobs.Description# />
						<SELECT id="dx#AutoProblem_ID#" name="DX_order" class="form-control hide" onchange="severity_update('#AutoProblem_ID#','#Assmt_ID#','Dx_order','#bgcolor#');">
							<cfloop index="i" from="1" to="30">
								<OPTION VALUE="#i#" <cfif #Dx_Order# EQ "#i#">SELECTED</cfif>>#i#</OPTION>
							</cfloop>
						</SELECT>
						<SELECT id="Coding_Status#AutoProblem_ID#" name="Coding_Status" class="form-control hide" onchange="severity_update('#AutoProblem_ID#','#Assmt_ID#','Coding_status','#bgcolor#');">
							<OPTION VALUE="placeholder" <cfif #Coding_Status# EQ "placeholder">SELECTED</cfif>>placeholder</OPTION>
							<OPTION VALUE="pending approval" <cfif #Coding_Status# EQ "pending approval">SELECTED</cfif>>pending approval</OPTION>
							<OPTION VALUE="approved" <cfif #Coding_Status# EQ "approved">SELECTED</cfif>>approved</OPTION>
						</SELECT>
						<div id="#theid2#" style="margin-left:30px;position:absolute;visibility:hidden;overflow:auto;border:2px solid ##CCC;background-color:##A1A1A1;border:1px solid ##333;padding:5px; z-index:1000"></div>
					</tr>
					<cfset x = x + 1 />
				</cfloop>
			<cfelse>
				<tr><td colspan="6">No OASIS deficits</td></tr>
			</cfif>
		</tbody>
	</table>
</cfoutput>