GMRAPST4 ;HIRMFO/WAA- PRINT FREQUENCY OF DIST OVR DT BY DC ;6/17/08 09:28
;;4.0;Adverse Reaction Tracking;**7,33,41**;Mar 29, 1996;Build 8
EN1 ; This routine will loop through the ADT entry point to get all
; the entries in that date range.
N GMAEN,GMAST,GMRADATE,GMRADC0,GMRADCN,GMRADPDT,GMRATOT ;41 Added NEW SAC
S GMRAOUT=0
W !,"Select an Observed date range for this report."
D DT^GMRAPL G:GMRAOUT EXIT
D PRINTER
EXIT ; Exit of program kill cleanup
K ^TMP($J,"GMRAPST4")
D KILL^XUSCLEAN
Q
PRINTER ;Select printer
W ! K GMRAZIS D DEV^GMRAUTL I POP W !,"PLEASE TRY LATER" S GMRAOUT=1 Q
I $D(IO("Q")) D Q
. S ZTRTN="PRINT^GMRAPST4",(ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
. S ZTDESC="Frequency Distribution of Drug Classes" D ^%ZTLOAD
. W !!,$S($D(ZTSK):"Request queued...",1:"Request NOT queued please try Later.")
. Q
U IO D PRINT U IO(0)
Q
PRINT ;Queue point for report
;loop through the 120.85 file and look for the field that
D NOW^%DTC S GMRADPDT=X
S GMRADATE=GMAST-.0001,GMRAPG=1
K ^TMP($J,"GMRAPST4")
S GMRATOT=0
F S GMRADATE=$O(^GMR(120.85,"B",GMRADATE)) Q:GMRADATE<1 Q:GMRADATE>GMAEN D
.S GMRAPA1=0 F S GMRAPA1=$O(^GMR(120.85,"B",GMRADATE,GMRAPA1)) Q:GMRAPA1<1 D
..S GMRAPA1(0)=$G(^GMR(120.85,GMRAPA1,0)) Q:GMRAPA1(0)="" ;Bad Node
..Q:+$G(^GMR(120.8,$P(GMRAPA1(0),U,15),"ER")) ;Entered in error data
..Q:'$$PRDTST^GMRAUTL1($P(GMRAPA1(0),U,2)) ;GMRA*4*33 Exclude test patient from report if production or legacy environment.
..S GMRAPA=$P(GMRAPA1(0),U,15) Q:'GMRAPA
..S GMRAPA(0)=$G(^GMR(120.8,GMRAPA,0)) Q:GMRAPA(0)=""
..S GMRADC=0
..F S GMRADC=$O(^GMR(120.8,GMRAPA,3,GMRADC)) Q:GMRADC<1 D
...S GMRATOT=GMRATOT+1
...S GMRADCN=$P($G(^GMR(120.8,GMRAPA,3,GMRADC,0)),U) Q:GMRADCN=""
...S ^TMP($J,"GMRAPST4",GMRADCN)=$G(^TMP($J,"GMRAPST4",GMRADCN))+1
...Q
..Q
.Q
Q:GMRAOUT
Q:'$D(^TMP($J,"GMRAPST4"))
S GMRADCN=0
;Sort in value order.
F S GMRADCN=$O(^TMP($J,"GMRAPST4",GMRADCN)) Q:GMRADCN<1 D
.S GMRADC=$G(^TMP($J,"GMRAPST4",GMRADCN)) Q:GMRADC<1
.S ^TMP($J,"GMRAPST4","B",GMRADC,GMRADCN)=""
.Q
D HEAD
S GMRADC=""
F S GMRADC=$O(^TMP($J,"GMRAPST4","B",GMRADC),-1) Q:GMRADC<1 D Q:GMRAOUT
.S GMRADCN=0,GMRATAB=0,GMRADC0=0
.F S GMRADCN=$O(^TMP($J,"GMRAPST4","B",GMRADC,GMRADCN)) Q:GMRADCN<1 D Q:GMRAOUT
..; S GMRADC0=$G(^PS(50.605,GMRADCN,0)) ;41 Changed from direct read to API call
..D C^PSN50P65(GMRADCN,,"GMRA") ;41 Added API
..S GMRADC0=$G(^TMP($J,"GMRA",GMRADCN,.01))_"^"_$G(^TMP($J,"GMRA",GMRADCN,1))
..S GMRATAB=30-$L($E($P(GMRADC0,U,2),1,30))
..W !,?GMRATAB,$E($P(GMRADC0,U,2),1,30)," (",$P(GMRADC0,U),") :",$J(GMRADC,5)
..D HEAD Q:GMRAOUT
..Q
.Q
W !!,?22,"Total number of records processed ",GMRATOT
D CLOSE^GMRAUTL
Q
HEAD ; Print header information
I GMRAPG'=1 Q:$Y<(IOSL-4)
I $E(IOST,1,2)="C-" D Q:GMRAOUT
.I GMRAPG=1 W @IOF Q
.I GMRAPG'=1 D Q:GMRAOUT
..N DIR S DIR(0)="E" D ^DIR I 'Y S GMRAOUT=1
..K Y
..Q
.Q
Q:GMRAOUT
I GMRAPG'=1 W @IOF
W "Report Date: ",$P($$FMTE^XLFDT(GMRADPDT),"@"),?70,"Page: ",GMRAPG
W !,?20,"Frequency Distribution of Drug Classes"
W !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
W !,"Drug Class",?43,"Number"
W !,$$REPEAT^XLFSTR("-",79)
S GMRAPG=GMRAPG+1
I $D(ZTQUEUED) S:$$STPCK^GMRAUTL1 GMRAOUT=1 ; Check if stopped by user
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMRAPST4 3406 printed Dec 13, 2024@01:40:19 Page 2
GMRAPST4 ;HIRMFO/WAA- PRINT FREQUENCY OF DIST OVR DT BY DC ;6/17/08 09:28
+1 ;;4.0;Adverse Reaction Tracking;**7,33,41**;Mar 29, 1996;Build 8
EN1 ; This routine will loop through the ADT entry point to get all
+1 ; the entries in that date range.
+2 ;41 Added NEW SAC
NEW GMAEN,GMAST,GMRADATE,GMRADC0,GMRADCN,GMRADPDT,GMRATOT
+3 SET GMRAOUT=0
+4 WRITE !,"Select an Observed date range for this report."
+5 DO DT^GMRAPL
if GMRAOUT
GOTO EXIT
+6 DO PRINTER
EXIT ; Exit of program kill cleanup
+1 KILL ^TMP($JOB,"GMRAPST4")
+2 DO KILL^XUSCLEAN
+3 QUIT
PRINTER ;Select printer
+1 WRITE !
KILL GMRAZIS
DO DEV^GMRAUTL
IF POP
WRITE !,"PLEASE TRY LATER"
SET GMRAOUT=1
QUIT
+2 IF $DATA(IO("Q"))
Begin DoDot:1
+3 SET ZTRTN="PRINT^GMRAPST4"
SET (ZTSAVE("GMRAOUT"),ZTSAVE("GMAST"),ZTSAVE("GMAEN"))=""
+4 SET ZTDESC="Frequency Distribution of Drug Classes"
DO ^%ZTLOAD
+5 WRITE !!,$SELECT($DATA(ZTSK):"Request queued...",1:"Request NOT queued please try Later.")
+6 QUIT
End DoDot:1
QUIT
+7 USE IO
DO PRINT
USE IO(0)
+8 QUIT
PRINT ;Queue point for report
+1 ;loop through the 120.85 file and look for the field that
+2 DO NOW^%DTC
SET GMRADPDT=X
+3 SET GMRADATE=GMAST-.0001
SET GMRAPG=1
+4 KILL ^TMP($JOB,"GMRAPST4")
+5 SET GMRATOT=0
+6 FOR
SET GMRADATE=$ORDER(^GMR(120.85,"B",GMRADATE))
if GMRADATE<1
QUIT
if GMRADATE>GMAEN
QUIT
Begin DoDot:1
+7 SET GMRAPA1=0
FOR
SET GMRAPA1=$ORDER(^GMR(120.85,"B",GMRADATE,GMRAPA1))
if GMRAPA1<1
QUIT
Begin DoDot:2
+8 ;Bad Node
SET GMRAPA1(0)=$GET(^GMR(120.85,GMRAPA1,0))
if GMRAPA1(0)=""
QUIT
+9 ;Entered in error data
if +$GET(^GMR(120.8,$PIECE(GMRAPA1(0),U,15),"ER"))
QUIT
+10 ;GMRA*4*33 Exclude test patient from report if production or legacy environment.
if '$$PRDTST^GMRAUTL1($PIECE(GMRAPA1(0),U,2))
QUIT
+11 SET GMRAPA=$PIECE(GMRAPA1(0),U,15)
if 'GMRAPA
QUIT
+12 SET GMRAPA(0)=$GET(^GMR(120.8,GMRAPA,0))
if GMRAPA(0)=""
QUIT
+13 SET GMRADC=0
+14 FOR
SET GMRADC=$ORDER(^GMR(120.8,GMRAPA,3,GMRADC))
if GMRADC<1
QUIT
Begin DoDot:3
+15 SET GMRATOT=GMRATOT+1
+16 SET GMRADCN=$PIECE($GET(^GMR(120.8,GMRAPA,3,GMRADC,0)),U)
if GMRADCN=""
QUIT
+17 SET ^TMP($JOB,"GMRAPST4",GMRADCN)=$GET(^TMP($JOB,"GMRAPST4",GMRADCN))+1
+18 QUIT
End DoDot:3
+19 QUIT
End DoDot:2
+20 QUIT
End DoDot:1
+21 if GMRAOUT
QUIT
+22 if '$DATA(^TMP($JOB,"GMRAPST4"))
QUIT
+23 SET GMRADCN=0
+24 ;Sort in value order.
+25 FOR
SET GMRADCN=$ORDER(^TMP($JOB,"GMRAPST4",GMRADCN))
if GMRADCN<1
QUIT
Begin DoDot:1
+26 SET GMRADC=$GET(^TMP($JOB,"GMRAPST4",GMRADCN))
if GMRADC<1
QUIT
+27 SET ^TMP($JOB,"GMRAPST4","B",GMRADC,GMRADCN)=""
+28 QUIT
End DoDot:1
+29 DO HEAD
+30 SET GMRADC=""
+31 FOR
SET GMRADC=$ORDER(^TMP($JOB,"GMRAPST4","B",GMRADC),-1)
if GMRADC<1
QUIT
Begin DoDot:1
+32 SET GMRADCN=0
SET GMRATAB=0
SET GMRADC0=0
+33 FOR
SET GMRADCN=$ORDER(^TMP($JOB,"GMRAPST4","B",GMRADC,GMRADCN))
if GMRADCN<1
QUIT
Begin DoDot:2
+34 ; S GMRADC0=$G(^PS(50.605,GMRADCN,0)) ;41 Changed from direct read to API call
+35 ;41 Added API
DO C^PSN50P65(GMRADCN,,"GMRA")
+36 SET GMRADC0=$GET(^TMP($JOB,"GMRA",GMRADCN,.01))_"^"_$GET(^TMP($JOB,"GMRA",GMRADCN,1))
+37 SET GMRATAB=30-$LENGTH($EXTRACT($PIECE(GMRADC0,U,2),1,30))
+38 WRITE !,?GMRATAB,$EXTRACT($PIECE(GMRADC0,U,2),1,30)," (",$PIECE(GMRADC0,U),") :",$JUSTIFY(GMRADC,5)
+39 DO HEAD
if GMRAOUT
QUIT
+40 QUIT
End DoDot:2
if GMRAOUT
QUIT
+41 QUIT
End DoDot:1
if GMRAOUT
QUIT
+42 WRITE !!,?22,"Total number of records processed ",GMRATOT
+43 DO CLOSE^GMRAUTL
+44 QUIT
HEAD ; Print header information
+1 IF GMRAPG'=1
if $Y<(IOSL-4)
QUIT
+2 IF $EXTRACT(IOST,1,2)="C-"
Begin DoDot:1
+3 IF GMRAPG=1
WRITE @IOF
QUIT
+4 IF GMRAPG'=1
Begin DoDot:2
+5 NEW DIR
SET DIR(0)="E"
DO ^DIR
IF 'Y
SET GMRAOUT=1
+6 KILL Y
+7 QUIT
End DoDot:2
if GMRAOUT
QUIT
+8 QUIT
End DoDot:1
if GMRAOUT
QUIT
+9 if GMRAOUT
QUIT
+10 IF GMRAPG'=1
WRITE @IOF
+11 WRITE "Report Date: ",$PIECE($$FMTE^XLFDT(GMRADPDT),"@"),?70,"Page: ",GMRAPG
+12 WRITE !,?20,"Frequency Distribution of Drug Classes"
+13 WRITE !,?25,"From: ",$$FMTE^XLFDT(GMAST,"2D")," To: ",$$FMTE^XLFDT(GMAEN,"2D")
+14 WRITE !,"Drug Class",?43,"Number"
+15 WRITE !,$$REPEAT^XLFSTR("-",79)
+16 SET GMRAPG=GMRAPG+1
+17 ; Check if stopped by user
IF $DATA(ZTQUEUED)
if $$STPCK^GMRAUTL1
SET GMRAOUT=1
+18 QUIT