
<cfparam name="url.type" default="diagnosis">
<cfparam name="url.report_type" default="teachplan">
<cfparam name="url.download" default="0">
<cfparam name="url.report" default="0">
<cfparam name="url.report_method" default="0">
  <cfoutput> report = #url.report#</cfoutput>   
<cfif isdefined('url.patient_id')>
		<cfscript>
				teachplan_component = CreateObject("Component", "teachplan");
				get_Teach_diagnoses = teachplan_component.Get_Teach_diagnoses_list_employee(patient_id="#url.patient_id#", AgencyID="#session.AgencyID#", assessment_id="#url.assessment_id#");
				Groupby_Teach_diagnoses = teachplan_component.Groupby_Teach_diagnoses_list(patient_id="#url.patient_id#", AgencyID="#session.AgencyID#", assessment_id="#url.assessment_id#");	
                dashboard_component = CreateObject("Component", "teachingplan_dashboard");			
                Get_Report5_groupby = dashboard_component.Get_Report5_groupby(Patient_ID="#url.patient_id#",Assessment_ID="#url.assessment_id#",Report="#url.report_type#");
                Get_Assessment_Patient_data = dashboard_component.Get_Assess_Patient_data(Patient_ID="#url.patient_id#",Assessment_ID="#url.assessment_id#");
		</cfscript>	 
