Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Margaret
Creator II
Creator II

Opioids prescribed per Emergency Department visit

I need to calculate the rate at which various providers prescribe controlled substances:

For each provider: Count(Rx)  /  Count(Visits)  

Sometimes a provider prescribes a medication to a patient they aren't assigned to.

Sometimes more than one provider is assigned to a single patient.

Here are the two tables I have:   

Account NumberRx ProviderMedicationRx ID
12667Brown, PAHYDROmorphone HCL15213627357
12667Brown, PAHYDROmorphone HCL15233728439
12667Dr. McDonaldfentaNYL15182933689-2
12667Dr. McDonaldHYDROCO37|Hydrocodone15194001371
12667Dr. McDonaldHYDROCOD/APAP 5/325 15193742325
12667Dr. McDonaldHYDROmorphone HCL15182933689
27025Dr. RodriguezchlordiazePOXIDE 25MG 29011739391
27025Dr. WongLORazepam28222549500-2
27025Dr. WilsonLORazepam28232607599

Account NumberVisit Provider
12667Brown, PA
27025Dr. Rodriguez
27025Dr Wong
27025Dr Wilson

I would like to create an object for the end user that looks like this:    

ProviderRx'sVisitsRx's/Visit
Brown, PA212/1
Dr. McDonald4           04/0
Dr. Rodriguez111/1
Dr. Wong111/1
Dr. Wilson111/1

(I also need to make a line graph showing Providers Rx/Visit rate over time with MonthYear as the X axis--so if I end up having to count providers visits in the script, somehow I would have to relate it back to my Calendar table.)

11 Replies
Margaret
Creator II
Creator II
Author

Yes 😞

Anonymous
Not applicable

Try using the Total() function.  I had something similar with months and used it like this:

count({<Year={'$(=max(Year))'}>}TOTAL<DispMonth> Distinct ACCOUNT_ID).

I was getting the same count for each month but this separated it into counts for each individual month.