<!---diagnosis.cfc--->
<cfcomponent displayname="Diagnosis"  hint="ColdFusion Component forDiagnosis">
<cfinclude template='/__Security-Block.cfm' />   
    
    <cffunction name="get_diagnosis"  access="remote" output="Yes" returntype="query">   
           <cfargument name="ICD" required="yes" hint="ICD">	
            <cfquery name="get_pathway" datasource="#Application.DataSrc#">
				SELECT * FROM  #Request.prefix_db_lookup#.vetted_190924 as vt 
				JOIN #Request.prefix_db_lookup#.CW_Coding_Class_PDGM  as cw ON  vt.Priority = cw.Priority
				WHERE vt.Pathway = cw.Pathway_ID
				AND vt.ICD = <cfqueryparam value="#arguments.Pathway#" cfsqltype="CF_SQL_INTEGER">
			</cfquery>
           <cfreturn get_pathway>
   </cffunction>  
                
  <cffunction name="Search_diagnosis"  access="remote" output="Yes" returntype="query">   
           <cfargument name="text" required="yes" hint="text">   
            <cfargument name="mainfestation"  default ="0" hint="text">   
           <cfquery name="get_diag" datasource="#Application.DataSrc#">
                  SELECT vt.id  as id,vt.Diagnosis,vt.ICD as ICD,'ICD' as Code_Type,cw.Default as Pathway_Type,vt.Diagnosis_Short as Short_Diagnosis, vt.Comorbid as Other_DG,vt.PDGM,vt.Comorbid
                    FROM  #Request.prefix_db_lookup#.vetted_190924 as vt
                    JOIN #Request.prefix_db_lookup#.CW_Coding_Class_PDGM  as cw ON     vt.Pathway = cw.Pathway_ID
                    WHERE 
                    <!---  vt.Pathway = cw.Pathway_ID AND --->
                  (vt.Diagnosis LIKE <cfqueryparam value = "%#Trim(arguments.text)#%" CFSQLType ="CF_SQL_VARCHAR"> OR vt.ICD LIKE <cfqueryparam value = "%#Trim(arguments.text)#%" CFSQLType ="CF_SQL_VARCHAR">) 
                   <cfif arguments.mainfestation neq 0>
                      AND vt.MANIFESTATION_FLAG  = <cfqueryparam value="#arguments.mainfestation#" cfsqltype="CF_SQL_INTEGER">
                    </cfif>
                    GROUP BY vt.ID
                    Order by vt.ICD  
             </cfquery>
             <cfreturn get_diag>  
    </cffunction>
               
    <cffunction name="get_diagnosis_ID"  access="remote" output="Yes" returntype="query">   
           <cfargument name="DiagnosisID" required="yes" hint="DiagnosisID">	
            <cfquery name="diagnosis" datasource="#Application.DataSrc#">
				SELECT vt.id  as id,vt.Diagnosis,vt.ICD as ICD,'ICD' as Code_Type,cw.Default as Pathway_Type,vt.Diagnosis_Short as Short_Diagnosis, vt.Comorbid as Other_DG,vt.PDGM,vt.Comorbid
                FROM  #Request.prefix_db_lookup#.vetted_190924 as vt 
				JOIN #Request.prefix_db_lookup#.CW_Coding_Class_PDGM  as cw ON  vt.Priority = cw.Priority
				WHERE  vt.ID = <cfqueryparam value="#arguments.DiagnosisID#" cfsqltype="CF_SQL_INTEGER">
			</cfquery>
           <cfreturn diagnosis>
    </cffunction> 
                
       <cffunction name="ass_diag"  access="remote" output="Yes" returntype="query">
           <cfargument name="Patient_ID" required="yes" hint="Patient_ID">	
           <cfargument name="Assessment_ID" required="yes" hint="Assessment_ID">	
            <cfquery name="diagnosis" datasource="#Application.DataSrc#">
				SELECT * FROM  #Request.prefix_db_agency#.Diagnosis 
				WHERE  Patient_ID = <cfqueryparam value="#arguments.Patient_ID#" cfsqltype="CF_SQL_INTEGER">
                AND Assessment_ID = <cfqueryparam value="#arguments.Assessment_ID#" cfsqltype="CF_SQL_INTEGER">
                AND  M0230_Link like '%M0230%' and M0230_Link is not null AND Disabled <> 1 
                ORDER BY Dx_Order ASC 
			</cfquery>
           <cfreturn diagnosis>
   </cffunction>           
                
               
  </cfcomponent>