<cfset agency_name = rereplace(Session.AgencyName,"[^A-Za-z0-9]","","all") />
<cfparam name="url.redirect_from" default="">
<cfparam name="url.OASIS_D_PDGM_Visit" default="">
<cfset url.report_type= decrypt(#url.report_type#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex") />
<cfset url.report_method= decrypt(#url.report_method#,"54kczhzgHTj4a8n+SRZPyg==","AES","Hex") />
<cfset url.AID = #url.assessment_id# />
<cfset url.ID = #url.patient_id# />		
<cfset TheFile="/var/www/datafiles/Agency_Logos/#session.AgencyID#.png">
 <cfset save_file = "/var/www/dashboard/coding_files/" />
<cfset coding_reports= #agency_name#&"_"&#Trim(get_Teach_diagnoses.Last_Name_M0040)#&"_"&#session.file_date#&"_"&#url.report_method#&"_report.pdf" /> 
<cfset recommended_reports= #agency_name#&"_"&#Trim(Get_Assessment_Patient_data.PatientLast)#&"_"&#session.file_date#&"_"&#url.report_method#&"_report.pdf" />
 <cfset zip_filename = #agency_name#&"_"&#Trim(Get_Assessment_Patient_data.PatientLast)#&"_"&#session.file_date# >
 <!--- <cfset recommended_reports= #agency_name#&"_"&#Trim(Get_Assessment_Patient_data.PatientLast)#&"_"&#DateFormat(now(),'yyyymmdd')#&"_recommended_report.pdf" />---> 
  
 <cfif  url.report_method  EQ 'teachplan'>
     
      <cfdocument format="pdf"   margintop=".75" marginbottom="1.25" orientation="landscape"  filename="#save_file##coding_reports#"
      overwrite="yes">	
		<cfdocumentsection>			
			<div class="row">		
				<div class="row">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td align="left" width="70%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td style="padding-left:10px; font-family: Arial; font-size: 25px;font-style: italic;">Teaching Plan for</td>
									</tr>
						
									<tr>
										<td height="6px"></td>
									</tr>
									<tr>				
										<td style="padding-left:50px; font-family: Arial; font-size: 30px; font-weight: bold;"><cfoutput>#get_Teach_diagnoses.First_Name_M0040# #get_Teach_diagnoses.Last_Name_M0040#</cfoutput></td>
									</tr>
									<tr>
										<td height="6px"></td>
									</tr>
									<tr>	
										<cfoutput>
										<cfset strSomestring = #get_Teach_diagnoses.Assessment_Reason_M0100#>
										<cfset SOC_String = find( "Start of care", strSomestring )>	
										<cfset Recertification_String = find( "Recertification", strSomestring )>
										<cfset Resumption_String = find( "Resumption", strSomestring )>
																						
										<td style="padding-left:80px; font-family: Arial; font-size: 25px; font-weight: bold;"><cfif #SOC_String# neq 0>Start of Care<cfelseif #Recertification_String# neq 0>Recertification<cfelseif #Resumption_String# neq 0>Resumption<cfelse>#get_Teach_diagnoses.Assessment_Reason_M0100#</cfif> #DateFormat(get_Teach_diagnoses.Assessment_Completed_M0090,"mm/dd/yy")#</td>
										</cfoutput>
									</tr>
								</table>
							</td>
							<td align="right" width="30%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   <cfif fileExists(TheFile)> 	
												<img src="file:///<cfoutput>#TheFile#</cfoutput>" width="100%"  style="height:100px;">							
											<cfelse> 
												<img src="file:///var/www/img/MHCB_Logo.png" width="100%" style="height:100px;"> 
											</cfif>	
										</td>
									</tr>	
								</table>
							</td>	
						</tr>
					</table>		
				</div>		
				<br />		
				<div class="row">
					<div style="padding-right:10px; text-align:right; font-family: Arial; font-size: 25px;font-style: italic;">Prepared by <cfoutput>#get_Teach_diagnoses.Employee_First_Name#&nbsp;#get_Teach_diagnoses.Employee_Last_Name# </cfoutput></div>		
				</div>		
				<br />
				<div class="row">
					<div style="border-top:solid 1px blue;"></div>
				</div>
				<div class="row">	
					<div class="row">
						<div style="margin-top:10px;"></div>
						<div style="padding-left:20px; font-family: Arial; font-size: 20px;">TABLE OF CONTENTS</div>
						<div style="margin-top:5px;"></div>
					</div>			
					<cfloop query="Groupby_Teach_diagnoses">	
						<cfscript>
							Groupby_DiagnosesList = teachplan_component.Group_Diagnoses_list(patient_id="#url.patient_id#", AgencyID="#session.AgencyID#", assessment_id="#url.assessment_id#",Pathway_type="#Dig_Pathway_Type#");						
						</cfscript>		
									
						<cfoutput query="Groupby_DiagnosesList">
							<div class="row">
								<div style="margin-top:3px;"></div>
								<div style="padding-left:60px; font-family: Arial; font-size: 20px;">
									<cfif #Groupby_DiagnosesList.DIG_PATHWAY_TYPE# eq  'diet'> 
										Diet - #Groupby_DiagnosesList.Dg_Diagnosis#
									<cfelseif #Groupby_DiagnosesList.DIG_PATHWAY_TYPE# eq  'DME/supplies'>
										DME/supplies - #Groupby_DiagnosesList.Dg_Diagnosis#
									<cfelse>
										<strong>#Groupby_DiagnosesList.Dg_Diagnosis#</strong>
									</cfif>
								</div>
								<div style="margin-top:5px;"></div>
							</div>	
							<cfscript>
								get_TeachSkills_type_1 = teachplan_component.Pathway_ID_based(Patient_ID="#Groupby_DiagnosesList.Dg_Patient_ID#", Assessment_ID="#Groupby_DiagnosesList.Dg_Assessment_ID#", Diagnosis_ID="#Groupby_DiagnosesList.Dg_id#",ICD="#Groupby_DiagnosesList.Dg_ICD#",sym_prev="1");						
							</cfscript>	
								
							<cfloop query="get_TeachSkills_type_1">					
									<cfquery  datasource="#Application.DataSrc#" name="get_TeachSkills_alldata_1">
										SELECT * FROM  
											#Request.prefix_db_agency#.Teaching_Skills 
										WHERE  
											Diagnosis_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER">
											AND Patient_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_Patient_ID#" CFSQLType ="CF_SQL_INTEGER"> 
											AND Assessment_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_Assessment_ID#" CFSQLType ="CF_SQL_INTEGER"> 
											AND ICD=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_ICD#" CFSQLType ="CF_SQL_VARCHAR"> 
											AND Deleted=0 
											AND Pathway_Type NOT LIKE 'goal%' 
											AND Pathway_Type NOT LIKE 'intervention%'
											AND Pathway_Type NOT LIKE 'Source%' 
											AND Pathway_ID <> 0
											<cfif #get_TeachSkills_type_1.Pathway_Type# neq ''>AND Pathway_Type = '#get_TeachSkills_type_1.Pathway_Type#'</cfif>  
											<cfif  #get_TeachSkills_type_1.Pathway_Type# eq "Teaching" >
												OR ( Pathway_Type = 'Title' AND Step_ID=129 AND Line_ID=0 AND Diagnosis_ID = <cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER"> AND Pathway_ID <> 0 )
											<cfelseif #get_TeachSkills_type_1.Pathway_Type# eq "symptom">
												OR ( Pathway_Type = 'Title' AND Step_ID=0 AND Line_ID=0 AND Diagnosis_ID = <cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER"> AND Pathway_ID <> 0 )
											</cfif> 
											ORDER BY Order_ID ASC
									</cfquery>																			   				
									 <cfloop query="get_TeachSkills_alldata_1">
										<cfif #get_TeachSkills_alldata_1.Pathway_Type# eq "Title" >
											<div class="row">
												<div style="margin-top:4px;"></div>
												<div style="padding-left:120px;font-size:14px;font-family: Arial;">#get_TeachSkills_alldata_1.Explanation#</div>
												<div style="margin-top:6px;"></div>
											</div>
										</cfif>
									</cfloop>
                                   <!--- <cfloop query="get_TeachSkills_alldata_1">
										<cfif #get_TeachSkills_alldata_1.Pathway_Type# eq "Title"  AND #get_TeachSkills_type_1.Pathway_Type# neq "symptom">
											<div class="row">
												<div style="margin-top:4px;"></div>
												<div style="padding-left:120px;font-size:14px;font-family: Arial;">#get_TeachSkills_alldata_1.Explanation#</div>
												<div style="margin-top:6px;"></div>
											</div>
										</cfif>
									</cfloop>--->
							</cfloop>					
						</cfoutput>
					</cfloop>
					<cfdocumentitem type="pagebreak">
					</cfdocumentitem>
				</div>		
				<div class="row">			
					<cfloop query="Groupby_Teach_diagnoses">	
						<cfscript>
							Groupby_DiagnosesList = teachplan_component.Group_Diagnoses_list(patient_id="#url.patient_id#", AgencyID="#session.AgencyID#", assessment_id="#url.assessment_id#",Pathway_type="#Dig_Pathway_Type#");						
						</cfscript>								
						<div class="row" style="margin-top:15px;">			
							<cfif Groupby_Teach_diagnoses.Dig_Pathway_Type eq ''>
								<label style="padding-left:0px; font-family: Arial; font-size: 22px;font-style: italic;">Primary Diagnosis</label>
							<cfelse>
								<!---<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-style: italic;"><cfoutput>#reReplace(Groupby_Teach_diagnoses.Dig_Pathway_Type ,"(^[a-z])","\U\1","ALL")#</cfoutput></label>	--->					
							</cfif>
						</div>
						<cfoutput query="Groupby_DiagnosesList">				
							<div class="row">
								<div style="margin-top:5px;"></div>
								<div style="padding-left:15px; font-family: Arial; font-size: 22px;">#Groupby_DiagnosesList.Dg_Diagnosis#</div>
								<div style="margin-top:5px;"></div>
							</div>
							<cfscript>
								get_TeachSkills_type = teachplan_component.Pathway_ID_based(Patient_ID="#Groupby_DiagnosesList.Dg_Patient_ID#", Assessment_ID="#Groupby_DiagnosesList.Dg_Assessment_ID#", Diagnosis_ID="#Groupby_DiagnosesList.Dg_id#",ICD="#Groupby_DiagnosesList.Dg_ICD#");						
							</cfscript>		
												
							<div class="row" style="font-family: Arial;padding-left:35px; font-size: 14px;">	<br />
							<cfloop query="get_TeachSkills_type">
                                <cfset three_icd = #Left(Groupby_DiagnosesList.Dg_ICD,3)# />                              
									<cfquery  datasource="#Application.DataSrc#" name="get_TeachSkills_alldata">
										SELECT * FROM  
											#Request.prefix_db_agency#.Teaching_Skills 
										WHERE  
											Diagnosis_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER">
											AND Patient_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_Patient_ID#" CFSQLType ="CF_SQL_INTEGER"> 
											AND Assessment_ID=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_Assessment_ID#" CFSQLType ="CF_SQL_INTEGER"> 
											AND ICD=<cfqueryparam value = "#Groupby_DiagnosesList.Dg_ICD#" CFSQLType ="CF_SQL_VARCHAR"> 
											AND Deleted=0 
											AND Pathway_Type NOT LIKE 'goal%' 
											AND Pathway_Type NOT LIKE 'intervention%'
											AND Pathway_Type NOT LIKE 'Source%' 
											AND Pathway_ID <> 0
											<cfif #get_TeachSkills_type.Pathway_Type# neq ''>AND Pathway_Type = '#get_TeachSkills_type.Pathway_Type#'</cfif>  
											<cfif   #get_TeachSkills_type.Pathway_Type# eq "Teaching" >
												OR ( Pathway_Type = 'Title' AND Step_ID=129 AND Line_ID=0 AND Diagnosis_ID = <cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER"> AND Pathway_ID <> 0 )
											<cfelseif #get_TeachSkills_type.Pathway_Type# eq "symptom"  >
												OR ( Pathway_Type = 'Title' AND Step_ID=0 AND Line_ID=0 AND Diagnosis_ID = <cfqueryparam value = "#Groupby_DiagnosesList.Dg_id#" CFSQLType ="CF_SQL_INTEGER"> AND Pathway_ID <> 0 )
											</cfif> 
											<!---ORDER BY Order_ID ASC--->										
									</cfquery>		
                                   													
									<cfloop query="get_TeachSkills_alldata">
										<cfif #get_TeachSkills_alldata.Pathway_Type# eq "Title">
											<div class="row">
												<div style="margin-top:5px;"></div>
												<div style="font-size:18px;font-weight:bold;">#UCase(get_TeachSkills_alldata.Explanation)#</div>
												<div style="margin-top:5px;"></div>
											</div>
										</cfif>
									</cfloop>							
				        					<!---<cfloop query="get_TeachSkills_alldata">			
										<cfif #get_TeachSkills_alldata.Line_ID# eq 0 and #get_TeachSkills_alldata.Pathway_Type# neq "symptom" and #get_TeachSkills_alldata.Pathway_Type# neq "Title">
											<div class="row">
												<div style="margin-top:5px;"></div>
												<div style="font-size:14px;"><b>#UCase(get_TeachSkills_alldata.Explanation)#</b></div>	
												<div style="margin-top:15px;"></div>
											</div>
										<cfelseif #get_TeachSkills_alldata.Pathway_Type# neq "Title">
											<div class="row">
												<div style="margin-top:5px;"></div> 
												<div style="font-size:14px;width:100%;">
													<cfif #get_TeachSkills_alldata.Line_ID# eq 0 and #get_TeachSkills_alldata.Pathway_Type# neq "symptom">
                                                       <b>#get_TeachSkills_alldata.Explanation#</b>
													<cfelse>#get_TeachSkills_alldata.Explanation#</cfif>
												</div>												
												<div style="margin-top:20px;"></div>
											</div>
                                         </cfif>	
									</cfloop>--->          
                                   <!--- <cfloop query="get_TeachSkills_alldata">	
                                         <cfif  #get_TeachSkills_alldata.Pathway_Type# eq "symptom" >
                                             <div class="row">
												<div style="margin-top:5px;"></div>
												<div style="font-size:14px;"><b>#UCase(get_TeachSkills_alldata.Explanation)#</b></div>	
												<div style="margin-top:15px;"></div>
											 </div>
                                             </cfif>
                                    </cfloop> --->   
                                        <cfloop query="get_TeachSkills_alldata">	
                                                 <cfif #get_TeachSkills_alldata.Line_ID# eq 0 and #get_TeachSkills_alldata.Pathway_Type# neq "symptom" and #get_TeachSkills_alldata.Pathway_Type# neq "Title">
                                                        <div class="row">
                                                            <div style="margin-top:5px;"></div>
                                                            <div style="font-size:14px;"><b>#UCase(get_TeachSkills_alldata.Explanation)#</b></div>	
                                                            <div style="margin-top:15px;"></div>
                                                        </div>
                                                <cfelseif #get_TeachSkills_alldata.Pathway_Type# neq "Title" and #get_TeachSkills_alldata.Pathway_Type# eq "symptom">
                                                        <div class="row">
                                                            <div style="margin-top:5px;"></div> 
                                                            <div style="font-size:14px;width:100%;">
                                                                #get_TeachSkills_alldata.Explanation#
                                                            </div>												
                                                            <div style="margin-top:20px;"></div>
                                                        </div>
                                                 <cfelseif #get_TeachSkills_alldata.Pathway_Type# neq "Title" and #get_TeachSkills_alldata.Pathway_Type# eq "teaching">
                                                        <div class="row">
                                                            <div style="margin-top:5px;"></div> 
                                                            <div style="font-size:14px;width:100%;">
                                                                <cfif #get_TeachSkills_alldata.Line_ID# eq 0 >
                                                                   <b>#get_TeachSkills_alldata.Explanation#</b>
                                                                <cfelse>#get_TeachSkills_alldata.Explanation#</cfif>
                                                            </div>												
                                                            <div style="margin-top:20px;"></div>
                                                        </div>
                                                 </cfif>
                                        </cfloop>                    
                                	<div class="row">
										<div style="margin-top:10px;"></div>
									</div>	
							</cfloop>	
							</div>	
							<cfdocumentitem type="pagebreak">
							</cfdocumentitem>				
						</cfoutput>	 								
					</cfloop>
				</div>
			</div>
			<cfdocumentitem type="footer"  evalatprint="true">
				<table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
					<tr>
					  <td><table align="center" cellpadding="0" cellspacing="0" border="0" width="100%" 
					  style="font-family: Arial; font-size: 22px; ">
						  <tr>
							<td height="3px"></td>
						  </tr>
						  <tr>
							<td align="center" style="font-family: Arial;font-size:22px;">Teaching Plan for <cfoutput>#get_Teach_diagnoses.First_Name_M0040#&nbsp;#get_Teach_diagnoses.Last_Name_M0040#</cfoutput></td>
						  </tr>
						  <tr>
							<td height="3px"></td>
						  </tr>
						  <tr>
							<td align="center" style="font-family: Arial;font-size: 22px;">prepared by <cfoutput>#get_Teach_diagnoses.Employee_First_Name#&nbsp;#get_Teach_diagnoses.Employee_Last_Name# </cfoutput></td>
						  </tr>
						<tr>
							<td height="3px"></td>
						  </tr>
						  <tr>
							<td align="center" style="font-family: Arial;font-size: 22px;"> page <cfoutput>#cfdocument.currentpagenumber#</cfoutput> </td>
						  </tr>
						  <tr>
							<td height="3px"></td>
						  </tr>
						</table></td>
					</tr>
				</table>
			</cfdocumentitem>  
		</cfdocumentsection>
	</cfdocument>
                                        
<cfelseif url.report_type EQ 1>
     <cfdocument format="pdf"   margintop=".75" marginbottom="1.25"   orientation="landscape"  filename="#save_file##recommended_reports#"  overwrite="yes">
	
		<cfdocumentsection>	
		
		<div class="row">
			<div class="row">
			
				<cfoutput>
				<div class="row">
					<div>
						<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;"><cfif #url.report_method# eq "2019_OASIS_D">2019 OASIS-D Recommended Diagnoses<cfelseif #url.report_method# eq "2020_PDGM">2020 PDGM Recommended Diagnoses</cfif></label>
					</div>
				</div>
				<div class="row">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td align="left" width="45%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">							
									<!---<tr>
										<td height="2px"></td>
									</tr>--->
									<tr>				
										<td style="padding-left:20px; font-family: Arial; font-size: 28px; font-weight: bold;"><cfoutput>#Get_Assessment_Patient_data.PatientFirst# #Get_Assessment_Patient_data.PatientLast#</cfoutput></td>
									</tr>
									<tr>	
										<cfoutput>
										<cfset strSomestring = #Get_Assessment_Patient_data.Assessment_Reason_M0100#>
										<cfset SOC_String = find( "Start of care", strSomestring )>	
										<cfset Recertification_String = find( "Recertification", strSomestring )>
										<cfset Resumption_String = find( "Resumption", strSomestring )>
																						
										<td style="padding-left:30px; font-family: Arial; font-size: 20px; font-weight: bold;"><cfif #SOC_String# neq 0>Start of Care<cfelseif #Recertification_String# neq 0>Recertification<cfelseif #Resumption_String# neq 0>Resumption<cfelse>#Get_Assessment_Patient_data.Assessment_Reason_M0100#</cfif> #DateFormat(Get_Assessment_Patient_data.Assessment_Completed_M0090,"mm/dd/yy")#</td>
										</cfoutput>
									</tr>
								</table>
							</td>				
							<td align="right" width="25%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   
										</td>
									</tr>	
									
								</table>
							</td>	
							<td align="right" width="30%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   <cfif fileExists(TheFile)> 	
												<img src="file:///<cfoutput>#TheFile#</cfoutput>" width="80%" style="height:100px;">							
											<cfelse> 
												<img src="file:///var/www/img/MHCB_Logo.png" width="100%" style="height:100px;"> 
											</cfif>	
										</td>
									</tr>	
									
								</table>
							</td>	
							
						</tr>
					</table>		
				</div>
				<br />
				
				</cfoutput>
				
				
				<table cellpadding="5" border="1" cellspacing="0" width="100%">
				
					<tr style="font-family: Arial;">
						<th width="10%" height="20px"></th>
						<th width="25%">User-entered Diagnoses</th>
						<th width="30%">Rationale</th>
						<th width="30%">Goal</th>
					</tr>
					
					<cfquery name="Get_Report_1_data_all" datasource="#Application.DataSrc#">
						SELECT * FROM 
							#Request.prefix_db_agency#.Coding_Results 
						WHERE 
							Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
							AND Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer"> 
							AND ( M0_Item_Medication like '%(M102%' or M0_Item_Medication = 'OASIS' ) 
							<!---AND ( M0_Item_Medication like '%(M102%' or M0_Item_Medication = 'OASIS' )--->	
                        Order by Results_ID ASC
					</cfquery>	
					<cfquery name="Get_Patient" datasource="#Application.DataSrc#">
						SELECT * FROM 
							#Request.prefix_db_agency#.patient
						WHERE 
							Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
				   </cfquery>	
                    <cfif Get_Patient.Safety_Hazards_M0320 neq ''>
                        <cfset Primary = '('&Get_Patient.Safety_Hazards_M0320 &')'>
                        <cfelse>
                            <cfset Primary = '(no primary reason documented)'>
					</cfif>

					<cfif #url.report_method# eq "2019_OASIS_D">
						<cfif isdefined('Get_Report_1_data_all.recordcount') and  Get_Report_1_data_all.RecordCount GT 0>	
							<cfoutput query="Get_Report_1_data_all">
                              <tr style="font-family: Arial; font-size: 13px;">
                                  <td width="5%">#Get_Report_1_data_all.M0_Item_Medication#</td>
                                  <td width="30%"><cfif Get_Report_1_data_all.Message_ID eq 13 or Get_Report_1_data_all.Message_ID eq 15 or Get_Report_1_data_all.Message_ID eq 16><font color="##FF0000">#Get_Report_1_data_all.Diagnosis#</font><cfelseif Get_Report_1_data_all.M0_Item_Medication eq 'OASIS'><font color="##0000FF">#Get_Report_1_data_all.Diagnosis#</font><cfelse>#Get_Report_1_data_all.Diagnosis#</cfif></td>
                                  <td width="30%">#Get_Report_1_data_all.OASIS#<!---<br>
                                      <cfif Get_Report_1_data_all.Medications eq 'no medications' and Get_Report_1_data_all.M0_Item_Medication neq 'OASIS'><font color="##9933ff">no medication</font><cfelseif Get_Report_1_data_all.M0_Item_Medication neq 'OASIS'><i>#Get_Report_1_data_all.Medications#</i><cfelse>&nbsp;</cfif>---></td>
                                  <td width="30%"><cfif Get_Report_1_data_all.Message_ID eq 13 or Get_Report_1_data_all.Message_ID eq 15><font color="##FF0000">GOAL ALREADY MET<br><br>#Get_Report_1_data_all.TextField_8#</font><cfelse>#Get_Report_1_data_all.TextField_8#</cfif></td>
                              </tr>								
							</cfoutput>
						<cfelse>
							<tr>
								<td align="center" valign="middle" colspan="4" height="50px">
									No Report Found
								</td>
							</tr>
						</cfif>						
					<cfelseif #url.report_method# eq "2020_PDGM">
						<cfif isdefined('Get_Report_1_data_all.recordcount') and  Get_Report_1_data_all.RecordCount GT 0>	
							<cfoutput query="Get_Report_1_data_all">
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="10%">#Get_Report_1_data_all.M0_Item_Medication#</td>
									<td width="25%"><cfif Get_Report_1_data_all.TextField_10 contains 'replace' or Get_Report_1_data_all.TextField_10 contains 'redund'><font color="##FF0000">#Get_Report_1_data_all.Diagnosis#</font><cfelse>#Get_Report_1_data_all.Diagnosis#</cfif><cfif Get_Report_1_data_all.Textfield_1 neq '' or Get_Report_1_data_all.Textfield_2 neq ''><br><br><i>#Get_Report_1_data_all.Textfield_1#<br>#Get_Report_1_data_all.Textfield_2#</i><cfelse></cfif></td>
									<td width="30%"><cfif Get_Report_1_data_all.Created_by contains 'replace' or Get_Report_1_data_all.Created_by contains 'redund'><font color="##FF0000">#Get_Report_1_data_all.Created_by#</font><cfelse>#Get_Report_1_data_all.Created_by#</cfif></td>
									<td width="30%"><cfif Get_Report_1_data_all.Textfield_9 contains '2020'><font color="##9933ff">#Get_Report_1_data_all.OASIS#<br><br>#Get_Report_1_data_all.Textfield_9#&nbsp;</font>&nbsp;#Primary#<br><br><cfelse>#Get_Report_1_data_all.OASIS#<br><br>#Get_Report_1_data_all.Textfield_9#</cfif><i>#Get_Report_1_data_all.Medications#</i></td>	
								</tr>								
							</cfoutput>
						<cfelse>
							<tr>
								<td align="center" valign="middle" colspan="4" height="50px">
									No Report Found
								</td>
							</tr>
						</cfif>
					</cfif>
					
				</table>
					
					
			</div>
		</div>
		<cfdocumentitem type="footer"  evalatprint="true">
				<table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
					<tr>
					  	<td>
							<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%" 
						  style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New; font-size: 22px; ">
							  <tr>
								<td height="8px"></td>
							  </tr>	
							  <tr>
								<td align="center" style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New;font-size: 26px;"> page <cfoutput>#cfdocument.currentpagenumber#</cfoutput> </td>
							  </tr>
							  <tr>
								<td height="10px"></td>
							  </tr>
							</table>
						</td>
					</tr>
				</table>
			</cfdocumentitem>  
		</cfdocumentsection>
	</cfdocument>



<cfelseif url.report_type EQ 2>
   

	<cfdocument format="pdf"  localURL = "yes"   margintop=".75" marginbottom="1.25"   orientation="landscape"  overwrite="yes"  filename="#save_file##recommended_reports#"   >
	
		<cfdocumentsection>	
		
		<div class="row">
		
				<cfquery name="Get_Report_2_data_2019" datasource="#Application.DataSrc#">
					SELECT * FROM 
						#Request.prefix_db_agency#.Coding_Results 
					WHERE 
						Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
						AND Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer">
                        AND ( M0_Item_Medication like '%(M102%' <!---or Order_ID = 28 or Order_ID = 29--->)
                    Order by Results_ID
				</cfquery>	
						
                    	<cfquery name="Get_Report_2_data_2020" datasource="#Application.DataSrc#">
                    SELECT * FROM 
						#Request.prefix_db_agency#.Coding_Results 
					WHERE 
						Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
						AND Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer">
                        AND (M0_Item_Medication like '%(M102%' or M0_Item_Medication = 'OASIS') 
                            AND Message_ID not in (13,15,16)
                    Order by Results_ID
				</cfquery>	

				<div class="row">
					<div>
						<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;"><cfif #url.report_method# eq "User_entered">User-entered Interventions & Goals for 485<cfelseif #url.report_method# eq "Recommended">Recommended Interventions & Goals for 485</cfif></label>
					</div>
				</div>
				<div class="row">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td align="left" width="45%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">							
									<!---<tr>
										<td height="2px"></td>
									</tr>--->
									<tr>				
										<td style="padding-left:40px; font-family: Arial; font-size: 28px; font-weight: bold;"><cfoutput>#Get_Assessment_Patient_data.PatientFirst# #Get_Assessment_Patient_data.PatientLast#</cfoutput></td>
									</tr>
									<tr>	
										<cfoutput>
										<cfset strSomestring = #Get_Assessment_Patient_data.Assessment_Reason_M0100#>
										<cfset SOC_String = find( "Start of care", strSomestring )>	
										<cfset Recertification_String = find( "Recertification", strSomestring )>
										<cfset Resumption_String = find( "Resumption", strSomestring )>
																						
										<td style="padding-left:50px; font-family: Arial; font-size: 24px; font-weight: bold;"><cfif #SOC_String# neq 0>Start of Care<cfelseif #Recertification_String# neq 0>Recertification<cfelseif #Resumption_String# neq 0>Resumption<cfelse>#Get_Assessment_Patient_data.Assessment_Reason_M0100#</cfif> #DateFormat(Get_Assessment_Patient_data.Assessment_Completed_M0090,"mm/dd/yy")#</td>
										</cfoutput>
									</tr>
								</table>
							</td>				
							<td align="right" width="25%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   
										</td>
									</tr>	
									
								</table>
							</td>	
							<td align="right" width="30%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   <cfif fileExists(TheFile)> 	
												<img src="file:///<cfoutput>#TheFile#</cfoutput>" width="100%" style="height:100px;">							
											<cfelse> 
												<img src="file:///var/www/img/MHCB_Logo.png" width="100%" style="height:100px;"> 
											</cfif>	
										</td>
									</tr>	
									
								</table>
							</td>	
							
						</tr>
					</table>		
				</div>
                                        <br>
				
                                        <cfoutput>#Get_Report_2_data_2019.Textfield_9#</cfoutput>
				<cfif url.report_method eq "User_entered">
					<div class="row">
						<table cellpadding="5" border="1" cellspacing="0" width="100%">					
							<tr style="font-family: Arial;">
								<th width="10%" height="40px"></th>
								<th width="25%">User-entered Diagnosis List</th>
								<th width="30%">Goals for CMS485 FL 22</th>
								<th width="30%">Interventions for CMS485 FL 21</th>
							</tr>
							
							<cfif isdefined('Get_Report_2_data_2019.recordcount') and  Get_Report_2_data_2019.RecordCount GT 0>	
								<cfoutput query="Get_Report_2_data_2019">
									<tr style="font-family: Arial; font-size: 13px;">
										<td width="10%">#Get_Report_2_data_2019.M0_Item_Medication#</td>
										<td width="25%">#Get_Report_2_data_2019.Diagnosis#</td>
										<td width="30%">#Get_Report_2_data_2019.Memo#</td>
										<td width="30%" valign="top">#Get_Report_2_data_2019.Textfield_12#</td>	
									</tr>
								</cfoutput>
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>					
						</table>
					</div>						
					<!---<br /><br /><br /><br />--->
					<cfdocumentitem type="pagebreak">
            		</cfdocumentitem>
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 34px;font-weight:bold;">INSERT INTO CMS485</label>
							</div>
						</div>
						<br /> <cfoutput>#Get_Report_2_data_2019.Textfield_9#</cfoutput>
					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">
												
							<tr style="font-family: Arial;">
								<th width="50%" height="40px">All Goals for CMS485 FL 22</th>
								<th width="50%">All Interventions for CMS485 FL 21</th>						
							</tr>
							
							<cfif isdefined('Get_Report_2_data_2019.recordcount') and  Get_Report_2_data_2019.RecordCount GT 0>	
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="50%" valign="top">
										<cfoutput query="Get_Report_2_data_2019">
											<cfif #Get_Report_2_data_2019.Memo# neq "">
												#Get_Report_2_data_2019.Memo# <br />
											</cfif>
										</cfoutput>										
									</td>
									<td width="50%" valign="top">
										<cfoutput query="Get_Report_2_data_2019">
											<cfif #Get_Report_2_data_2019.Textfield_12# neq "">
												#Get_Report_2_data_2019.Textfield_12# <br />
											</cfif>
										</cfoutput>	
									</td>									
								</tr>
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="2" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>					
						</table>
					</div>	
				<cfelseif url.report_method eq "Recommended">
					<div class="row">
						<table cellpadding="5" border="1" cellspacing="0" width="100%">					
							<tr style="font-family: Arial;">
								<th width="10%" height="40px"></th>
								<th width="25%">User-entered Diagnosis List</th>
								<th width="30%">Goals for CMS485 FL 22</th>
								<th width="30%">Interventions for CMS485 FL 21</th>
							</tr>
							
							<cfif isdefined('Get_Report_2_data_2020.recordcount') and  Get_Report_2_data_2020.RecordCount GT 0>	
								<cfoutput query="Get_Report_2_data_2020">
									<tr style="font-family: Arial; font-size: 13px;">
										<td width="10%">#Get_Report_2_data_2020.M0_Item_Medication#</td>
										<td width="25%">#Get_Report_2_data_2020.Textfield_10#</td>
										<td width="30%">#Get_Report_2_data_2020.Memo#</td>
										<td width="30%" valign="top">#Get_Report_2_data_2020.Textfield_12#</td>	
									</tr>
								</cfoutput>							
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>					
						</table>
					</div>						
					<!---<br /><br /><br />--->
					<cfdocumentitem type="pagebreak">
            		</cfdocumentitem>
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 34px;font-weight:bold;">INSERT INTO CMS485</label>
							</div>
						</div>
						<br /><br />
					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">
												
							<tr style="font-family: Arial;">
								<th width="50%" height="40px">All Goals for CMS485 FL 22</th>
								<th width="50%">All Interventions for CMS485 FL 21</th>						
							</tr>
							
							<cfif isdefined('Get_Report_2_data_2020.recordcount') and  Get_Report_2_data_2020.RecordCount GT 0>	
									<tr style="font-family: Arial; font-size: 13px;">
										<td width="50%" valign="top">
											<cfoutput query="Get_Report_2_data_2020">
												<cfif #Get_Report_2_data_2020.Memo# neq "">
													#Get_Report_2_data_2020.Memo# <br />
												</cfif>
											</cfoutput>										
										</td>
										<td width="50%" valign="top">
											<cfoutput query="Get_Report_2_data_2020">
												<cfif #Get_Report_2_data_2020.Textfield_12# neq "">
													#Get_Report_2_data_2020.Textfield_12# <br />
												</cfif>
											</cfoutput>	
										</td>								
									</tr>
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="2" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>					
						</table>
					</div>				
				
				</cfif>
					
				</div>
	
			
				
	  
			<cfdocumentitem type="footer"  evalatprint="true">
				<table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
					<tr>
					  	<td>
							<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%" 
						  style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New; font-size: 22px; ">
							  <tr>
								<td height="8px"></td>
							  </tr>	
							  <tr>
								<td align="center" style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New;font-size: 26px;"> page <cfoutput>#cfdocument.currentpagenumber#</cfoutput> </td>
							  </tr>
							  <tr>
								<td height="10px"></td>
							  </tr>
							</table>
						</td>
					</tr>
				</table>
			</cfdocumentitem>  
		</cfdocumentsection>
	</cfdocument>


<cfelseif url.report_type EQ 4>


	<cfdocument format="pdf"  localURL = "yes"   margintop=".75" marginbottom="1.25"   orientation="landscape"  overwrite="yes"  filename="#save_file##recommended_reports#"   >
	
		<cfdocumentsection>	
		
		<div class="row">
		
			<div class="row">
				
				<div class="row">
					<div>
						<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">OASIS-D and PDGM Visit Utilization</label>
					</div>
				</div>
				<div class="row">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td align="left" width="45%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">							
																		<tr>				
										<td style="padding-left:20px; font-family: Arial; font-size: 24px; font-weight: bold;"><cfoutput>#Get_Assessment_Patient_data.PatientFirst# #Get_Assessment_Patient_data.PatientLast#</cfoutput></td>
									</tr>
									<tr>	
										<cfoutput>

										<cfset strSomestring = #Get_Assessment_Patient_data.Assessment_Reason_M0100#>
										<cfset SOC_String = find( "Start of care", strSomestring )>	
										<cfset Recertification_String = find( "Recertification", strSomestring )>
										<cfset Resumption_String = find( "Resumption", strSomestring )>
																						
										<td style="padding-left:30px; font-family: Arial; font-size: 20px; font-weight: bold;"><cfif #SOC_String# neq 0>Start of Care<cfelseif #Recertification_String# neq 0>Recertification<cfelseif #Resumption_String# neq 0>Resumption<cfelse>#Get_Assessment_Patient_data.Assessment_Reason_M0100#</cfif> #DateFormat(Get_Assessment_Patient_data.Assessment_Completed_M0090,"mm/dd/yy")#</td>
										</cfoutput>
									</tr>
								</table>
							</td>				
							<td align="right" width="25%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   
										</td>
									</tr>	
									
								</table>
							</td>	
							<td align="right" width="30%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   <cfif fileExists(TheFile)> 	
												<img src="file:///<cfoutput>#TheFile#</cfoutput>" width="100%" style="height:100px;">							
											<cfelse> 
												<img src="file:///var/www/img/MHCB_Logo.png" width="100%" style="height:100px;"> 
											</cfif>	
										</td>
									</tr>	
									
								</table>
							</td>	
							
						</tr>
					</table>		
				</div>
				<br />
			
			<cfquery name="Get_Report_data_all" datasource="#Application.DataSrc#">
				SELECT * FROM 
					#Request.prefix_db_agency#.Coding_Results 
				WHERE 
					Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
					AND Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer"> 
					AND ( M0_Item_Medication='(M1021)' or M0_Item_Medication='(M1023)' or M0_Item_Medication='OASIS' )	
               
			</cfquery>
                                 			
			<cfquery name="Get_Report_4_datas_User" datasource="#Application.DataSrc#">
				SELECT * FROM 
					 #Request.prefix_db_agency#.Coding_Results as r 
				JOIN 
					#Request.prefix_db_agency#.Coding_Scrub as s on s.patient_ID=r.Patient_ID and s.Assessment_ID=r.Assessment_ID and s.Message_ID = 76
				WHERE  
					r.Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
					AND r.Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer">
               		AND r.M0_Item_Medication like '%(M102%'
                	Order by r.Results_ID
			</cfquery>
			<cfquery name="Get_Report_4_datas" datasource="#Application.DataSrc#">
				SELECT * FROM 
					 #Request.prefix_db_agency#.Coding_Results as r 
				JOIN 
					#Request.prefix_db_agency#.Coding_Scrub as s on s.patient_ID=r.Patient_ID and s.Assessment_ID=r.Assessment_ID and s.Message_ID = 76
				WHERE  
					r.Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
					AND r.Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer">
                    AND r.Message_ID NOT IN (13,15,16)
                    and r.Textfield_10 IS NOT NULL
                and r.Message_ID != 78
                    Order by r.Results_ID
			</cfquery>

			
			<!---<cfquery name="Get_Report_4_Groupby" datasource="#Application.DataSrc#">
				SELECT * FROM #Request.prefix_db_agency#.Coding_Scrub					 
				WHERE  
					Patient_ID=<cfqueryparam value="#url.patient_id#" cfsqltype="cf_sql_integer"> 
					AND Assessment_ID=<cfqueryparam value="#url.assessment_id#" cfsqltype="cf_sql_integer">
					GROUP BY Patient_ID,Assessment_ID
			</cfquery>--->
			
			
			
			<cfif url.report_method eq "2019_OASIS_D">
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">2019 OASIS-D Coding Wizard-Recommended <font color="##0000FF">MEDICARE AVERAGE</font></label>
							</div>
						</div>
						<br /><br />					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">											
							<tr style="font-family: Arial;">
								<th width="100%">2019 OASIS D Analysis and Rationale</th>
							</tr>														
							<cfif isdefined('Get_Report_data_all.recordcount') and  Get_Report_data_all.RecordCount GT 0>														
								<cfoutput query="Get_Report_data_all">
									<tr style="font-family: Arial; font-size: 12px;">
										<td width="10%">#Get_Report_data_all.M0_Item_Medication#</td>
										<td width="45%">#Get_Report_data_all.Diagnosis#</td>
										<td width="45%">#Get_Report_data_all.Deficits#</td>	
									</tr>
								</cfoutput>			
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>												
						</table>
					</div>			
			<cfelseif url.report_method eq "2020_PDGM">			
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">2020 PDGM Coding Wizard-Recommended</label>
							</div>
						</div>
						<br /><br />					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">											
							<tr style="font-family: Arial;">
								<th width="10%" height="80px" width="80px">Skill</th>
								<th width="45%">User-entered Diagnosis List</th>
								<th width="45%">2020 PDGM Analysis and Rationale</th>
							</tr>
							<cfif isdefined('Get_Report_data_all.recordcount') and  Get_Report_data_all.RecordCount GT 0>	
								<cfoutput query="Get_Report_data_all">
									<tr style="font-family: Arial; font-size: 12px;">
										<td width="10%">#Get_Report_data_all.M0_Item_Medication#</td>
										<td width="45%">#Get_Report_data_all.Diagnosis#</td>
										<td width="45%">#Get_Report_data_all.Memo#</td>	
									</tr>
								</cfoutput>														
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>												
						</table>
					</div>	 
					
			<cfelseif url.report_method eq "utilization">	
			
					<!---<cfif CGI.REMOTE_ADDR eq "103.66.78.232">
						<cfdump var="#Get_Report_4_datas_User#">
						<cfabort>
					</cfif>--->
			
				<!---		
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">Visit Plan</label>
							</div>
						</div>
						<br /><br />--->					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">											
							<tr style="font-family: Arial;">
																<th width="100%">User-Entered Utilization and Rationale</th>
							</tr>
							<cfif isdefined('Get_Report_4_datas_User.recordcount') and  Get_Report_4_datas_User.RecordCount GT 0>	
								<cfset Report_4_count_chk = 0 />
								<cfoutput query="Get_Report_4_datas_User" group="Results_ID">
									<cfset Report_4_count_chk = Report_4_count_chk + 1 />
									<tr style="font-family: Arial; font-size: 14px;">
												<cfif #Report_4_count_chk# eq 1>
                                          <td width="100%" rowspan="#Get_Report_4_datas_User.RecordCount#" valign="top">
										  	<cfoutput>												
												<cfif #Get_Report_4_datas_User.Answer_1# neq "">
													#Get_Report_4_datas_User.Answer_1# <br />
												</cfif>												
											</cfoutput>
										  </td>	
                                          <cfelse>
											<td width="100%" style="display:none;"></td>
										</cfif>
									</tr>
								</cfoutput>	
								<cfset Report_4_count_chk = 0 />												
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>												
						</table>
					</div>
					<!---<br /><br />--->
					<cfdocumentitem type="pagebreak">
            		</cfdocumentitem>
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">2019 OASIS-D Coding Wizard-Recommended&nbsp;&nbsp;<font color="##0000FF">MEDICARE AVG</font></label>
							</div>
						</div>
						<br />					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">											
							<!---<tr style="font-family: Arial;">
								
								<th width="100%">2019 OASIS D Analysis and Rationale</th>
							</tr>--->
							<cfif isdefined('Get_Report_4_datas.recordcount') and  Get_Report_4_datas.RecordCount GT 0>	
								<cfset Report_4_count_chk_1 = 0 />
								<cfoutput query="Get_Report_4_datas"  group="Results_ID">
									<cfset Report_4_count_chk_1 = Report_4_count_chk_1 + 1 />
									<tr style="font-family: Arial; font-size: 14px;">
										<cfif #Report_4_count_chk_1# eq 1>
											<td width="100%" rowspan="#Get_Report_4_datas.RecordCount#" valign="top">
												<cfoutput>												
													<cfif #Get_Report_4_datas.Field_2# neq "">
														#Get_Report_4_datas.Field_2# <br />
													</cfif>												
												</cfoutput>
											</td>	
										<cfelse>
											<td width="100%" style="display:none;"></td>
										</cfif>										
									</tr>
								</cfoutput>	
								<cfset Report_4_count_chk_1 = 0 />													
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>												
						</table>
					</div>
					<!---<br /><br />--->
					<cfdocumentitem type="pagebreak">
            		</cfdocumentitem>
					<div class="row">			
						<div class="row">
							<div>
								<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">2020 PDGM Coding Wizard-Recommended</label>
							</div>
						</div>
						<br />					
						<table cellpadding="5" border="1" cellspacing="0" width="100%">											
							<!---<tr style="font-family: Arial;">
								<th width="70%">2020 PDGM Analysis and Rationale</th>
							</tr>--->
							<cfif isdefined('Get_Report_4_datas.recordcount') and  Get_Report_4_datas.RecordCount GT 0>	
								<cfset Report_4_count_chk_2 = 0 />
								<cfoutput query="Get_Report_4_datas" group="Results_ID">
									<cfset Report_4_count_chk_2 = Report_4_count_chk_2 + 1 />
									<tr style="font-family: Arial; font-size: 14px;">
										<cfif #Report_4_count_chk_2# eq 1>
											<td width="100%" rowspan="#Get_Report_4_datas.RecordCount#" valign="top">
												<cfoutput>												
													<cfif #Get_Report_4_datas.Field_7# neq "">
														#Get_Report_4_datas.Field_7# <br />
													</cfif>												
												</cfoutput>
											</td>	
										<cfelse>
											<td width="100%" style="display:none;"></td>
										</cfif>		
									</tr>
								</cfoutput>	
								<cfset Report_4_count_chk_2 = 0 />													
							<cfelse>
								<tr>
									<td align="center" valign="middle" colspan="4" height="50px">
										No Report Found
									</td>
								</tr>
							</cfif>												
						</table>
					</div>
			</cfif>				
		</div>	  
			<cfdocumentitem type="footer"  evalatprint="true">
				<table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
					<tr>
					  	<td>
							<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%" 
						  style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New; font-size: 22px; ">
							  <tr>
								<td height="8px"></td>
							  </tr>	
							  <tr>
								<td align="center" style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New;font-size: 26px;"> page <cfoutput>#cfdocument.currentpagenumber#</cfoutput> </td>
							  </tr>
							  <tr>
								<td height="10px"></td>
							  </tr>
							</table>
						</td>
					</tr>
				</table>
			</cfdocumentitem>  
		</cfdocumentsection>
	</cfdocument>

<cfelseif url.report_type EQ 5>

	<cfdocument format="pdf"  localURL = "yes"   margintop=".75" marginbottom="1.25"   orientation="landscape"  overwrite="yes"  filename="#save_file##recommended_reports#"   >
	
		<cfdocumentsection>	
		
		<div class="row">
			<div class="row">
				<!---<div class="row">
					<div>
						<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">REPORT <cfoutput>#url.report_type#</cfoutput> - Visit Plan</label>
					</div>
				</div>
				<br />--->
				
				<div class="row">
					<table cellpadding="0" cellspacing="0" border="0" width="100%">
						<tr>
							<td align="left" width="45%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">							
									<tr>
										<td height="2px"></td>
									</tr>
									<tr>				
										<td style="padding-left:0px; font-family: Arial; font-size: 28px; font-weight: bold;"><cfoutput>#Get_Assessment_Patient_data.PatientFirst# #Get_Assessment_Patient_data.PatientLast#</cfoutput>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!---</td>
									</tr>
									<tr>--->	
										<cfoutput>
										<cfset strSomestring = #Get_Assessment_Patient_data.Assessment_Reason_M0100#>
										<cfset SOC_String = find( "Start of care", strSomestring )>	
										<cfset Recertification_String = find( "Recertification", strSomestring )>
										<cfset Resumption_String = find( "Resumption", strSomestring )>
																						
										<td style="padding-left:50px; font-family: Arial; font-size: 24px; font-weight: bold;"><cfif #SOC_String# neq 0>Start of Care<cfelseif #Recertification_String# neq 0>Recertification<cfelseif #Resumption_String# neq 0>Resumption<cfelse>#Get_Assessment_Patient_data.Assessment_Reason_M0100#</cfif> #DateFormat(Get_Assessment_Patient_data.Assessment_Completed_M0090,"mm/dd/yy")#</td>
										</cfoutput>
									</tr>
								</table>
							</td>				
							<!---<td align="right" width="25%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   
										</td>
									</tr>	
									
								</table>
							</td>	
							<td align="right" width="30%">
								<table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr>
										<td>
										   <cfif fileExists(TheFile)> 	
												<img src="file:///<cfoutput>#TheFile#</cfoutput>" width="100%" style="height:100px;">							
											<cfelse> 
												<img src="file:///var/www/img/MHCB_Logo.png" width="100%" style="height:100px;"> 
											</cfif>	
										</td>
									</tr>	
									
								</table>
							</td>--->	
							
						</tr>
					</table>		
				</div>
				<br />
				
				<cfoutput>
				<cfparam name="Record_Type_Full" default = "">
				<cfif url.OASIS_D_PDGM_Visit eq "">					
				
						<cfif isdefined('Get_Report5_groupby.recordcount') and  Get_Report5_groupby.RecordCount GT 0>	
						   <cfset i = 1 >
							<cfloop query="Get_Report5_groupby">
							
								<cfscript>
									Get_coding_scrub_data_all = dashboard_component.Get_Report5_Visit_based(Patient_ID="#url.patient_id#",Assessment_ID="#url.assessment_id#",Risk_value="#Get_Report5_groupby.Risk#",Message_value="#Get_Report5_groupby.Message#");
								</cfscript>
							
								<cfif isdefined('Get_coding_scrub_data_all.recordcount') and  Get_coding_scrub_data_all.RecordCount GT 0>								
									<div class="row">
										<div>
											<label style="padding-left:50px; font-family: Arial; font-size: 24px;font-weight:bold;">VISIT PLAN FOR #Get_Report5_groupby.Risk#<!--- - #Get_Report5_groupby.Message#---></label>
										</div>
									</div>
									<br />
									<cfloop query="Get_coding_scrub_data_all">	
								   		<cfset i = 1 >						
										<div class="row">
											<div>
												<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">Visit #Get_coding_scrub_data_all.Message_ID#&nbsp;&nbsp;&nbsp;&nbsp;Goals of Visit: SYMPTOMS ARE MANAGED</label>
											</div>
										</div>
										<div class="row" style="height:10px;">							
										</div>					
										<table cellpadding="5" border="1" cellspacing="0" width="100%">	
											
											<tr style="font-family: Arial; font-size: 13px;">
												<td width="20%">GOALS Of VISIT #Get_coding_scrub_data_all.Message_ID# </td>
												<td width="80%">#Get_coding_scrub_data_all.Answer_1#</td>						
											</tr>
											<tr style="font-family: Arial; font-size: 13px;">
												<td width="20%">ASSESSMENT</td>
												<td width="80%">#Get_coding_scrub_data_all.Answer_2#</td>						
											</tr>		
											<tr style="font-family: Arial; font-size: 13px;">
												<td width="20%">PHYSICIAN FOLLOW-UP</td>
												<td width="80%">#Get_coding_scrub_data_all.GG_1#</td>						
											</tr>	
											<tr style="font-family: Arial; font-size: 13px;">
												<td width="20%">PERFORM</td>
												<td width="80%">#Get_coding_scrub_data_all.GG_2#</td>						
											</tr>
											<tr style="font-family: Arial; font-size: 13px;">
												<td width="20%">PATIENT TEACHING</td>
												<td width="80%">#Get_coding_scrub_data_all.Created_by#</td>						
											</tr>
											
										</table>
										<br />
										<cfset i = i + 1 >
										<cfdocumentitem type="pagebreak">
										</cfdocumentitem>
									</cfloop>
								</cfif>	
					
							</cfloop>
						<cfelse>
							<table>
								<tr>
									<td align="center" valign="middle" colspan="2" height="50px">
										No Report Found
									</td>
								</tr>
							</table>
						</cfif>	
						
				<cfelse>
					<cfset risk_message = url.OASIS_D_PDGM_Visit.Split("~")>	
					<cfset Record_Type_Full = #risk_message[1]#&" - "&#risk_message[2]# />
					<cfscript>
						Groupby_coding_scrub = dashboard_component.Get_Report5_Visit_based(Patient_ID="#url.patient_id#",Assessment_ID="#url.assessment_id#",Risk_value="#risk_message[1]#",Message_value="#risk_message[2]#");
					</cfscript>
                       

					<cfif isdefined('Groupby_coding_scrub.recordcount') and  Groupby_coding_scrub.RecordCount GT 0>	
					   <cfset j = 1 >					   		
					   		<div class="row">
								<div>
									<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">VISIT PLAN FOR #Record_Type_Full#</label>
								</div>
							</div>
							<br />
						<cfloop query="Groupby_coding_scrub">
							<div class="row">
								<div>
									<!---<label style="padding-left:0px; font-family: Arial; font-size: 20px;font-weight:bold;">Visit #Groupby_coding_scrub.Message_ID#</label>--->
                                    <label style="padding-left:0px; font-family: Arial; font-size: 18px;font-weight:bold;">Visit&nbsp;#Groupby_coding_scrub.Message_ID#&nbsp;<cfif Record_Type_Full contains 'SN'>Goals: Symptoms are managed<cfif #Groupby_coding_scrub.Message_ID# neq 1>;&nbsp;#Groupby_coding_scrub.Subject#</cfif></cfif></label>
								</div>
							</div>
							<div class="row" style="height:10px;">							
							</div>					
							<table cellpadding="5" border="1" cellspacing="0" width="100%">	
								<cfif Record_Type_Full contains 'PT' or Record_Type_Full contains 'OT'>
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="20%">GOALS for VISIT #Message_ID# </td>
									<td width="80%">#Groupby_coding_scrub.Answer_1#</td>					
								</tr></cfif>
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="10%">ASSESSMENT</td>
									<td width="90%">#Groupby_coding_scrub.Answer_2#</td>						
								</tr>		
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="10%">PHYSICIAN FOLLOW-UP</td>
									<td width="90%">#GG_1#</td>						
								</tr>	
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="10%">PERFORM</td>
									<td width="90%">#Groupby_coding_scrub.GG_2#</td>						
								</tr>
								<tr style="font-family: Arial; font-size: 13px;">
									<td width="10%">TEACHING</td>
									<td width="90%">#Groupby_coding_scrub.Created_by#</td>						
								</tr>
								
							</table>
							<br />
							<cfset j = j + 1 >
							<cfdocumentitem type="pagebreak">
							</cfdocumentitem>
						</cfloop>				
					<cfelse>
						<table>
							<tr>
								<td align="center" valign="middle" colspan="2" height="50px">
									No Report Found
								</td>
							</tr>
						</table>
					</cfif>	
					
				</cfif>
						
						
									
				</cfoutput>	
			</div>
		</div>
			
			<cfdocumentitem type="footer"  evalatprint="true">
				<table cellpadding="0" align="center" style="border-top:: solid 1px black;" cellspacing="0" border="0" height="150px" width="100%">
					<tr>
					  	<td>
							<table align="center" cellpadding="0" cellspacing="0" border="0" width="100%" 
						  style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New; font-size: 22px; ">
							  <tr>
								<td height="2px"></td>
							  </tr>	
							  <tr>
								<td align="center" style="font-family: font-family: Consolas, 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', Monaco, 'Courier New;font-size: 26px;"><cfoutput>#Record_Type_Full#&nbsp;Visit Plan for #Get_Assessment_Patient_data.PatientFirst#&nbsp;#Get_Assessment_Patient_data.PatientLast#</cfoutput><br><cfoutput>page #cfdocument.currentpagenumber#</cfoutput> </td>
							  </tr>
							  <!---<tr>
								<td height="2px"></td>
							  </tr>--->
							</table>
						</td>
					</tr>
				</table>
			</cfdocumentitem>  
		</cfdocumentsection>
	</cfdocument>

</cfif>
<cfelse>
	<p>Cannot be reloaded. Please go back to <a href="../dashboard/index.cfm?page=dashboard&cat=dashboard&rpt=coding_wizard_dashboard">coding wizard report</a>dashboard and please print report once again</p>
</cfif>