delete from #Request.prefix_db_agency#.Coding_Scrub
where Assessment_ID = #url.AID#
select *
from #Request.prefix_db_agency#.Assessment_New
where Assessment_ID = #url.AID#
select *
from #Request.prefix_db_agency#.patient
where Patient_ID = #url.ID#
select * from #Request.prefix_db_agency#.Coding_Results where Assessment_ID = #url.AID# and Diagnosis like '%diabetes%' and (Message_ID != '14' and Message_ID != '15')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','201','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
select * from #Request.prefix_db_agency#.Coding_Results where Assessment_ID = #url.AID# and Diagnosis like '%diabetes%' and (Message_ID != '14' and Message_ID != '15')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','202','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
select * from #Request.prefix_db_agency#.Coding_Results where Assessment_ID = #url.AID# and (ICD like '%I70%' or ICD like '%I73%')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','203','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
select * from #Request.prefix_db_agency#.Coding_Results where Assessment_ID = #url.AID# and (ICD like '(I70%' or ICD like '(I73%')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','204','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','211','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','212','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','213','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','215','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','216','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Results
(Assessment_ID,Patient_ID,Message_ID,M0_Item_Medication,Order_ID,Diagnosis,OASIS,Medications,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'20','Inconsistency','217','#Diagnosis#','#OASIS#','#medications#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#Answer_1#','#Answer_2#','#GG_1#','#GG_2#','#M0_Item#','#Subject#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,GG_1Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'120','#Answer_1#','#GG_1#','#DateFormat(Now(),"yyyy-mm-dd")#')
select *
from #Request.prefix_db_lookup#.Therapy_Utilization
where Code = '#M0_Item#'
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,'#Message_ID#','#OT_Goals#','#PT_Goals#','#OT_Count#','#PT_Count#','#M0_Item#','#Goals#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
select *
from #Request.prefix_db_agency#.Coding_Scrub
where Assessment_ID = #url.AID#
and Patient_ID = #url.ID#
and Message_ID = 114
Update #Request.prefix_db_agency#.Coding_Scrub
set Short = '#NewHIPPS#', Risk_Type = '#OldHIPPS#'
where Assessment_ID = #url.AID#
and Patient_ID = #url.ID#
and Message_ID = 114
select t.ID
from #Request.prefix_db_agency#.Coding_Scrub c, #Request.prefix_db_lookup#.Utilization_Schedules t
where c.Assessment_ID = #url.AID#
and c.Patient_ID = #url.ID#
and c.Message_ID = 114
and Left(c.Short,4) = t.HIPPS_Code
and c.Message = t.Utilization
and t.Therapy_Visits = #Desired#
INSERT IGNORE INTO #Request.prefix_db_agency#.Coding_Scrub
(Assessment_ID,Patient_ID,Message_ID,Answer_1,Answer_2,GG_1,GG_2,M0_Item,Subject,Desired,Message,Created_Date)
VALUES (#Assessment_ID#,#Patient_ID#,115,'#Answer_1#','#Answer_2#','#GG_1#','#Sched#','#M0_Item#','#Goals#','#Desired#','#Message#','#DateFormat(Now(),"yyyy-mm-dd")#')
Update #Request.prefix_db_agency#.Coding_Scrub
set Short = '#NewHIPPS#', Risk_Type = '#OldHIPPS#'
where Assessment_ID = #url.AID#
and Patient_ID = #url.ID#
and Message_ID = 115