<cfquery name="new" datasource="#Application.DataSrc#">
	SELECT Assessment_Completed_M0090 FROM #Request.prefix_db_agency#.Assessment_New where Assessment_ID = '#Session.CS.AssessmentID#'
</cfquery>
<cfset diag = CreateObject("Component", "components.diagnosis") />

<cfif isdefined('url.M1010')>
	<cfoutput>
		<cfif new.Assessment_Completed_M0090 gt '2015-09-30'>
			<cfquery name="M1010Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis,Code_Type FROM #Request.prefix_db_lookup#.Dx_list_ICD10 WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		<cfelse>
			<cfquery name="M1010Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis FROM #Request.prefix_db_lookup#.diagnosis_list WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		</cfif>
	</cfoutput>
	<table border="0" cellpadding="4" cellspacing="4" width="100%" >
		<tr>
			<td colspan="3" height="20px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center" style="border-bottom:1px solid black">
				<table border="0" cellpadding="0" cellspacing="0" width="90%" >
					<tr>
						<td width="50%" align="left" style="font-weight:bold;font-family: Arial;font-size: 14px;">
							Inpatient Facilities ICD10 Z-Codes
						</td>
						<td colspan="2" align="right" width="50%">
							<input type="button" name="btnCancel" value="Cancel" onClick="ColdFusion.Window.hide('searchForm');
							<cfif not isdefined('url.soc')>ColdFusion.Window.show('recertstep1');</cfif>" />
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3" height="10px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center">
				<table border="0" cellpadding="5" cellspacing="5" width="80%" >
					<cfif isdefined('M1010Diagnosis.recordcount') and  M1010Diagnosis.RecordCount GT 0>
						<cfloop query="M1010Diagnosis">
							<tr>
								<td valign="top" width="15%" height="50px" bgcolor="#E6FFC1" style="font-family: Arial;font-size: 12px;">
									Click Select Button
								</td>
								<td valign="top" width="55%" height="50px">
									<label style="font-family: Arial;font-size: 12px;"><cfoutput>#M1010Diagnosis.Diagnosis#</cfoutput></label>
								</td>
								<td align="left" valign="top" width="10%" height="50px">
									<cfoutput>
										<input name="Select" type="button" value="select" style="font-family: Arial;font-size: 12px;"
										onClick="return DiagnosislistID('#M1010Diagnosis.id#');"/>
									</cfoutput>
								</td>
							</tr>
						</cfloop>
						<cfelse>
							<td align="left" valign="middle" colspan="3" height="50px">
								No Result Found
							</td>
						</cfif>
					</table>
				</td>
			</tr>
	</table>
</cfif>

<cfif isdefined('url.M1020')>
	<cfoutput>
		<cfif new.Assessment_Completed_M0090 gt '2015-09-30'>
			<cfquery name="M1012Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis FROM #Request.prefix_db_lookup#.Dx_list_ICD10 WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		<cfelse>
			<cfquery name="M1012Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis FROM #Request.prefix_db_lookup#.diagnosis_list WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		</cfif>
	</cfoutput>
	<table border="0" cellpadding="4" cellspacing="4" width="100%" >
		<tr>
			<td colspan="3" height="20px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center" style="border-bottom:1px solid black">
				<table border="0" cellpadding="0" cellspacing="0" width="90%" >
					<tr>
						<td width="50%" align="left" style="font-weight:bold;font-family: Arial;font-size: 14px;">
							Procedure Select
						</td>
						<td colspan="2" align="right" width="50%">
							<input type="button" name="btnCancel" value="Cancel" onClick="ColdFusion.Window.hide('searchFormM1012');
							<cfif not isdefined('url.soc')>ColdFusion.Window.show('recertstep1');</cfif>" />
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3" height="10px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center">
				<table border="0" cellpadding="5" cellspacing="5" width="80%" >
					<cfif isdefined('M1012Diagnosis.recordcount') and  M1012Diagnosis.RecordCount GT 0>
						<cfloop query="M1012Diagnosis">
							<tr>
								<td valign="top" width="15%" height="50px" bgcolor="#E6FFC1" style="font-family: Arial;font-size: 12px;">
									Click Select Button
								</td>
								<td valign="top" width="55%" height="50px">
									<label style="font-family: Arial;font-size: 12px;"><cfoutput>#M1012Diagnosis.Diagnosis#</cfoutput></label>
								</td>
								<td align="left" valign="top" width="10%" height="50px">
									<cfoutput>
										<input name="Select" type="button" value="select" style="font-family: Arial;font-size: 12px;"
										onClick="return DiagnosislistIDM1020('#M1012Diagnosis.id#');"/>
									</cfoutput>
								</td>
							</tr>
						</cfloop>
					<cfelse>
						<td align="left" valign="middle" colspan="3" height="50px">
							No Result Found
						</td>
					</cfif>
				</table>
			</td>
		</tr>
	</table>
