work_samples/troll_path.rb
def ditch_nonos(mssql)
  num_nonos = 0
  join_condition = %{from path_reports as p INNER JOIN
          CHSDwNoContact.dbo.nono as n
          on p.mrn = n.chsid}
  sql_count = %{select count(*) as num #{join_condition}}
  sql_ditch = %{delete from path_reports where id in (select id #{join_condition}) }
  num_nonos = mssql.select_one(sql_count)['num']
  if num_nonos > 0 then
    mssql.do(sql_ditch)
    "Removed #{num_nonos} reports for people on the NONO list.\n"
  else
    "None of the new path reports were for people who have opted out of GHRI research.\n"
  end
end
  So--we have the path reports of interest stored in path_reports, along with their PCPs.
  We need:
    - Check if the person is already in Recruits
      - if yes--were they rejected on the basis of a prior path report?
        - if yes
            - Replace their earlier 'Path Report REJECTED' status with a 'Prior Path Report REJECTED' status.
            - Add a 'Path report ACCEPTED' or 'Path review Required' status as necessary.
        - if not, copy their recruitid to the path report

    New info to gather:
    - consumno (b/c Survey wants it) (csr_dem)
    - StudyID (just copy recruitid?)
    - Full name (csr_id)
    - Residential address (csr_id.CSR_ADR_LN1 et seq.)
    - DOB (csr_dem)
    - Sex (csr_dem)

So--we have the path reports of interest stored in path_reports, along with their PCPs.
We need:
Check if the person is already in Recruits
if yes--were they rejected on the basis of a prior path report.
if yes
Replace their earlier 'Path Report REJECTED' status with a 'Prior Path Report REJECTED' status.
Add a 'Path report ACCEPTED' or 'Path review Required' status as necessary.
if not, copy their recruitid to the path report


So -- we have the path reports of interest stored in path_reports along with their PCPs . We need : Check if the person is already in Recruits if yes -- were they rejected on the basis of a prior path report . if yes Replace their earlier ' Path Report REJECTED ' status with a ' Prior Path Report REJECTED ' status . Add a ' Path report ACCEPTED ' or ' Path review Required ' status as necessary . if not copy their recruitid to the path report
def ditch_nonos(mssql)
  num_nonos = 0
  join_condition = %{from path_reports as p INNER JOIN
          CHSDwNoContact.dbo.nono as n
          on p.mrn = n.chsid}
  sql_count = %{select count(*) as num #{join_condition}}
  sql_ditch = %{delete from path_reports where id in (select id #{join_condition}) }
  num_nonos = mssql.select_one(sql_count)['num']
  if num_nonos > 0 then
    mssql.do(sql_ditch)
    "Removed #{num_nonos} reports for people on the NONO list.\n"
  else
    "None of the new path reports were for people who have opted out of GHRI research.\n"
  end
end
def ditch_nonos ( mssql ) num_nonos = 0 join_condition = %{from path_reports as p INNER JOIN
          CHSDwNoContact.dbo.nono as n
          on p.mrn = n.chsid} sql_count = %{select count(*) as num #{join_condition}} sql_ditch = %{delete from path_reports where id in (select id #{join_condition}) } num_nonos = mssql . select_one ( sql_count ) [ 'num' ] if num_nonos > 0 then mssql . do ( sql_ditch ) "Removed #{num_nonos} reports for people on the NONO list.\n" else "None of the new path reports were for people who have opted out of GHRI research.\n" end end
So--we have the path reports of interest stored in path_reports, along with their PCPs.
So -- we have the path reports of interest stored in path_reports along with their PCPs .
mssql