[613] | 1 | SPNLRL1 ;ISC-SF/GB-SCD PHARMACY UTILIZATION REPORT (PRINT PART 1 OF 3) ;4 JUN 94 [ 08/23/94 10:04 AM ]
|
---|
| 2 | ;;2.0;Spinal Cord Dysfunction;;01/02/1997
|
---|
| 3 | ; PAGELEN Number of lines per page
|
---|
| 4 | ; TITLE Array of header lines (titles)
|
---|
| 5 | P1(TITLE,PAGELEN,ABORT) ;
|
---|
| 6 | ; NDDRUGS Number of different types of drugs
|
---|
| 7 | ; ZDRUGNR Internal Entry Number of a drug in ^PSDRUG
|
---|
| 8 | ; FILLS Number of fills given
|
---|
| 9 | N NDDRUGS,ZDRUGNR,FILLS,OUT,LINE,STARTLIN,COL,NPATS
|
---|
| 10 | S TITLE(4)=""
|
---|
| 11 | S FILLS=+$G(^TMP("SPN",$J,"RX","FILLS"))
|
---|
| 12 | S NPATS=+$G(^TMP("SPN",$J,"RX","PAT"))
|
---|
| 13 | S TITLE(5)=$$CENTER^SPNLRU("Totals: "_$FN(FILLS,",")_" fill"_$S(FILLS=1:"",1:"s")_" reported for "_$FN(NPATS,",")_" patient"_$S(NPATS=1:"",1:"s"))
|
---|
| 14 | S ZDRUGNR=""
|
---|
| 15 | F NDDRUGS=0:1 S ZDRUGNR=$O(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR)) Q:ZDRUGNR=""
|
---|
| 16 | S:NDDRUGS=1&(FILLS>1) TITLE(6)=$$CENTER^SPNLRU("(This includes just one type of drug)")
|
---|
| 17 | S:NDDRUGS>1 TITLE(6)=$$CENTER^SPNLRU("(These include "_$FN(NDDRUGS,",")_" different drugs)")
|
---|
| 18 | S FILLS=+$O(^TMP("SPN",$J,"RX","FILLS",""))
|
---|
| 19 | F D Q:FILLS=""!(ABORT)
|
---|
| 20 | . D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
|
---|
| 21 | . K OUT,TITLE(4),TITLE(5),TITLE(6)
|
---|
| 22 | . S STARTLIN=$Y
|
---|
| 23 | . S OUT(STARTLIN+1)=""
|
---|
| 24 | . F COL=1:1:3 D Q:FILLS=""
|
---|
| 25 | . . S OUT(STARTLIN)=$G(OUT(STARTLIN))_" Patients Fills "
|
---|
| 26 | . . F LINE=STARTLIN+2:1:PAGELEN D Q:FILLS=""
|
---|
| 27 | . . . S OUT(LINE)=$G(OUT(LINE))_$J($FN($G(^TMP("SPN",$J,"RX","FILLS",FILLS)),","),10)_$J($FN(-FILLS,","),11)_" "
|
---|
| 28 | . . . S FILLS=$O(^TMP("SPN",$J,"RX","FILLS",FILLS))
|
---|
| 29 | . S LINE=""
|
---|
| 30 | . F S LINE=$O(OUT(LINE)) Q:LINE="" D
|
---|
| 31 | . . W !,OUT(LINE)
|
---|
| 32 | Q
|
---|
| 33 | P2(TITLE,PAGELEN,QLIST,ABORT) ;
|
---|
| 34 | N NPATS,ZDRUGNR,FILLS,MAXPATS,MAXFILLS,NAME
|
---|
| 35 | S TITLE(4)=""
|
---|
| 36 | S TITLE(5)=$$CENTER^SPNLRU("Drugs with "_$FN(QLIST("MINFILL"),",")_" or more fills")
|
---|
| 37 | ; TITLE(6)=" 1 2 3 4 5 6 7 8"
|
---|
| 38 | S TITLE(6)=""
|
---|
| 39 | S TITLE(7)=" Max # Fills"
|
---|
| 40 | S TITLE(8)="Drug Fills Patients (# patients)"
|
---|
| 41 | D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
|
---|
| 42 | S ZDRUGNR=""
|
---|
| 43 | F S ZDRUGNR=$O(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR)) Q:ZDRUGNR="" D
|
---|
| 44 | . S FILLS=^TMP("SPN",$J,"RX","DRUG",ZDRUGNR)
|
---|
| 45 | . Q:FILLS<QLIST("MINFILL")
|
---|
| 46 | . S NPATS=^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"PAT")
|
---|
| 47 | . S NAME=^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"NAME")
|
---|
| 48 | . S ^TMP("SPN",$J,"RX","OUT",-FILLS,-NPATS,NAME)=ZDRUGNR
|
---|
| 49 | S FILLS=""
|
---|
| 50 | F S FILLS=$O(^TMP("SPN",$J,"RX","OUT",FILLS)) Q:FILLS="" D Q:ABORT
|
---|
| 51 | . S NPATS=""
|
---|
| 52 | . F S NPATS=$O(^TMP("SPN",$J,"RX","OUT",FILLS,NPATS)) Q:NPATS="" D Q:ABORT
|
---|
| 53 | . . S NAME=""
|
---|
| 54 | . . F S NAME=$O(^TMP("SPN",$J,"RX","OUT",FILLS,NPATS,NAME)) Q:NAME="" D Q:ABORT
|
---|
| 55 | . . . I $Y>PAGELEN D HEADER^SPNLRU(.TITLE,.ABORT) Q:ABORT
|
---|
| 56 | . . . S ZDRUGNR=^TMP("SPN",$J,"RX","OUT",FILLS,NPATS,NAME)
|
---|
| 57 | . . . S MAXFILLS=$O(^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"FILLS",""))
|
---|
| 58 | . . . S MAXPATS=^TMP("SPN",$J,"RX","DRUG",ZDRUGNR,"FILLS",MAXFILLS)
|
---|
| 59 | . . . W !,NAME,?40,$J($FN(-FILLS,","),10),?52,$J($FN(-NPATS,","),10)
|
---|
| 60 | . . . I FILLS'=NPATS&(-FILLS>1)&(-NPATS>1) W ?65,$J($FN(-MAXFILLS,","),9)," (",MAXPATS,")"
|
---|
| 61 | . . . ; See what IMRWRCP1 does here for national report.
|
---|
| 62 | K ^TMP("SPN",$J,"RX","OUT")
|
---|
| 63 | K TITLE(4),TITLE(5),TITLE(6),TITLE(7),TITLE(8)
|
---|
| 64 | Q
|
---|