</cfif>

<cfif isdefined('url.M1016')>
	<cfoutput>
		<cfif new.Assessment_Completed_M0090 gt '2015-09-30'>
			<cfquery name="M1016Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis FROM #Request.prefix_db_lookup#.Dx_list_ICD10 WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		<cfelse>
			<cfquery name="M1016Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis FROM #Request.prefix_db_lookup#.diagnosis_list WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery>
		</cfif>
	</cfoutput>
	<table border="0" cellpadding="4" cellspacing="4" width="100%" >
		<tr>
			<td colspan="3" height="20px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center" style="border-bottom:1px solid black">
				<table border="0" cellpadding="0" cellspacing="0" width="90%" >
					<tr>
						<td width="60%" align="left" style="font-weight:bold;font-family: Arial;font-size: 14px;">
							Diagnosis requiring treatment change ICD10 Z-Codes
						</td>
						<td colspan="2" align="right" width="30%">
							<input type="button" name="btnCancel" value="Cancel" onClick="ColdFusion.Window.hide('searchFormM1016');
							<cfif not isdefined('url.soc')>ColdFusion.Window.show('recertstep1');</cfif>" />
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3" height="10px">
			</td>
		</tr>
		<tr>
			<td colspan="3" align="center">
				<table border="0" cellpadding="5" cellspacing="5" width="80%" >
					<cfif isdefined('M1016Diagnosis.recordcount') and  M1016Diagnosis.RecordCount GT 0>
						<cfloop query="M1016Diagnosis">
							<tr>
								<td valign="top" width="15%" height="50px" bgcolor="#E6FFC1" style="font-family: Arial;font-size: 12px;">
									Click Select Button
								</td>
								<td valign="top" width="55%" height="50px">
									<label style="font-family: Arial;font-size: 12px;"><cfoutput>#M1016Diagnosis.Diagnosis#</cfoutput></label>
								</td>
								<td align="left" valign="top" width="10%" height="50px">
									<cfoutput>
										<input name="Select" type="button" value="select" style="font-family: Arial;font-size: 12px;"
										onClick="return DiagnosislistIDM1016('#M1016Diagnosis.id#');"/>
									</cfoutput>
								</td>
							</tr>
						</cfloop>
					<cfelse>
						<td align="left" valign="middle" colspan="3" height="50px">
							No Result Found
						</td>
					</cfif>
				</table>
			</td>
		</tr>
	</table>
</cfif>

