source: WorldVistAEHR/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLRS1.m

Last change on this file was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.8 KB
Line 
1SPNLRS1 ;ISC-SF/GB-SCD PHARMACY UTILIZATION (SPECIFIC) REPORT (PART 1 OF 1) ;6/23/95 12:03
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3P1(TITLE,PAGELEN,QLIST,ABORT) ;
4 ; PID Patient Name
5 ; PSSN Patient SSN
6 N NPATS,ZDRUGNR,FILLS,ZDRUG,ZDRUGNAM,PID,PNAME,PSSN,QTY,COST,PRICE,PDATA
7 S TITLE(4)=""
8 S TITLE(7)=""
9 ; TITLE(7)=" 1 2 3 4 5 6 7 8"
10 S TITLE(8)="Patient Name SSN Fills Qty Value"
11 S ZDRUGNR="" ; create list in drug name order
12 F S ZDRUGNR=$O(QLIST(ZDRUGNR)) Q:ZDRUGNR="" D
13 . S ZDRUG(QLIST(ZDRUGNR))=ZDRUGNR
14 S ZDRUGNAM=""
15 F S ZDRUGNAM=$O(ZDRUG(ZDRUGNAM)) Q:ZDRUGNAM="" D
16 . S ZDRUGNR=ZDRUG(ZDRUGNAM)
17 . S PRICE=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PRICE"))
18 . S TITLE(5)=$$CENTER^SPNLRU(ZDRUGNAM_", currently $"_$FN(PRICE,",",4)_"/unit")
19 . S FILLS=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR))
20 . S NPATS=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PAT"))
21 . S QTY=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"QTY"))
22 . S COST=QTY*PRICE
23 . S TITLE(6)=$$PAD^SPNLRU("Total: "_$FN(NPATS,",")_" patient"_$S(NPATS=1:"",1:"s"),45)_$J($FN(FILLS,","),11)_$J($FN(QTY,","),11)_$J("$"_$FN(COST,",",2),14)
24 . D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
25 . K TITLE(6)
26 . S PID=""
27 . F S PID=$O(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PID",PID)) Q:PID="" D Q:ABORT
28 . . I $Y>PAGELEN D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
29 . . S PNAME=$P(PID,U,1),PSSN=$P(PID,U,2)
30 . . S PDATA=^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PID",PID)
31 . . S FILLS=+$P(PDATA,U,1),QTY=+$P(PDATA,U,2)
32 . . S COST=QTY*PRICE
33 . . W !,PNAME,?32,PSSN,?44,$J($FN(FILLS,","),11),?54,$J($FN(QTY,","),11),?66,$J($FN(COST,",",2),14)
34 K TITLE(4),TITLE(5),TITLE(7),TITLE(8)
35 Q
36P2(TITLE,PAGELEN,QLIST,ABORT) ;
37 N NPATS,ZDRUGNR,FILLS,ZDRUG,ZDRUGNAM,PID,QTY,COST,PRICE
38 S TITLE(4)=""
39 ; TITLE(5)=" 1 2 3 4 5 6 7 8"
40 S TITLE(5)="Drug Unit Cost Pats Fills Units Value"
41 ; "12345678901234567890123456789012345 XX.XXXX XX,XXX XX,XXX XXX,XXX X,XXX,XXX.XX"
42 S ZDRUGNR="" ; create list in drug name order
43 F S ZDRUGNR=$O(QLIST(ZDRUGNR)) Q:ZDRUGNR="" D
44 . S ZDRUG(QLIST(ZDRUGNR))=ZDRUGNR
45 D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
46 S ZDRUGNAM=""
47 F S ZDRUGNAM=$O(ZDRUG(ZDRUGNAM)) Q:ZDRUGNAM="" D Q:ABORT
48 . D:$Y>PAGELEN HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
49 . S ZDRUGNR=ZDRUG(ZDRUGNAM)
50 . S PRICE=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PRICE"))
51 . S FILLS=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR))
52 . S NPATS=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PAT"))
53 . S QTY=+$G(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"QTY"))
54 . S COST=QTY*PRICE
55 . W !,$E(ZDRUGNAM,1,36),?36,$J($FN(PRICE,",",4),7),?44,$J($FN(NPATS,","),7),?52,$J($FN(FILLS,","),7),?60,$J($FN(QTY,","),7),?68,$J($FN(COST,",",2),12)
56 K TITLE(4),TITLE(5)
57 Q
Note: See TracBrowser for help on using the repository browser.