We know that about 25% of patients stop coming after the third session (including intake). (Another query tells us that). We are interested in surveying these patients to learn what we could have done better to have them stay in treatment (assuming that in most cases, successful psychotherapy takes more than 3 sessions).
So, I’d like to query out patients with an intake in the last 8 months, who were seen for three or less sessions and who have not had a treatment session for at least the last 60 days. One needs to keep in mind that I want to count only active treatment sessions, not finance charges, records request, no show fees or any other non-treatment session.
SELECT
lastname, firstname, id,
lfeedate AS "Last Service",
priprvcode AS "primary Provider",
(SELECT COUNT(DISTINCT a.trandate)
FROM sos.journal a JOIN sos.jcharges b ON a.jnum = b.jnum
WHERE a.ptnum = pt.ptnum
AND servicenum IN
(SELECT servicenum
FROM sos.services
WHERE srvcode IN ( 'A','B','C' ) ) )
/*replace 'A','B','C' above with the codes you want to count */
AS "SrvDateCount"
FROM
sos.rv_patients AS pt
WHERE
IntakeDate BETWEEN (TODAY( ) - 240) AND TODAY()
/*automatically does last 8 months. Note that TODAY() returns the same value as "CURRENT DATE" */
AND lfeedate < (CURRENT DATE - 90)
AND SrvDateCount <= 3