The purpose of the report I'm trying to create is to find out if a member is being brought
back to a clinic several times (separate DOS) to have multiple procedures performed.
Each of the 6 procedures (LINE_CODE) listed in my basic code below HAS THE POSSIBILITY OF BEING DONE ON BOTH THE RT AND LT SIDES OF THE BODY, so essentially, I'd like to show every possible combination (12 procedures) for any given member, even if he isn't having all performed.
I think to show this data most effectively to the provider will be to show a format similar to as follows:
MEMBER DOS PROC1_RT DONE PROC1_LT NOT DONE (checks) ...PROC12_LT... PAID AMT/DOS
A 1/5/11 1 0 0 $1000
A 1/12/11 0 1 0 $500
A 1/12/11 1 0 0 $200
Then later I can do summary statistics on the counts per member (make sure procedures aren't being duplicated unnecessarily) and average costs per procedure...
Anyhow, any advice is much appreciated; thank you
Current coding - gets all members having these procedures:
SELECT DISTINCT MC.MEMBER
, CASE WHEN MCD.LINE_CODE IN('36478','36479') THEN 'LASER'
WHEN MCD.LINE_CODE IN('36470','36471') THEN 'UGS'
WHEN MCD.LINE_CODE IN('36011','37204') THEN 'TCC'
END AS TX
FROM #temp_CLAIMS_MC MC
INNER JOIN MASTER_CLAIM#DETAIL mcd ON mc.[DOCUMENT] = mcd.[DOCUMENT]
WHERE (MCD.LINE_CODE IN('36478','36479','36470','36471','36011','37204') )
OR (MCD.MOD2 IN('RT','LT')))
ORDER BY MC.MEMBER, MCD.LINE_CODE, MCD.MOD1, MCD.MOD2, FIRST_DOS
--counting the distinct procedures:
, COUNT(DISTINCT PROCD) AS COUNT_DISTINCT_PROCS
GROUP BY MEMBER
ORDER BY COUNT(DISTINCT PROCD) DESC