LRRMM ;DALOI/JMC/SED - Lab Reports via Network Mail ;01/29/13 10:26
;;5.2;LAB SERVICE;**164,427**;Sep 27, 1994;Build 33
;
;
LAB ;Requires Lab 5.0 and Mailman 7.0 (Spooling to XMBS GlobaL)
;Enter with LRRLROC=Interim Report Location (File 44 Abbreviation)
; LRRVDT=Date to produce reports for (i.e. "T-1" would
; produce reports for work verified yesterday)
; LRRDEV=Name of the spool Device.
; Default is "SPOOL80" if not defined.
; LRRSITE=Name Of Referring Lab (Should be domain file
; entry i.e "MILWAUKEE.DOMAIN.EXT")
; LRRNORP=1 If "NEGATIVE" Mail Messages are -NOT- Required.
;
N LRRMMPG1
;
S U="^" S:'$D(DTIME) DTIME=600
S:'$D(LRRNORP) LRRNORP=0 S X=$S($D(LRRVDT):LRRVDT,1:"T-1"),%DT="" D ^%DT Q:Y<1 S LRRVDT=Y D DD^LRX S LRRDATE=Y D ^LRPARAM
I '$D(^LRO(69,LRRVDT,1,"AN",LRRLROC))&(LRRNORP) Q
S:$G(LRRDEV)="" LRRDEV="SPOOL80"
D NOW^%DTC
S LRRNAME="LAB REPORTS "_$P(LRRSITE,".",1)_" "_%,IO("DOC")=LRRNAME,IOP=LRRDEV_";"_IO("DOC") D ^%ZIS
S (LRLAB,LREND,LRSTOP,LRFOOT)=0,(LRH,LRONESPC,LRONETST)="",LRCW=8,LRHF=1
U IO I '$D(^LRO(69,LRRVDT,1,"AN",LRRLROC)) W !,"No reports to transmit today." G MAIL
;
S LRRMMPG1=1 ; Flag for first-page. After first report is printed, set flag to 0.
;
S LRDFN=0
F S LRDFN=$O(^LRO(69,LRRVDT,1,"AN",LRRLROC,LRDFN)) Q:LRDFN<1 D
. ;
. S LROC=LRRLROC
. I LRFOOT D FOOT^LRRP1
. S LRFOOT=0,LRHF=1
. S LRDPF=$P(^LR(LRDFN,0),U,2)
. S DFN=$P(^LR(LRDFN,0),U,3)
. D PT^LRX
. ;
. S LRIDT=0
. F S LRIDT=$O(^LRO(69,LRRVDT,1,"AN",LRRLROC,LRDFN,LRIDT)) Q:LRIDT<1 D
. . ;
. . I $D(^LR(LRDFN,"CH",LRIDT)) D
. . . D CH^LRRP2
. . . S LRRMMPG1=0 ; set "first-page flag" to 0
. . ;
. . I $D(^LR(LRDFN,"MI",LRIDT)) D
. . . ; print form-feed before printing Micro report
. . . ; (did not use LRMLTRPT flag (used by RPT^LRMIPSZ1 to print form-feed) - as there it prints form-feed AFTER
. . . ; the report and Chem prints the form-feed BEFORE the report, and we need them to be consistent here)
. . . I LRFOOT D FOOT^LRRP1 S LRFOOT=0 ; print footer of prev report before form-feed
. . . I $G(IOF)'="",'LRRMMPG1 W @IOF
. . . ;
. . . D MI^LRRP2
. . . S LRRMMPG1=0 ; set "first-page flag" to 0
;
D MAIL
;
Q
;
MAIL ; Send the message
;
D:LRFOOT FOOT^LRRP1 W ! D ^%ZISC,KILL^XM
S XMDF=1,XMDUZ=DUZ,X="G.LAB REPORT" D WHO^XMA21
S X="G.LAB REPORT@"_LRRSITE D INST^XMA21
S XMSUB=^DD("SITE")_" LAB REPORTS FOR "_$P(LRRSITE,".",1)_" ON "_LRRDATE
D TSK^LRRMM
Q
;
ONELOC ;Entry point to create lab reports for one location.
D LAB,KILL Q
;
MANYLOC ;Entry point to create lab reports for several sites.
;Enter with LRRLST=List of File #44 Locations (abbreviations)
;Separated by ";" (i.e. LRRLST="XXX;YYY")
;LRRDLST=List of corresponding domain names to send reports
; to (i.e. LRRDLST="AAA.DOMAIN.EXT;BBB.DOMAIN.EXT")
F LRRZZ=1:1 S LRRLROC=$P(LRRLST,";",LRRZZ) Q:LRRLROC="" S LRRSITE=$P(LRRDLST,";",LRRZZ) D LAB
D KILL Q
;
ALLOC ;Entry point to send lab reports to all locations defined in
;file #64.6 (interim reports) that have a domain name entered.
;This requires a field "domain name" being added to #64.6 at
;subscript ^LAB(64.6,D0,0), this is a pointer to the domain file.
S LRRZZ=0
F S LRRZZ=$O(^LAB(64.6,LRRZZ)) Q:'LRRZZ D
.S LRRZZ(0)=+$P($G(^LAB(64.6,LRRZZ,0)),U,7)
.I LRRZZ(0) S LRRLROC=$P($G(^SC(+$P(^LAB(64.6,LRRZZ,0),"^"),0)),"^",2),LRRSITE=$P($G(^DIC(4.2,LRRZZ(0),0)),"^") I LRRLROC]"",LRRSITE]"" D LAB
D KILL Q
;
KILL ;Cleanup before leaving.
S:$D(ZTQUEUED) ZTREQ="@"
K %,%DT,DFN,LRCW,LRDFN,LRDPF,LREND,LRFOOT,LRH,LRHF,LRIDT,LRLAB,LROC
K LRONESPC,LRONETST,LRSTOP,IOP,X,XMDF,Y,ZZ,LRRDATE,LRRDLST
K LRRLROC,LRRLST,LRRNAME,LRRNORP,LRRSITE,LRRVDT,LRRZZ,LRRDEV
D V^LRU,^LRKILL,KILL^XM
Q
TSK ;Entry point from taskman to load a spool file into message.
;Enter with XMSUB=header,XMY(SENDEE NAMES)=""
;LRRNAME=name of spool document file to load into message.
K DIC S:'$D(DTIME) DTIME=300
S U="^",X=LRRNAME,DIC=3.51,DIC(0)="MZ"
D ^DIC Q:Y<1 S DA=+Y,ZISPL0=Y(0),ZISDA=DA K DIC
DQMAIL W:'$D(ZTQUEUED) !,"Moving it..."
S XS=$P(ZISPL0,"^",10),XMY(DUZ)="",XMTEXT="^XMBS(3.519,"_XS_",2,"
D:XS>0 ^XMD D DSDOC^ZISPL(ZISDA),DSD^ZISPL(XS) W:'$D(ZTQUEUED) !," Now a normal mail message.."
I $G(XMZ) S XMDUZ=DUZ D NNEW^XMA ;Make message new for recipient.
D KILL1 Q
;
PRINT ;Entry point from menu option to extract text of message and print it.
D HOME^%ZIS K DIC
ASK ;Select the mailman basket.
S DIC="^XMB(3.7,DUZ,2,",DIC(0)="AEMNQ",DIC("A")="Select Mail Basket: "
S DIC("B")="IN"
W ! D ^DIC G:Y<1 KILL1 S LRRMK=+Y,LRRMKN=$P(Y,"^",2)
K ^TMP($J) S (LRRMC,LRRMZ1)=0
F S LRRMZ1=$O(^XMB(3.7,DUZ,2,LRRMK,1,LRRMZ1)) Q:LRRMZ1<1 D
.S J=+^(LRRMZ1,0)
.Q:$P($G(^XMB(3.9,J,0)),U,1)'["LAB REPORT"
.S LRRMC=LRRMC+1,^TMP($J,"B",LRRMC)=J
W " ",$S(LRRMC=0:"No Lab",1:LRRMC)," Message",$S(LRRMC'=1:"s",1:"")," in basket." G:LRRMC=0 ASK
LIST ;Select the message.
W @IOF,!,"Select from the following:" S (LRRMZ,LRROUT,I)=0
F S I=$O(^TMP($J,"B",I)) Q:'I S LRRMZ=^TMP($J,"B",I) D Q:LRROUT
.I $Y>(IOSL-5) K DIR S DIR(0)="E" D ^DIR K DIR S LRROUT=Y-1 W @IOF Q:LRROUT
.S LRRMR=$G(^XMB(3.9,LRRMZ,0)) Q:LRRMR="" S LRRMSUB=$P(LRRMR,U,1)
.I LRRMSUB["~U~" F S LRRMSUB=$P(LRRMSUB,"~U~",1)_"^"_$P(LRRMSUB,"~U~",2,99) Q:LRRMSUB'["~U~"
.W !,I," Subj: ",LRRMSUB," "
.S Y=$P(LRRMR,U,3),X1=+$P($G(^XMB(3.9,LRRMZ,2,0)),"^",4)
.I Y'?7N.E W Y
.E W $E(Y,4,5),"/",$E(Y,6,7),"/",$E(Y,2,3)," " S Y=$P(Y,".",2)_"0000" W "@ ",$E(Y,1,2),":",$E(Y,3,4)
.W " ",X1," Line",$S(X1>1:"s",1:"")
Q:LRROUT
K DIR S DIR(0)="NO^1:"_LRRMC_":0"
S DIR("A")="Select Message to Extract",DIR("B")=1
S DIR("?")="Enter the number of the message you want printed"
D ^DIR K DIR G:$D(DIRUT) ASK S LRRMZ=$G(^TMP($J,"B",Y))
S %IS="Q" D ^%ZIS I POP D HOME^%ZIS,KILL1 Q
I $D(IO("Q")) S ZTDESC="Extract Text of Mail Message",ZTSAVE("LRRMZ")="",ZTRTN="WRITE^LRRMM" D ^%ZTLOAD W !,"REQUEST ",$S($D(ZTSK):"",1:"NOT "),"QUEUED" K IO("Q"),ZTSK D ^%ZISC G ASK
D WRITE,KILL1 G ASK
;
WRITE ;Print the text of the message.
U IO S LRRCN=.9999
F S LRRCN=$O(^XMB(3.9,LRRMZ,2,LRRCN)) Q:'LRRCN S X=^(LRRCN,0) W:X="|TOP|" @IOF W:X'="|TOP|" X,!
W @IOF D ^%ZISC,KILL1 S:$D(ZTQUEUED) ZTREQ="@" Q
;
KILL1 K ^TMP($J),LRRCN,LRRMC,LRRMK,LRRMKN,LRRMR,LRRMZ,LRRMZ1
K LRRMSUB,LRROUT,%,%IS,DA,DIC,DIR,DIROUT,DIRUT,DUOUT,I,J
K POP,X,X1,XMZ,XS,Y,ZISDA,ZISPL0
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLRRMM 6506 printed Oct 16, 2024@18:20:33 Page 2
LRRMM ;DALOI/JMC/SED - Lab Reports via Network Mail ;01/29/13 10:26
+1 ;;5.2;LAB SERVICE;**164,427**;Sep 27, 1994;Build 33
+2 ;
+3 ;
LAB ;Requires Lab 5.0 and Mailman 7.0 (Spooling to XMBS GlobaL)
+1 ;Enter with LRRLROC=Interim Report Location (File 44 Abbreviation)
+2 ; LRRVDT=Date to produce reports for (i.e. "T-1" would
+3 ; produce reports for work verified yesterday)
+4 ; LRRDEV=Name of the spool Device.
+5 ; Default is "SPOOL80" if not defined.
+6 ; LRRSITE=Name Of Referring Lab (Should be domain file
+7 ; entry i.e "MILWAUKEE.DOMAIN.EXT")
+8 ; LRRNORP=1 If "NEGATIVE" Mail Messages are -NOT- Required.
+9 ;
+10 NEW LRRMMPG1
+11 ;
+12 SET U="^"
if '$DATA(DTIME)
SET DTIME=600
+13 if '$DATA(LRRNORP)
SET LRRNORP=0
SET X=$SELECT($DATA(LRRVDT):LRRVDT,1:"T-1")
SET %DT=""
DO ^%DT
if Y<1
QUIT
SET LRRVDT=Y
DO DD^LRX
SET LRRDATE=Y
DO ^LRPARAM
+14 IF '$DATA(^LRO(69,LRRVDT,1,"AN",LRRLROC))&(LRRNORP)
QUIT
+15 if $GET(LRRDEV)=""
SET LRRDEV="SPOOL80"
+16 DO NOW^%DTC
+17 SET LRRNAME="LAB REPORTS "_$PIECE(LRRSITE,".",1)_" "_%
SET IO("DOC")=LRRNAME
SET IOP=LRRDEV_";"_IO("DOC")
DO ^%ZIS
+18 SET (LRLAB,LREND,LRSTOP,LRFOOT)=0
SET (LRH,LRONESPC,LRONETST)=""
SET LRCW=8
SET LRHF=1
+19 USE IO
IF '$DATA(^LRO(69,LRRVDT,1,"AN",LRRLROC))
WRITE !,"No reports to transmit today."
GOTO MAIL
+20 ;
+21 ; Flag for first-page. After first report is printed, set flag to 0.
SET LRRMMPG1=1
+22 ;
+23 SET LRDFN=0
+24 FOR
SET LRDFN=$ORDER(^LRO(69,LRRVDT,1,"AN",LRRLROC,LRDFN))
if LRDFN<1
QUIT
Begin DoDot:1
+25 ;
+26 SET LROC=LRRLROC
+27 IF LRFOOT
DO FOOT^LRRP1
+28 SET LRFOOT=0
SET LRHF=1
+29 SET LRDPF=$PIECE(^LR(LRDFN,0),U,2)
+30 SET DFN=$PIECE(^LR(LRDFN,0),U,3)
+31 DO PT^LRX
+32 ;
+33 SET LRIDT=0
+34 FOR
SET LRIDT=$ORDER(^LRO(69,LRRVDT,1,"AN",LRRLROC,LRDFN,LRIDT))
if LRIDT<1
QUIT
Begin DoDot:2
+35 ;
+36 IF $DATA(^LR(LRDFN,"CH",LRIDT))
Begin DoDot:3
+37 DO CH^LRRP2
+38 ; set "first-page flag" to 0
SET LRRMMPG1=0
End DoDot:3
+39 ;
+40 IF $DATA(^LR(LRDFN,"MI",LRIDT))
Begin DoDot:3
+41 ; print form-feed before printing Micro report
+42 ; (did not use LRMLTRPT flag (used by RPT^LRMIPSZ1 to print form-feed) - as there it prints form-feed AFTER
+43 ; the report and Chem prints the form-feed BEFORE the report, and we need them to be consistent here)
+44 ; print footer of prev report before form-feed
IF LRFOOT
DO FOOT^LRRP1
SET LRFOOT=0
+45 IF $GET(IOF)'=""
IF 'LRRMMPG1
WRITE @IOF
+46 ;
+47 DO MI^LRRP2
+48 ; set "first-page flag" to 0
SET LRRMMPG1=0
End DoDot:3
End DoDot:2
End DoDot:1
+49 ;
+50 DO MAIL
+51 ;
+52 QUIT
+53 ;
MAIL ; Send the message
+1 ;
+2 if LRFOOT
DO FOOT^LRRP1
WRITE !
DO ^%ZISC
DO KILL^XM
+3 SET XMDF=1
SET XMDUZ=DUZ
SET X="G.LAB REPORT"
DO WHO^XMA21
+4 SET X="G.LAB REPORT@"_LRRSITE
DO INST^XMA21
+5 SET XMSUB=^DD("SITE")_" LAB REPORTS FOR "_$PIECE(LRRSITE,".",1)_" ON "_LRRDATE
+6 DO TSK^LRRMM
+7 QUIT
+8 ;
ONELOC ;Entry point to create lab reports for one location.
+1 DO LAB
DO KILL
QUIT
+2 ;
MANYLOC ;Entry point to create lab reports for several sites.
+1 ;Enter with LRRLST=List of File #44 Locations (abbreviations)
+2 ;Separated by ";" (i.e. LRRLST="XXX;YYY")
+3 ;LRRDLST=List of corresponding domain names to send reports
+4 ; to (i.e. LRRDLST="AAA.DOMAIN.EXT;BBB.DOMAIN.EXT")
+5 FOR LRRZZ=1:1
SET LRRLROC=$PIECE(LRRLST,";",LRRZZ)
if LRRLROC=""
QUIT
SET LRRSITE=$PIECE(LRRDLST,";",LRRZZ)
DO LAB
+6 DO KILL
QUIT
+7 ;
ALLOC ;Entry point to send lab reports to all locations defined in
+1 ;file #64.6 (interim reports) that have a domain name entered.
+2 ;This requires a field "domain name" being added to #64.6 at
+3 ;subscript ^LAB(64.6,D0,0), this is a pointer to the domain file.
+4 SET LRRZZ=0
+5 FOR
SET LRRZZ=$ORDER(^LAB(64.6,LRRZZ))
if 'LRRZZ
QUIT
Begin DoDot:1
+6 SET LRRZZ(0)=+$PIECE($GET(^LAB(64.6,LRRZZ,0)),U,7)
+7 IF LRRZZ(0)
SET LRRLROC=$PIECE($GET(^SC(+$PIECE(^LAB(64.6,LRRZZ,0),"^"),0)),"^",2)
SET LRRSITE=$PIECE($GET(^DIC(4.2,LRRZZ(0),0)),"^")
IF LRRLROC]""
IF LRRSITE]""
DO LAB
End DoDot:1
+8 DO KILL
QUIT
+9 ;
KILL ;Cleanup before leaving.
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 KILL %,%DT,DFN,LRCW,LRDFN,LRDPF,LREND,LRFOOT,LRH,LRHF,LRIDT,LRLAB,LROC
+3 KILL LRONESPC,LRONETST,LRSTOP,IOP,X,XMDF,Y,ZZ,LRRDATE,LRRDLST
+4 KILL LRRLROC,LRRLST,LRRNAME,LRRNORP,LRRSITE,LRRVDT,LRRZZ,LRRDEV
+5 DO V^LRU
DO ^LRKILL
DO KILL^XM
+6 QUIT
TSK ;Entry point from taskman to load a spool file into message.
+1 ;Enter with XMSUB=header,XMY(SENDEE NAMES)=""
+2 ;LRRNAME=name of spool document file to load into message.
+3 KILL DIC
if '$DATA(DTIME)
SET DTIME=300
+4 SET U="^"
SET X=LRRNAME
SET DIC=3.51
SET DIC(0)="MZ"
+5 DO ^DIC
if Y<1
QUIT
SET DA=+Y
SET ZISPL0=Y(0)
SET ZISDA=DA
KILL DIC
DQMAIL if '$DATA(ZTQUEUED)
WRITE !,"Moving it..."
+1 SET XS=$PIECE(ZISPL0,"^",10)
SET XMY(DUZ)=""
SET XMTEXT="^XMBS(3.519,"_XS_",2,"
+2 if XS>0
DO ^XMD
DO DSDOC^ZISPL(ZISDA)
DO DSD^ZISPL(XS)
if '$DATA(ZTQUEUED)
WRITE !," Now a normal mail message.."
+3 ;Make message new for recipient.
IF $GET(XMZ)
SET XMDUZ=DUZ
DO NNEW^XMA
+4 DO KILL1
QUIT
+5 ;
PRINT ;Entry point from menu option to extract text of message and print it.
+1 DO HOME^%ZIS
KILL DIC
ASK ;Select the mailman basket.
+1 SET DIC="^XMB(3.7,DUZ,2,"
SET DIC(0)="AEMNQ"
SET DIC("A")="Select Mail Basket: "
+2 SET DIC("B")="IN"
+3 WRITE !
DO ^DIC
if Y<1
GOTO KILL1
SET LRRMK=+Y
SET LRRMKN=$PIECE(Y,"^",2)
+4 KILL ^TMP($JOB)
SET (LRRMC,LRRMZ1)=0
+5 FOR
SET LRRMZ1=$ORDER(^XMB(3.7,DUZ,2,LRRMK,1,LRRMZ1))
if LRRMZ1<1
QUIT
Begin DoDot:1
+6 SET J=+^(LRRMZ1,0)
+7 if $PIECE($GET(^XMB(3.9,J,0)),U,1)'["LAB REPORT"
QUIT
+8 SET LRRMC=LRRMC+1
SET ^TMP($JOB,"B",LRRMC)=J
End DoDot:1
+9 WRITE " ",$SELECT(LRRMC=0:"No Lab",1:LRRMC)," Message",$SELECT(LRRMC'=1:"s",1:"")," in basket."
if LRRMC=0
GOTO ASK
LIST ;Select the message.
+1 WRITE @IOF,!,"Select from the following:"
SET (LRRMZ,LRROUT,I)=0
+2 FOR
SET I=$ORDER(^TMP($JOB,"B",I))
if 'I
QUIT
SET LRRMZ=^TMP($JOB,"B",I)
Begin DoDot:1
+3 IF $Y>(IOSL-5)
KILL DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
SET LRROUT=Y-1
WRITE @IOF
if LRROUT
QUIT
+4 SET LRRMR=$GET(^XMB(3.9,LRRMZ,0))
if LRRMR=""
QUIT
SET LRRMSUB=$PIECE(LRRMR,U,1)
+5 IF LRRMSUB["~U~"
FOR
SET LRRMSUB=$PIECE(LRRMSUB,"~U~",1)_"^"_$PIECE(LRRMSUB,"~U~",2,99)
if LRRMSUB'["~U~"
QUIT
+6 WRITE !,I," Subj: ",LRRMSUB," "
+7 SET Y=$PIECE(LRRMR,U,3)
SET X1=+$PIECE($GET(^XMB(3.9,LRRMZ,2,0)),"^",4)
+8 IF Y'?7N.E
WRITE Y
+9 IF '$TEST
WRITE $EXTRACT(Y,4,5),"/",$EXTRACT(Y,6,7),"/",$EXTRACT(Y,2,3)," "
SET Y=$PIECE(Y,".",2)_"0000"
WRITE "@ ",$EXTRACT(Y,1,2),":",$EXTRACT(Y,3,4)
+10 WRITE " ",X1," Line",$SELECT(X1>1:"s",1:"")
End DoDot:1
if LRROUT
QUIT
+11 if LRROUT
QUIT
+12 KILL DIR
SET DIR(0)="NO^1:"_LRRMC_":0"
+13 SET DIR("A")="Select Message to Extract"
SET DIR("B")=1
+14 SET DIR("?")="Enter the number of the message you want printed"
+15 DO ^DIR
KILL DIR
if $DATA(DIRUT)
GOTO ASK
SET LRRMZ=$GET(^TMP($JOB,"B",Y))
+16 SET %IS="Q"
DO ^%ZIS
IF POP
DO HOME^%ZIS
DO KILL1
QUIT
+17 IF $DATA(IO("Q"))
SET ZTDESC="Extract Text of Mail Message"
SET ZTSAVE("LRRMZ")=""
SET ZTRTN="WRITE^LRRMM"
DO ^%ZTLOAD
WRITE !,"REQUEST ",$SELECT($DATA(ZTSK):"",1:"NOT "),"QUEUED"
KILL IO("Q"),ZTSK
DO ^%ZISC
GOTO ASK
+18 DO WRITE
DO KILL1
GOTO ASK
+19 ;
WRITE ;Print the text of the message.
+1 USE IO
SET LRRCN=.9999
+2 FOR
SET LRRCN=$ORDER(^XMB(3.9,LRRMZ,2,LRRCN))
if 'LRRCN
QUIT
SET X=^(LRRCN,0)
if X="|TOP|"
WRITE @IOF
if X'="|TOP|"
WRITE X,!
+3 WRITE @IOF
DO ^%ZISC
DO KILL1
if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
+4 ;
KILL1 KILL ^TMP($JOB),LRRCN,LRRMC,LRRMK,LRRMKN,LRRMR,LRRMZ,LRRMZ1
+1 KILL LRRMSUB,LRROUT,%,%IS,DA,DIC,DIR,DIROUT,DIRUT,DUOUT,I,J
+2 KILL POP,X,X1,XMZ,XS,Y,ZISDA,ZISPL0
+3 QUIT