<cfif isdefined('url.M0230')>
	<cfoutput>
                   <cfset M0230Diagnosis = diag.Search_diagnosis('#url.text#') />	
			<!--- <cfquery name="M0230Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis,Case_Mix_Message,Code_Type,ICD FROM #Request.prefix_db_lookup#.Dx_list_ICD10 WHERE Diagnosis LIKE '%#url.text#%'
			</cfquery> --->
	</cfoutput>
	<div style="margin:0 15px;">
		<img title="Close" name="btnCancel" style="border:none;cursor:pointer;float:right;" onClick="ColdFusion.Window.hide('searchFormM0230');" src="../../images/icon_back.gif" width="33" height="35" />
		<h4>Diagnosis Select</h4>
		<table border="0" cellpadding="4" cellspacing="4" width="100%">
			<tr>
				<td colspan="3" align="center">
					<table class="table table-bordered table-striped table-condensed flip-content margin-top-10">
						<cfif isdefined('M0230Diagnosis.recordcount') and  M0230Diagnosis.RecordCount GT 0>
							<thead>
								<tr>
									<th>Diagnosis</th>
                                    <th>ICD</th>
									<th width="20%" style="text-align:center">Action</th>
								</tr>
							</thead>
							<tbody>
								<cfloop query="M0230Diagnosis">
									<tr>
										<td>
											<label><cfoutput>#M0230Diagnosis.Diagnosis#</cfoutput></label>
										</td>
                                        <td>
											<label><cfoutput>#M0230Diagnosis.ICD#</cfoutput></label>
										</td>
										<td style="text-align:center">
											<cfoutput>
												<input class="btn blue btn-sm" name="Select" type="button" value="select" onClick="return DiagnosislistIDM0230A('#M0230Diagnosis.id#','#REPLACE(M0230Diagnosis.Diagnosis,"'","","ALL")#','#M0230Diagnosis.Code_Type#');"/>
											</cfoutput>
											<br/>
                                            <cfif new.Assessment_Completed_M0090 lt '2019-12-01' AND session.Display neq 'Melissa Cott'>
											<label style="color:#FF0000;"><cfoutput>#M0230Diagnosis.Case_Mix_Message#</cfoutput></label>
                                                                         </cfif>
										</td>
									</tr>
								</cfloop>
							<cfelse>
								<tr>
									<td align="left" valign="middle" colspan="3" height="50px">
										No Result Found
									</td>
								</tr>
							</tbody>
						</cfif>
					</table>
				</td>
			</tr>
		</table>
	</div>
</cfif>

<cfif isdefined('url.M0230M')>
	<cfoutput>
			<cfquery name="M0230Diagnosis" datasource="#Application.DataSrc#">
				SELECT id,Diagnosis,Case_Mix_Message FROM #Request.prefix_db_lookup#.Dx_list_ICD10 WHERE Diagnosis LIKE '%#url.text#%' and Manfestation='M'
				and Manfestation is not null
			</cfquery>
             <cfset M0230Diagnosis = diag.Search_diagnosis('#url.text#',1) />
	</cfoutput>
	<div style="margin:0 15px;">
		<img title="Close" name="btnCancel" style="border:none;cursor:pointer;float:right;"  onClick="ColdFusion.Window.hide('searchFormM0230M'); <cfif not isdefined('url.soc')>ColdFusion.Window.show('searchFormM0230SubWindow');</cfif>" src="../../images/icon_back.gif" width="33" height="35" />
		<h4>Diagnosis Select</h4>
		<table border="0" cellpadding="4" cellspacing="4" width="100%" >
			<tr>
				<td colspan="3" align="center">
					<table class="table table-bordered table-striped table-condensed flip-content margin-top-10">
						<cfif isdefined('M0230Diagnosis.recordcount') and  M0230Diagnosis.RecordCount GT 0>
							<thead>
								<tr>
									<th>Diagnosis</th>
									<th width="20%" style="text-align:center">Action</th>
								</tr>
							</thead>
							<tbody>
								<cfloop query="M0230Diagnosis">
									<tr>
										<td>
											<label><cfoutput>#M0230Diagnosis.Diagnosis#</cfoutput></label>
										</td>
										<td style="text-align:center">
											<cfoutput>
												<input class="btn blue btn-sm" name="Select" type="button" value="select" onClick="return DiagnosislistIDM0230B('#M0230Diagnosis.id#','#REPLACE(M0230Diagnosis.Diagnosis,"'","","ALL")#');"/>
											</cfoutput>
											
										</td>
									</tr>
								</cfloop>
							<cfelse>
								<tr>
									<td align="left" valign="middle" colspan="2" height="50px">
										No Result Found
									</td>
								</tr>
							</tbody>
						</cfif>
					</table>
				</td>
			</tr>
		</table>
	</div>
</cfif>

