AGSSLBAT ; IHS/ASDS/EFG - PRINT 'SSN ADDED' LETTERS TO SEND TO PATIENTS ;
;;7.1;PATIENT REGISTRATION;;AUG 25,2005
;
START D DT^DICRW S IOP="HOME" D ^%ZIS
H 2 W $$S^AGVDF("IOF"),!,"This will send SSN Notification Letters to those patients",! W "that have had their SSN ADDED by the SSA/SSN Matching Process.",!!
REVIEW ;review previous printing
I '$D(^AGSSLTMP) K DIR S DIR(0)="Y",DIR("A")="Do you wish to proceed",DIR("B")="Y" W !!,"There is no temporary SSN global to print batches from." D ^DIR G:$G(DUOUT)!(Y=0) END D LOAD
S AGSSTP=^AGSSLTMP("TP"),AGSSLPB=^("LPB"),AGSSBFP=^("BFP")
W !!,"TOTAL PATIENTS",?25,$J(AGSSTP,5)
W !,"Letters Per Batch",?25,$J(AGSSLPB,5)
W !,"Batches for Printing",?25,$J(AGSSBFP,5)
W !!,"Batch Numbers Completed",!
F AGSI=1:1:AGSSBFP-1 S AGSC=$G(^AGSSLTMP("BAT",AGSI)) I AGSC=(AGSI*AGSSLPB) W:$X>75 ! W $J(AGSI,5)
S AGSC=$G(^AGSSLTMP("BAT",AGSSBFP)) I (AGSC=AGSSTP) W:$X>75 ! W $J(AGSSBFP,5)
W !!,"Batch Numbers to Print",! K AGSSMORE
F AGSI=1:1:AGSSBFP-1 S AGSC=$G(^AGSSLTMP("BAT",AGSI)) I AGSC'=(AGSI*AGSSLPB) W:$X>75 ! W $J(AGSI,5)
S AGSC=$G(^AGSSLTMP("BAT",AGSSBFP)) I (AGSC'=AGSSTP) W:$X>75 ! W $J(AGSSBFP,5)
I $G(AGSSMORE) W !,"There are ",AGSSMORE," batches to Print",!
K DIR S DIR(0)="S^C:Continue;R:Restart;K:Kill Temporary Global;E:EXIT",DIR("B")="C" D ^DIR
I Y="R" D LOAD G START
I Y="C" D CONTINUE G END
I Y="K" S AGTMP="^AGSSLTMP" K @AGTMP G START
G END ;----->
Q
LOAD ;EP
S AGTMP="^AGSSLTMP" K @AGTMP
K DIC S X="A",DIC="^AUTTSSN(",DIC(0)="XQMZ" D ^DIC S AGSSIEN=+Y
I '$D(^AGSSLTMP) S DFN=0 F AGSSC=0:1 S DFN=$O(^AUPNPAT("AS",AGSSIEN,DFN)) Q:DFN'>0
W !,"There are ",AGSSC," potential patients to receive letters. ",!
K DIR S DIR(0)="N^1:99999",DIR("A")="How many letters per batch do you wish to have / OR ^ to quit " D ^DIR G:$G(DUOUT) END S AGSSLPB=Y
S AGSSBFP=AGSSC\AGSSLPB+$S(AGSSC#AGSSLPB:1,1:0)
S ^AGSSLTMP("BFP")=AGSSBFP,^("TP")=AGSSC,^("LPB")=AGSSLPB
Q
CONTINUE ;EP
K DIR S DIR(0)="L^1:"_AGSSBFP,DIR("A")="Please select batch(s) to print /OR ^ to quit" D ^DIR G:$G(DUOUT) START S AGSSNUM=Y
S XBRC="SCAN^AGSSLBAT",XBRP="PRINT^AGSSLBAT",XBRX="END^AGSSLBAT",XBNS="AGS"
D ^XBDBQUE
Q
SCAN ;scan SSN Ver Stat Indx / build
Q:$D(^AGSSLTMP("A")) ;indexing already built
K DIC S X="A",DIC="^AUTTSSN(",DIC(0)="XQMZ" D ^DIC S AGSSIEN=+Y
S DFN=0 F AGSSC=1:1 S DFN=$O(^AUPNPAT("AS",AGSSIEN,DFN)) Q:DFN'>0 S AGSSNM=$P(^DPT(DFN,0),U),^AGSSLTMP("A",AGSSNM,DFN)="" ;order alpha index
S AGSSC=0,AGSSNM="" F S AGSSNM=$O(^AGSSLTMP("A",AGSSNM)) Q:AGSSNM="" S DFN=0 F S DFN=$O(^AGSSLTMP("A",AGSSNM,DFN)) Q:DFN'>0 S AGSSC=AGSSC+1,^AGSSLTMP(AGSSC,AGSSNM,DFN)="",^AGSSLTMP("A",AGSSNM,DFN)=AGSSC ;order numeric-alpha index
Q
PRINT F AGSSI=1:1 S AGSSNB=$P(AGSSNUM,",",AGSSI) Q:AGSSNB'>0 D PATPRT,RPTPRT
U IO W:$Y>1 @IOF
D END
Q
PATPRT ;print patient letters for a batch
U IO W:$Y>1 @IOF
F AGSSIEN=(AGSSNB-1)*AGSSLPB+1:1:AGSSNB*AGSSLPB Q:'$D(^AGSSLTMP(AGSSIEN)) D PRTLTR S ^AGSSLTMP("BAT",AGSSNB)=AGSSIEN
Q
PRTLTR ;print letter
S AGSSNM=$O(^AGSSLTMP(AGSSIEN,"")),DFN=$O(^(AGSSNM,"")),^AGSSLTMP(AGSSIEN)=""
D ^AGSSLPRT I $G(AGSST)]"" S ^AGSSLTMP(AGSSIEN)=AGSST K AGSST
Q
RPTPRT ;print summary report
;needs AGSSNB,AGSSLPB (b number),(n per batch)
I $G(AGSITE)="" S AGSITE=$P(^AUTTSITE(1,0),"^")
S AGSSPG("PG")=1,AGSSPG("HDR")="Report of 'SSN ADDED' Patient Leters BATCH "_AGSSNB_" " D AGSSHDR ;print header
S AGSSC=0 F AGSSIEN=(AGSSNB-1)*AGSSLPB+1:1:AGSSNB*AGSSLPB Q:'$D(^AGSSLTMP(AGSSIEN)) S AGSSNM=$O(^AGSSLTMP(AGSSIEN,"")),DFN=$O(^(AGSSNM,0)) Q:AGSSNM="" D
.S AGSHRN=$P($G(^AUPNPAT(DFN,41,AGSITE,0)),"^",2)
.S AGSSCL=5+35*(AGSSC#2) W ?AGSSCL,$J(AGSHRN,6)," ",AGSSNM W:($G(^AGSSLTMP(AGSSIEN))]"") " *"_^AGSSLTMP(AGSSIEN) I AGSSCL>10 W ! D AGSSPG
.S AGSSC=AGSSC+1
W !!,"TOTAL = ",AGSSC H 5
Q
END ;EP
K AGSS,AGSC,AGSHRN,AGSI,AGSITE,AGSSNUM,AGSSBFP,AGSSNB,AGSSBFP,AGSSC,AGSSCL,AGSSIEN,AGSSLPB,AGSSNM,AGSSTP
K AGBOT,AGI,AGIN,AGSSLPB,AGSSI,AGSSLBC,DA,DIR,DFN,DR
Q
AGSSPG ;EP
;this utility uses variables AGSSPG("HDR"),AGSSPG("DT"),AGSSPG("LINE"),AGSSPG("PG") ; kill variables by D EAGSSPG
Q:($Y<(IOSL-4))!($G(DOUT)!$G(DFOUT)) S:'$D(AGSSPG("PG")) AGSSPG("PG")=0 S AGSSPG("PG")=AGSSPG("PG")+1 I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DROUT))
AGSSHDR ;EP header
W:$Y @IOF W ! Q:'$D(AGSSPG("HDR")) S:'$D(AGSSPG("LINE")) $P(AGSSPG("LINE"),"-",IOM-2)="" S:'$D(AGSSPG("PG")) AGSSPG("PG")=1 I '$D(AGSSPG("DT")) S %H=$H D YX^%DTC S AGSSPG("DT")=Y
U IO W ?(IOM-40-$L(AGSSPG("HDR"))/2),AGSSPG("HDR"),?(IOM-40),AGSSPG("DT"),?(IOM-10),"PAGE: ",AGSSPG("PG"),!,AGSSPG("LINE")
AGSSHD ;EP column
W !!," * BAD Patient Record -- LETTER NOT PRINTED",!!
W !," A - Address D - Date of Death R - Record Disposition S - Patient Status",!
Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DROUT))
EAGSSPG K AGSSPG("LINE"),AGSSPG("PG"),AGSSPG("HDR"),AGSSPG("DT") Q
Q
AGSSLBAT ; IHS/ASDS/EFG - PRINT 'SSN ADDED' LETTERS TO SEND TO PATIENTS ;
+1 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
+2 ;
START DO DT^DICRW
SET IOP="HOME"
DO ^%ZIS
+1 HANG 2
WRITE $$S^AGVDF("IOF"),!,"This will send SSN Notification Letters to those patients",!
WRITE "that have had their SSN ADDED by the SSA/SSN Matching Process.",!!
REVIEW ;review previous printing
+1 IF '$DATA(^AGSSLTMP)
KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Do you wish to proceed"
SET DIR("B")="Y"
WRITE !!,"There is no temporary SSN global to print batches from."
DO ^DIR
IF $GET(DUOUT)!(Y=0)
GOTO END
DO LOAD
+2 SET AGSSTP=^AGSSLTMP("TP")
SET AGSSLPB=^("LPB")
SET AGSSBFP=^("BFP")
+3 WRITE !!,"TOTAL PATIENTS",?25,$JUSTIFY(AGSSTP,5)
+4 WRITE !,"Letters Per Batch",?25,$JUSTIFY(AGSSLPB,5)
+5 WRITE !,"Batches for Printing",?25,$JUSTIFY(AGSSBFP,5)
+6 WRITE !!,"Batch Numbers Completed",!
+7 FOR AGSI=1:1:AGSSBFP-1
SET AGSC=$GET(^AGSSLTMP("BAT",AGSI))
IF AGSC=(AGSI*AGSSLPB)
IF $X>75
WRITE !
WRITE $JUSTIFY(AGSI,5)
+8 SET AGSC=$GET(^AGSSLTMP("BAT",AGSSBFP))
IF (AGSC=AGSSTP)
IF $X>75
WRITE !
WRITE $JUSTIFY(AGSSBFP,5)
+9 WRITE !!,"Batch Numbers to Print",!
KILL AGSSMORE
+10 FOR AGSI=1:1:AGSSBFP-1
SET AGSC=$GET(^AGSSLTMP("BAT",AGSI))
IF AGSC'=(AGSI*AGSSLPB)
IF $X>75
WRITE !
WRITE $JUSTIFY(AGSI,5)
+11 SET AGSC=$GET(^AGSSLTMP("BAT",AGSSBFP))
IF (AGSC'=AGSSTP)
IF $X>75
WRITE !
WRITE $JUSTIFY(AGSSBFP,5)
+12 IF $GET(AGSSMORE)
WRITE !,"There are ",AGSSMORE," batches to Print",!
+13 KILL DIR
SET DIR(0)="S^C:Continue;R:Restart;K:Kill Temporary Global;E:EXIT"
SET DIR("B")="C"
DO ^DIR
+14 IF Y="R"
DO LOAD
GOTO START
+15 IF Y="C"
DO CONTINUE
GOTO END
+16 IF Y="K"
SET AGTMP="^AGSSLTMP"
KILL @AGTMP
GOTO START
+17 ;----->
GOTO END
+18 QUIT
LOAD ;EP
+1 SET AGTMP="^AGSSLTMP"
KILL @AGTMP
+2 KILL DIC
SET X="A"
SET DIC="^AUTTSSN("
SET DIC(0)="XQMZ"
DO ^DIC
SET AGSSIEN=+Y
+3 IF '$DATA(^AGSSLTMP)
SET DFN=0
FOR AGSSC=0:1
SET DFN=$ORDER(^AUPNPAT("AS",AGSSIEN,DFN))
IF DFN'>0
QUIT
+4 WRITE !,"There are ",AGSSC," potential patients to receive letters. ",!
+5 KILL DIR
SET DIR(0)="N^1:99999"
SET DIR("A")="How many letters per batch do you wish to have / OR ^ to quit "
DO ^DIR
IF $GET(DUOUT)
GOTO END
SET AGSSLPB=Y
+6 SET AGSSBFP=AGSSC\AGSSLPB+$SELECT(AGSSC#AGSSLPB:1,1:0)
+7 SET ^AGSSLTMP("BFP")=AGSSBFP
SET ^("TP")=AGSSC
SET ^("LPB")=AGSSLPB
+8 QUIT
CONTINUE ;EP
+1 KILL DIR
SET DIR(0)="L^1:"_AGSSBFP
SET DIR("A")="Please select batch(s) to print /OR ^ to quit"
DO ^DIR
IF $GET(DUOUT)
GOTO START
SET AGSSNUM=Y
+2 SET XBRC="SCAN^AGSSLBAT"
SET XBRP="PRINT^AGSSLBAT"
SET XBRX="END^AGSSLBAT"
SET XBNS="AGS"
+3 DO ^XBDBQUE
+4 QUIT
SCAN ;scan SSN Ver Stat Indx / build
+1 ;indexing already built
IF $DATA(^AGSSLTMP("A"))
QUIT
+2 KILL DIC
SET X="A"
SET DIC="^AUTTSSN("
SET DIC(0)="XQMZ"
DO ^DIC
SET AGSSIEN=+Y
+3 ;order alpha index
SET DFN=0
FOR AGSSC=1:1
SET DFN=$ORDER(^AUPNPAT("AS",AGSSIEN,DFN))
IF DFN'>0
QUIT
SET AGSSNM=$PIECE(^DPT(DFN,0),U)
SET ^AGSSLTMP("A",AGSSNM,DFN)=""
+4 ;order numeric-alpha index
SET AGSSC=0
SET AGSSNM=""
FOR
SET AGSSNM=$ORDER(^AGSSLTMP("A",AGSSNM))
IF AGSSNM=""
QUIT
SET DFN=0
FOR
SET DFN=$ORDER(^AGSSLTMP("A",AGSSNM,DFN))
IF DFN'>0
QUIT
SET AGSSC=AGSSC+1
SET ^AGSSLTMP(AGSSC,AGSSNM,DFN)=""
SET ^AGSSLTMP("A",AGSSNM,DFN)=AGSSC
+5 QUIT
PRINT FOR AGSSI=1:1
SET AGSSNB=$PIECE(AGSSNUM,",",AGSSI)
IF AGSSNB'>0
QUIT
DO PATPRT
DO RPTPRT
+1 USE IO
IF $Y>1
WRITE @IOF
+2 DO END
+3 QUIT
PATPRT ;print patient letters for a batch
+1 USE IO
IF $Y>1
WRITE @IOF
+2 FOR AGSSIEN=(AGSSNB-1)*AGSSLPB+1:1:AGSSNB*AGSSLPB
IF '$DATA(^AGSSLTMP(AGSSIEN))
QUIT
DO PRTLTR
SET ^AGSSLTMP("BAT",AGSSNB)=AGSSIEN
+3 QUIT
PRTLTR ;print letter
+1 SET AGSSNM=$ORDER(^AGSSLTMP(AGSSIEN,""))
SET DFN=$ORDER(^(AGSSNM,""))
SET ^AGSSLTMP(AGSSIEN)=""
+2 DO ^AGSSLPRT
IF $GET(AGSST)]""
SET ^AGSSLTMP(AGSSIEN)=AGSST
KILL AGSST
+3 QUIT
RPTPRT ;print summary report
+1 ;needs AGSSNB,AGSSLPB (b number),(n per batch)
+2 IF $GET(AGSITE)=""
SET AGSITE=$PIECE(^AUTTSITE(1,0),"^")
+3 ;print header
SET AGSSPG("PG")=1
SET AGSSPG("HDR")="Report of 'SSN ADDED' Patient Leters BATCH "_AGSSNB_" "
DO AGSSHDR
+4 SET AGSSC=0
FOR AGSSIEN=(AGSSNB-1)*AGSSLPB+1:1:AGSSNB*AGSSLPB
IF '$DATA(^AGSSLTMP(AGSSIEN))
QUIT
SET AGSSNM=$ORDER(^AGSSLTMP(AGSSIEN,""))
SET DFN=$ORDER(^(AGSSNM,0))
IF AGSSNM=""
QUIT
Begin DoDot:1
+5 SET AGSHRN=$PIECE($GET(^AUPNPAT(DFN,41,AGSITE,0)),"^",2)
+6 SET AGSSCL=5+35*(AGSSC#2)
WRITE ?AGSSCL,$JUSTIFY(AGSHRN,6)," ",AGSSNM
IF ($GET(^AGSSLTMP(AGSSIEN))]"")
WRITE " *"_^AGSSLTMP(AGSSIEN)
IF AGSSCL>10
WRITE !
DO AGSSPG
+7 SET AGSSC=AGSSC+1
End DoDot:1
+8 WRITE !!,"TOTAL = ",AGSSC
HANG 5
+9 QUIT
END ;EP
+1 KILL AGSS,AGSC,AGSHRN,AGSI,AGSITE,AGSSNUM,AGSSBFP,AGSSNB,AGSSBFP,AGSSC,AGSSCL,AGSSIEN,AGSSLPB,AGSSNM,AGSSTP
+2 KILL AGBOT,AGI,AGIN,AGSSLPB,AGSSI,AGSSLBC,DA,DIR,DFN,DR
+3 QUIT
AGSSPG ;EP
+1 ;this utility uses variables AGSSPG("HDR"),AGSSPG("DT"),AGSSPG("LINE"),AGSSPG("PG") ; kill variables by D EAGSSPG
+2 IF ($Y<(IOSL-4))!($GET(DOUT)!$GET(DFOUT))
QUIT
IF '$DATA(AGSSPG("PG"))
SET AGSSPG("PG")=0
SET AGSSPG("PG")=AGSSPG("PG")+1
IF $EXTRACT(IOST)="C"
KILL DIR
SET DIR(0)="E"
DO ^DIR
IF ($GET(DIROUT)!$GET(DUOUT)!$GET(DTOUT)!$GET(DROUT))
QUIT
AGSSHDR ;EP header
+1 IF $Y
WRITE @IOF
WRITE !
IF '$DATA(AGSSPG("HDR"))
QUIT
IF '$DATA(AGSSPG("LINE"))
SET $PIECE(AGSSPG("LINE"),"-",IOM-2)=""
IF '$DATA(AGSSPG("PG"))
SET AGSSPG("PG")=1
IF '$DATA(AGSSPG("DT"))
SET %H=$HOROLOG
DO YX^%DTC
SET AGSSPG("DT")=Y
+2 USE IO
WRITE ?(IOM-40-$LENGTH(AGSSPG("HDR"))/2),AGSSPG("HDR"),?(IOM-40),AGSSPG("DT"),?(IOM-10),"PAGE: ",AGSSPG("PG"),!,AGSSPG("LINE")
AGSSHD ;EP column
+1 WRITE !!," * BAD Patient Record -- LETTER NOT PRINTED",!!
+2 WRITE !," A - Address D - Date of Death R - Record Disposition S - Patient Status",!
+3 IF ($GET(DIROUT)!$GET(DUOUT)!$GET(DTOUT)!$GET(DROUT))
QUIT
EAGSSPG KILL AGSSPG("LINE"),AGSSPG("PG"),AGSSPG("HDR"),AGSSPG("DT")
QUIT
+1 QUIT