ACDWRP5 ;IHS/ADC/EDE/KML - REPORT GENERATOR;
;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
;Report 2,3,4,5,6,7,50,51,52,53,54,55,56,63,64,65
I '$D(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL")) D ^ACDWK Q
S (ACDGTOT,ACDGTOT1)=0
D C S ACDP1="" F D F Q:$D(DIRUT) S ACDP1=$O(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1)) Q:ACDP1="" W !,$E(ACDP1,1,24) D P1 Q:$D(DIRUT)
I $D(DIRUT) D ^ACDWK Q ; quit if user entered "^"
I ACDTG="G51"!(ACDTG="G3") W !!! F ACDLP=0:0 S ACDLP=$O(^ACDDRUG(ACDLP)) Q:'ACDLP I $D(^(ACDLP,0)) S ACDRUG=$P(^(0),U,2)_"="_$P(^(0),U) I '$D(ACDRUG(ACDRUG)) W !,ACDRUG,?67,"NO DATA FOUND"
I ACDTG="G51"!(ACDTG="G3")!(ACDTG="G7")!(ACDTG="G64") D COMB
D ^ACDWK Q
P1 ;
I ACDTG="G51"!(ACDTG="G3") S ACDRUG(ACDP1)=""
S (ACDSTOT,ACDSTOT1)=0 F ACDP2=0:0 D F Q:$D(DIRUT) S ACDP2=$O(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1,ACDP2)) Q:'ACDP2 D P2 Q:$D(DIRUT)
Q:$D(DIRUT)
W ?26,ACDSTOT,?48,ACDSTOT1,?74,$J(ACDSTOT1/ACDSTOT,5,2),!
Q
P2 ;
S ACDSTOT=ACDSTOT+1,ACDSTOT1=ACDSTOT1+^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1,ACDP2)
Q
F ;Form feed
I $Y+4>IOSL D F^ACDWUTL D:'$D(DIRUT) C
Q
C ;Column
W !!,ACDC(1),?26,ACDC(2),?48,ACDC(3),?72,ACDC(4),!,ACDH(1),!
Q
COMB ;List patients on more than 1 drug i.e. combination drugs.
W !!!,"COMBINATIONS ARE AS FOLLOWS:",!
S ACDP1=""
F S ACDP1=$O(^TMP("CDMIS",$J,ACDP1)) Q:ACDP1="" D Q:$D(DIRUT)
. S ACDP2=0
. F ACDNUM=0:1 S ACDP2=$O(^TMP("CDMIS",$J,ACDP1,ACDP2)) Q:'ACDP2
. D F Q:$D(DIRUT) W ACDP1,?67,"CLIENTS = ",?74,$J(ACDNUM,3),!
. Q
Q
ACDWRP5 ;IHS/ADC/EDE/KML - REPORT GENERATOR;
+1 ;;4.1;CHEMICAL DEPENDENCY MIS;;MAY 11, 1998
+2 ;Report 2,3,4,5,6,7,50,51,52,53,54,55,56,63,64,65
+3 IF '$DATA(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL"))
DO ^ACDWK
QUIT
+4 SET (ACDGTOT,ACDGTOT1)=0
+5 DO C
SET ACDP1=""
FOR
DO F
IF $DATA(DIRUT)
QUIT
SET ACDP1=$ORDER(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1))
IF ACDP1=""
QUIT
WRITE !,$EXTRACT(ACDP1,1,24)
DO P1
IF $DATA(DIRUT)
QUIT
+6 ; quit if user entered "^"
IF $DATA(DIRUT)
DO ^ACDWK
QUIT
+7 IF ACDTG="G51"!(ACDTG="G3")
WRITE !!!
FOR ACDLP=0:0
SET ACDLP=$ORDER(^ACDDRUG(ACDLP))
IF 'ACDLP
QUIT
IF $DATA(^(ACDLP,0))
SET ACDRUG=$PIECE(^(0),U,2)_"="_$PIECE(^(0),U)
IF '$DATA(ACDRUG(ACDRUG))
WRITE !,ACDRUG,?67,"NO DATA FOUND"
+8 IF ACDTG="G51"!(ACDTG="G3")!(ACDTG="G7")!(ACDTG="G64")
DO COMB
+9 DO ^ACDWK
QUIT
P1 ;
+1 IF ACDTG="G51"!(ACDTG="G3")
SET ACDRUG(ACDP1)=""
+2 SET (ACDSTOT,ACDSTOT1)=0
FOR ACDP2=0:0
DO F
IF $DATA(DIRUT)
QUIT
SET ACDP2=$ORDER(^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1,ACDP2))
IF 'ACDP2
QUIT
DO P2
IF $DATA(DIRUT)
QUIT
+3 IF $DATA(DIRUT)
QUIT
+4 WRITE ?26,ACDSTOT,?48,ACDSTOT1,?74,$JUSTIFY(ACDSTOT1/ACDSTOT,5,2),!
+5 QUIT
P2 ;
+1 SET ACDSTOT=ACDSTOT+1
SET ACDSTOT1=ACDSTOT1+^TMP("ACD",ACDJOB,ACDBT,ACDTGSUB,"VAL",ACDP1,ACDP2)
+2 QUIT
F ;Form feed
+1 IF $Y+4>IOSL
DO F^ACDWUTL
IF '$DATA(DIRUT)
DO C
+2 QUIT
C ;Column
+1 WRITE !!,ACDC(1),?26,ACDC(2),?48,ACDC(3),?72,ACDC(4),!,ACDH(1),!
+2 QUIT
COMB ;List patients on more than 1 drug i.e. combination drugs.
+1 WRITE !!!,"COMBINATIONS ARE AS FOLLOWS:",!
+2 SET ACDP1=""
+3 FOR
SET ACDP1=$ORDER(^TMP("CDMIS",$JOB,ACDP1))
IF ACDP1=""
QUIT
Begin DoDot:1
+4 SET ACDP2=0
+5 FOR ACDNUM=0:1
SET ACDP2=$ORDER(^TMP("CDMIS",$JOB,ACDP1,ACDP2))
IF 'ACDP2
QUIT
+6 DO F
IF $DATA(DIRUT)
QUIT
WRITE ACDP1,?67,"CLIENTS = ",?74,$JUSTIFY(ACDNUM,3),!
+7 QUIT
End DoDot:1
IF $DATA(DIRUT)
QUIT
+8 QUIT