TIUPRPN7 ;SLC/MJC - Progress Notes Outpt Batch Prt ;6/26/01
;;1.0;TEXT INTEGRATION UTILITIES;**45,100,121**;Jun 20, 1997
;
BATCH ;batch print outpatient progress notes sorted by terminal digit
;if you wish to exlude a particular hospital location from this
;print option that can be specified in the
;EXCLUDE FROM BATCH PRINTING field of file 8925.93
;[TIU PRINT PN BATCH INTERACTIVE]
;
N Y,TIUQT,TIUSTART,TIUDIV,ANS,LAST,DIV
D SETUP^TIUPRPN3("Batch Print Outpatient Progress Notes by Terminal Digit")
W !!?5,"Notes will be printed in terminal digit order."
W !!?5,"This option may also be scheduled to run non-interactively"
W !?5,"in file #19.2 OPTION SCHEDULING FILE.",!!
;
I $D(^TIU(8925.94,0))'=1 W $C(7),$C(7),!?5,"Before using this option "
I W "you must enter the divisions for your site in"
I W !?5,"file #8925.94 - TIU DIVISION PRINT PARAMETERS FILE." Q
;
S DIC=8925.94,DIC(0)="AEQMNZ",DIC("A")="Select DIVISION: "
S DIC("B")=$P($G(^DG(40.8,+$G(^DISV(DUZ,"^TIU(8925.94,")),0),""),U)
D ^DIC K DIC Q:Y<0
S TIUDIV=+Y(0)_U_+Y_U_Y(0,0)
;ien medical center div^ien tiu param^external division
S LAST=$P($G(^TIU(8925.94,+$P(TIUDIV,U,2),1)),U)
I LAST']"" S TIUSTART=$$DATE^TIUPRPN4() Q:TIUSTART']""
I LAST]"" D Q:$D(TIUQT)
.W !!,"Notes were last printed for '"_$P(TIUDIV,U,3)_"' "
.W $$FMTE^XLFDT(LAST,"1P"),!
.S ANS=$$READ^TIUU("YA","Print from this DATE/TIME on? ","YES","D HELP^TIUPRPN5")
.I $D(DIRUT) S TIUQT=1 Q
.I +$G(ANS) S TIUSTART=LAST Q
.D 3^TIUPRPN5 S TIUSTART=$$DATE^TIUPRPN4() I TIUSTART']"" S TIUQT=1 Q
DEV S %ZIS("B")=$P($G(^%ZIS(1,+$P($G(^TIU(8925.94,$P(TIUDIV,U,2),1)),U,2),0),""),U) ;brings up default prter from 8925.94 param file
W ! S %ZIS="Q" D ^%ZIS I POP K POP G EXIT
I $E(IOST)="C" W $C(7),$C(7),!?5,"You must select a printer for this "
I W "option!!" G DEV
S TIUDIV=+$P(TIUDIV,U,2)
I $D(IO("Q")) K IO("Q") D G EXIT
.S ZTRTN="PRINT^TIUPRPN7",ZTSAVE("TIUSTART")="",ZTSAVE("TIUDIV")=""
.S ZTDESC="TIU BATCH PRT PNS OUTPT DIV"
.D ^%ZTLOAD W !,$S($D(ZTSK):"Request Queued!",1:"Request Canceled!")
.K ZTSK,ZTDESC,ZTDTH,ZTIO,ZTRTN,STSAVE,%ZIS,TIUSTART,TIUDIV
.D HOME^%ZIS
U IO D PRINT,^%ZISC
Q
PRINT ;entry point for non-interactive tasked job
;requires TIUDIV set to the division you want notes for
;if queued non-interactively, file 8925.94- field #1.02 will need
;to contain the start time of the batch
;[TIU PRINT PN BATCH SCHEDULED]- entry point if called from file #19.2
;
I '$D(TIUDIV) D TROUBLE G EXIT
N DATE,LOC,IFN,SSN,DFN,STOP,DIV
K ^TMP("TIUREPLACE",$J),^TMP("TIUPR",$J),^TMP("TIULQ",$J)
S STOP=$$NOW^XLFDT
I '$D(TIUSTART) S TIUSTART=$P($G(^TIU(8925.94,TIUDIV,1)),U)
Q:TIUSTART']"" ;date not passed/no date in field 1.01 file #8925.94
S DIV=+$P($G(^TIU(8925.94,TIUDIV,0)),U)
S LOC=0
F S LOC=$O(^TIU(8925,"ALOCP",LOC)) Q:'LOC D
.Q:+$$LOC(LOC,DIV) S DATE=TIUSTART
.F S DATE=$O(^TIU(8925,"ALOCP",LOC,DATE)) Q:'DATE!(DATE>STOP) D
..S IFN=0 F S IFN=$O(^TIU(8925,"ALOCP",LOC,DATE,IFN)) Q:'IFN D
...D REPLACE^TIUPRPN3(IFN,DATE,1501)
S IFN=0 F S IFN=$O(^TMP("TIUREPLACE",$J,IFN)) Q:'IFN D
.S DFN=$P(^TIU(8925,IFN,0),U,2),SSN=$P(^DPT(DFN,0),U,9)
.S SSN=$E(SSN,8,9)_$E(SSN,6,7)_$E(SSN,4,5)_$E(SSN,1,3)
.S DATE=^TMP("TIUREPLACE",$J,IFN,"DT")
.S ^TMP("TIUPR",$J,SSN_";"_DFN,DATE,IFN)="Vice SF 509"
I '$D(^TMP("TIUPR",$J)) D TROUBLE G EXIT
D PRINT^TIUPRPN1(1,1)
S $P(^TIU(8925.94,TIUDIV,1),U)=STOP
EXIT K ^TIU("TIUPR",$J),^TMP("TIULQ",$J),^TMP("TIUREPLACE",$J)
Q
LOC(LOC,DIV) ;checks if this location should be batch prted
N IEN
S IEN=$O(^TIU(8925.93,"B",LOC,0))
Q $S($P($G(^SC(LOC,0)),U,3)="W":1,$P($G(^SC(LOC,0)),U,15)'=DIV:1,'$D(^TIU(8925.93,+IEN,0)):"",+$G(^TIU(8925.93,IEN,3)):1,1:"")
;
TROUBLE ;message to print if no output
W !!,"The option [TIU PRINT PN BATCH OUTPT] ran to completion at "
W !,$$FMTE^XLFDT($$NOW^XLFDT,"1P")," but did not find any notes."
W !!,"If you were expecting notes to print review the following:"
;
W !!,"INTERACTIVE"
W !,"-----------"
W !,"1. Very little can go wrong- the required criteria is screened"
W !,"while the user is manually queueing the job."
W !!,"2. This option prints all the outpatient progress notes, in"
W !,"terminal digit order, for the selected date range for ALL CLINICS"
W !,"for the selected DIVISION. Verify that you have signed progress"
W !,"notes satisfying this criteria.",!
;
W !!,"NON-INTERACTIVE (job set to run in OPTION SCHEDULING FILE (#19.2)"
W !,"-----------------------------------------------------------------"
W !,"1. DIVISION must be defined in file #8925.94 (TIU DIVISION PRINT"
W !,"PRINT PARAMETERS FILE)."
W !!,"2. The variable TIUDIV must be defined in the VARIABLE NAME "
W !,"multiple of the OPTION SCHEDULING FILE (#19.2). TIUDIV should"
W !,"be set to the IEN of an entry in the TIU DIVISION PRINT PARAMETERS"
W !,"FILE (#8925.94)."
W !!,"3. This option must find a valid date in field #1.01 of"
W !,"file #8925.94 to start looping on. If a valid date is not "
W !,"found, the option will terminate with this message."
W !!,"4. To assist in troubleshooting, if no notes are found, the"
W !,"DATE/TIME field (#1.01) of file #8925.94 will not be re-set"
W !,"to the new value (which is NOW) when the option begins "
W "calculating."
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIUPRPN7 5377 printed Dec 13, 2024@02:43:52 Page 2
TIUPRPN7 ;SLC/MJC - Progress Notes Outpt Batch Prt ;6/26/01
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**45,100,121**;Jun 20, 1997
+2 ;
BATCH ;batch print outpatient progress notes sorted by terminal digit
+1 ;if you wish to exlude a particular hospital location from this
+2 ;print option that can be specified in the
+3 ;EXCLUDE FROM BATCH PRINTING field of file 8925.93
+4 ;[TIU PRINT PN BATCH INTERACTIVE]
+5 ;
+6 NEW Y,TIUQT,TIUSTART,TIUDIV,ANS,LAST,DIV
+7 DO SETUP^TIUPRPN3("Batch Print Outpatient Progress Notes by Terminal Digit")
+8 WRITE !!?5,"Notes will be printed in terminal digit order."
+9 WRITE !!?5,"This option may also be scheduled to run non-interactively"
+10 WRITE !?5,"in file #19.2 OPTION SCHEDULING FILE.",!!
+11 ;
+12 IF $DATA(^TIU(8925.94,0))'=1
WRITE $CHAR(7),$CHAR(7),!?5,"Before using this option "
+13 IF $TEST
WRITE "you must enter the divisions for your site in"
+14 IF $TEST
WRITE !?5,"file #8925.94 - TIU DIVISION PRINT PARAMETERS FILE."
QUIT
+15 ;
+16 SET DIC=8925.94
SET DIC(0)="AEQMNZ"
SET DIC("A")="Select DIVISION: "
+17 SET DIC("B")=$PIECE($GET(^DG(40.8,+$GET(^DISV(DUZ,"^TIU(8925.94,")),0),""),U)
+18 DO ^DIC
KILL DIC
if Y<0
QUIT
+19 SET TIUDIV=+Y(0)_U_+Y_U_Y(0,0)
+20 ;ien medical center div^ien tiu param^external division
+21 SET LAST=$PIECE($GET(^TIU(8925.94,+$PIECE(TIUDIV,U,2),1)),U)
+22 IF LAST']""
SET TIUSTART=$$DATE^TIUPRPN4()
if TIUSTART']""
QUIT
+23 IF LAST]""
Begin DoDot:1
+24 WRITE !!,"Notes were last printed for '"_$PIECE(TIUDIV,U,3)_"' "
+25 WRITE $$FMTE^XLFDT(LAST,"1P"),!
+26 SET ANS=$$READ^TIUU("YA","Print from this DATE/TIME on? ","YES","D HELP^TIUPRPN5")
+27 IF $DATA(DIRUT)
SET TIUQT=1
QUIT
+28 IF +$GET(ANS)
SET TIUSTART=LAST
QUIT
+29 DO 3^TIUPRPN5
SET TIUSTART=$$DATE^TIUPRPN4()
IF TIUSTART']""
SET TIUQT=1
QUIT
End DoDot:1
if $DATA(TIUQT)
QUIT
DEV ;brings up default prter from 8925.94 param file
SET %ZIS("B")=$PIECE($GET(^%ZIS(1,+$PIECE($GET(^TIU(8925.94,$PIECE(TIUDIV,U,2),1)),U,2),0),""),U)
+1 WRITE !
SET %ZIS="Q"
DO ^%ZIS
IF POP
KILL POP
GOTO EXIT
+2 IF $EXTRACT(IOST)="C"
WRITE $CHAR(7),$CHAR(7),!?5,"You must select a printer for this "
+3 IF $TEST
WRITE "option!!"
GOTO DEV
+4 SET TIUDIV=+$PIECE(TIUDIV,U,2)
+5 IF $DATA(IO("Q"))
KILL IO("Q")
Begin DoDot:1
+6 SET ZTRTN="PRINT^TIUPRPN7"
SET ZTSAVE("TIUSTART")=""
SET ZTSAVE("TIUDIV")=""
+7 SET ZTDESC="TIU BATCH PRT PNS OUTPT DIV"
+8 DO ^%ZTLOAD
WRITE !,$SELECT($DATA(ZTSK):"Request Queued!",1:"Request Canceled!")
+9 KILL ZTSK,ZTDESC,ZTDTH,ZTIO,ZTRTN,STSAVE,%ZIS,TIUSTART,TIUDIV
+10 DO HOME^%ZIS
End DoDot:1
GOTO EXIT
+11 USE IO
DO PRINT
DO ^%ZISC
+12 QUIT
PRINT ;entry point for non-interactive tasked job
+1 ;requires TIUDIV set to the division you want notes for
+2 ;if queued non-interactively, file 8925.94- field #1.02 will need
+3 ;to contain the start time of the batch
+4 ;[TIU PRINT PN BATCH SCHEDULED]- entry point if called from file #19.2
+5 ;
+6 IF '$DATA(TIUDIV)
DO TROUBLE
GOTO EXIT
+7 NEW DATE,LOC,IFN,SSN,DFN,STOP,DIV
+8 KILL ^TMP("TIUREPLACE",$JOB),^TMP("TIUPR",$JOB),^TMP("TIULQ",$JOB)
+9 SET STOP=$$NOW^XLFDT
+10 IF '$DATA(TIUSTART)
SET TIUSTART=$PIECE($GET(^TIU(8925.94,TIUDIV,1)),U)
+11 ;date not passed/no date in field 1.01 file #8925.94
if TIUSTART']""
QUIT
+12 SET DIV=+$PIECE($GET(^TIU(8925.94,TIUDIV,0)),U)
+13 SET LOC=0
+14 FOR
SET LOC=$ORDER(^TIU(8925,"ALOCP",LOC))
if 'LOC
QUIT
Begin DoDot:1
+15 if +$$LOC(LOC,DIV)
QUIT
SET DATE=TIUSTART
+16 FOR
SET DATE=$ORDER(^TIU(8925,"ALOCP",LOC,DATE))
if 'DATE!(DATE>STOP)
QUIT
Begin DoDot:2
+17 SET IFN=0
FOR
SET IFN=$ORDER(^TIU(8925,"ALOCP",LOC,DATE,IFN))
if 'IFN
QUIT
Begin DoDot:3
+18 DO REPLACE^TIUPRPN3(IFN,DATE,1501)
End DoDot:3
End DoDot:2
End DoDot:1
+19 SET IFN=0
FOR
SET IFN=$ORDER(^TMP("TIUREPLACE",$JOB,IFN))
if 'IFN
QUIT
Begin DoDot:1
+20 SET DFN=$PIECE(^TIU(8925,IFN,0),U,2)
SET SSN=$PIECE(^DPT(DFN,0),U,9)
+21 SET SSN=$EXTRACT(SSN,8,9)_$EXTRACT(SSN,6,7)_$EXTRACT(SSN,4,5)_$EXTRACT(SSN,1,3)
+22 SET DATE=^TMP("TIUREPLACE",$JOB,IFN,"DT")
+23 SET ^TMP("TIUPR",$JOB,SSN_";"_DFN,DATE,IFN)="Vice SF 509"
End DoDot:1
+24 IF '$DATA(^TMP("TIUPR",$JOB))
DO TROUBLE
GOTO EXIT
+25 DO PRINT^TIUPRPN1(1,1)
+26 SET $PIECE(^TIU(8925.94,TIUDIV,1),U)=STOP
EXIT KILL ^TIU("TIUPR",$JOB),^TMP("TIULQ",$JOB),^TMP("TIUREPLACE",$JOB)
+1 QUIT
LOC(LOC,DIV) ;checks if this location should be batch prted
+1 NEW IEN
+2 SET IEN=$ORDER(^TIU(8925.93,"B",LOC,0))
+3 QUIT $SELECT($PIECE($GET(^SC(LOC,0)),U,3)="W":1,$PIECE($GET(^SC(LOC,0)),U,15)'=DIV:1,'$DATA(^TIU(8925.93,+IEN,0)):"",+$GET(^TIU(8925.93,IEN,3)):1,1:"")
+4 ;
TROUBLE ;message to print if no output
+1 WRITE !!,"The option [TIU PRINT PN BATCH OUTPT] ran to completion at "
+2 WRITE !,$$FMTE^XLFDT($$NOW^XLFDT,"1P")," but did not find any notes."
+3 WRITE !!,"If you were expecting notes to print review the following:"
+4 ;
+5 WRITE !!,"INTERACTIVE"
+6 WRITE !,"-----------"
+7 WRITE !,"1. Very little can go wrong- the required criteria is screened"
+8 WRITE !,"while the user is manually queueing the job."
+9 WRITE !!,"2. This option prints all the outpatient progress notes, in"
+10 WRITE !,"terminal digit order, for the selected date range for ALL CLINICS"
+11 WRITE !,"for the selected DIVISION. Verify that you have signed progress"
+12 WRITE !,"notes satisfying this criteria.",!
+13 ;
+14 WRITE !!,"NON-INTERACTIVE (job set to run in OPTION SCHEDULING FILE (#19.2)"
+15 WRITE !,"-----------------------------------------------------------------"
+16 WRITE !,"1. DIVISION must be defined in file #8925.94 (TIU DIVISION PRINT"
+17 WRITE !,"PRINT PARAMETERS FILE)."
+18 WRITE !!,"2. The variable TIUDIV must be defined in the VARIABLE NAME "
+19 WRITE !,"multiple of the OPTION SCHEDULING FILE (#19.2). TIUDIV should"
+20 WRITE !,"be set to the IEN of an entry in the TIU DIVISION PRINT PARAMETERS"
+21 WRITE !,"FILE (#8925.94)."
+22 WRITE !!,"3. This option must find a valid date in field #1.01 of"
+23 WRITE !,"file #8925.94 to start looping on. If a valid date is not "
+24 WRITE !,"found, the option will terminate with this message."
+25 WRITE !!,"4. To assist in troubleshooting, if no notes are found, the"
+26 WRITE !,"DATE/TIME field (#1.01) of file #8925.94 will not be re-set"
+27 WRITE !,"to the new value (which is NOW) when the option begins "
+28 WRITE "calculating."
+29 QUIT