<cfif isdefined('url.MSearch')>
	<cfoutput>
		<cfquery name="Medslist" datasource="#Application.DataSrc#">
			SELECT Trade_ID,Name FROM #Request.prefix_db_lookup#.Meds_New WHERE Name LIKE '%#url.text#%'
		</cfquery>
	</cfoutput>
	<div style="margin:10px 15px;">
		<h4 style="float:left;">Medication Search Result</h4>
		<div style="margin:8px 0 0 25px;float:right;">
			<input class="btn btn-sm blue" type="button" name="btnRefresh" value="Refresh" onClick="ColdFusion.Window.hide('searchMedication');ColdFusion.Window.show('MedicationWindow');" />
			<input class="btn btn-sm blue" type="button" name="TypeOwn1" value="type my own" onClick="TypeOwn();" />
			<input class="btn btn-sm btn-default" type="button" name="btnCancel" value="Cancel" onClick="ColdFusion.Window.hide('searchMedication');ColdFusion.Window.show('MedicationWindow');" />
		</div>
		<table border="0" cellpadding="4" cellspacing="4" width="100%">
			<tr>
				<td colspan="3" align="center">
					<table class="table table-bordered table-striped table-condensed flip-content margin-top-10">
						<cfif isdefined('Medslist.recordcount') and  Medslist.RecordCount GT 0>
							<thead>
								<tr>
									<th>Diagnosis</th>
									<th width="20%" style="text-align:center">Action</th>
								</tr>
							</thead>
							<tbody>
								<cfloop query="Medslist">
									<tr>
										<td>
											<label><cfoutput>#Medslist.Name#</cfoutput></label>
										</td>
										<td style="text-align:center">
											<cfoutput>
												<input class="btn blue btn-sm" name="submit" type="submit" value="select" onClick="ShowID('#Medslist.Trade_ID#');"/>
											</cfoutput>
										</td>
									</tr>
								</cfloop>
							<cfelse>
								<tr>
									<td align="left" valign="middle" colspan="2" height="50px">
										No Result Found
									</td>
								</tr>
							</tbody>
						</cfif>
					</table>
				</td>
			</tr>
		</table>
	</div>
</cfif>

<cfif isdefined('url.MSearch2')>
	<cfoutput>
		<cfquery name="MedsDose" datasource="#Application.DataSrc#">
			select Meds_New_Dose.Dose_ID,Meds_New_Dose.Dose,Meds_New_Dose.Form from #Request.prefix_db_lookup#.Meds_New_Dose where Trade_ID='#url.text#'
		</cfquery>
		<cfquery name="MedsDoseName" datasource="#Application.DataSrc#">
			SELECT Name FROM #Request.prefix_db_lookup#.Meds_New m where Trade_ID='#url.text#'
		</cfquery>
	</cfoutput>
	<div style="margin:10px 15px;">
		<div style="margin:8px 0 0 25px;float:right;">
			<input class="btn btn-sm blue" type="button" name="TypeOwn2" value="type my own" onClick="TypeOwn2();"/>
			<input class="btn btn-sm btn-default" type="button" name="btnCancel" value="Cancel" onClick="ColdFusion.Window.hide('searchMedication2');ColdFusion.Window.show('MedicationWindow');" />
		</div>
		<h4><cfoutput>#MedsDoseName.Name#</cfoutput></h4>
		<p style="font-size:14px;">available doses/how dispensed*</p>
		<table border="0" cellpadding="4" cellspacing="4" width="100%">
			<tr>
				<td colspan="3" align="center">
					<table class="table table-bordered table-striped table-condensed flip-content margin-top-10">
						<cfif isdefined('MedsDose.recordcount') and  MedsDose.RecordCount GT 0>
							<thead>
								<tr>
									<th>Meds Dose</th>
									<th width="20%" style="text-align:center">Action</th>
								</tr>
							</thead>
							<tbody>
								<cfloop query="MedsDose">
									<tr>
										<td>
											<label><cfoutput>#MedsDose.Dose#</cfoutput><br><cfoutput>#MedsDose.Form#</cfoutput></label>
										</td>
										<td style="text-align:center;vertical-align: middle;">
											<cfoutput>
												<input class="btn blue btn-sm" name="submit" type="submit" value="select" onClick="ShowDoseID('#MedsDose.Dose_ID#');"/>
											</cfoutput>
										</td>
									</tr>
								</cfloop>
							</tbody>
						</cfif>
					</table>
				</td>
			</tr>
		</table>
	</div>
</cfif>