BLRUTIL8 ;IHS/MSC/MKK - MISC IHS LAB UTILITIES (Cont) ; 01-Jun-2016 06:49 ; MKK
;;5.2;IHS LABORATORY;**1037,1039**;NOV 01, 1997;Build 38
;
DUPDNAME ; EP - Find Instances of Duplicate DataNames
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
;
Q:$$DUPNAMEI()="Q"
;
F S DATADESC=$O(^DD(63.04,"B",DATADESC)) Q:DATADESC=""!(QFLG="Q") D DUPNAMEL
;
; W !!,?4,"Number of Duplicate Datanames = ",CNT
;
; ----- BEGIN IHS/MSC/MKK - LR*5.2*1034
W !!,?4,DATANCNT," DataNames Analyzed."
W !!,?9,$S(CNT:CNT,1:"No")," Duplicate DataName",$S(CNT=1:"",1:"s"),"."
; ----- END IHS/MSC/MKK - LR*5.2*1034
;
D ^%ZISC
;
D PRESSKEY^BLRGMENU(9)
Q
;
DUPNAMEI() ; EP - Initialization
D SETBLRVS("DUPDNAME")
;
S HEADER(1)="Duplicate DataNames"
S HEADER(2)="File 63.04"
;
D HEADERDT^BLRGMENU
D HEADONE^BLRGMENU(.HDRONE)
;
S HEADER(3)=" "
S $E(HEADER(4),10)="#"
S $E(HEADER(4),20)="Description"
S $E(HEADER(4),50)="Last Edit"
S $E(HEADER(4),65)="F 60"
;
D ^%ZIS
I POP D Q "Q"
. W !,?4,"Invalid DEVICE call. Routine Ends."
. D PRESSKEY^BLRGMENU(9)
;
U IO
;
S (CNT,PG)=0
S MAXLINES=(IOSL-4),LINES=MAXLINES+10
S QFLG="NO"
S DATADESC=""
S DATANCNT=0 ; IHS/MSC/MKK - LR*5.2*1034
Q "OK"
;
DUPNAMEL ; EP - Line of Data
Q:$$DUPNAMEC(.DUPNAMEA)=0
;
I LINES>MAXLINES D HEADERPG^BLRGMENU(.PG,.QFLG,HDRONE) Q:QFLG="Q"
;
S (CNTDN,DATANAME)=0
F S DATANAME=$O(DUPNAMEA(DATANAME)) Q:DATANAME<1!(QFLG="Q") D
. I LINES>MAXLINES D HEADERPG^BLRGMENU(.PG,.QFLG,HDRONE) Q:QFLG="Q"
. ;
. S CNTDN=CNTDN+1
. W $J(CNTDN,3)
. W ?9,DATANAME
. W ?19,$E(DATADESC,1,28)
. S CREATEDT=$G(DUPNAMEA(DATANAME,"DT"))
. W:$L(CREATEDT) ?49,$$FMTE^XLFDT(CREATEDT,"5DZ")
. W ?65,$O(^LAB(60,"C","CH;"_DATANAME_";1",0))
. W !
. S LINES=LINES+1
;
W !
S LINES=LINES+1
S CNT=CNT+1
Q
;
DUPNAMEC(ARRAY) ; EP - Check on the DataName
S DATANCNT=DATANCNT+1 ; IHS/MSC/MKK - LR*5.2*1034
;
NEW DN,NUMDUPS
;
K ARRAY
;
S (DN,NUMDUPS)=0
F S DN=$O(^DD(63.04,"B",DATADESC,DN)) Q:DN<1 D
. S NUMDUPS=NUMDUPS+1
. S ARRAY(DN)=""
. S ARRAY(DN,"DT")=$G(^DD(63.04,DN,"DT"))
;
Q $S(NUMDUPS<2:1,1:0)
;
SETBLRVS(TWO) ; EP - Use the STACK to find the Routine and set the BLRVRN variable(S)
; S CONTXT=$STACK(-1)-1
; S:CONTXT<1 CONTXT=1
; S PLACE=$STACK(CONTXT,"PLACE")
; S BLRVERN=$P($P(PLACE,"^",2)," ")
; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039 - Don't use $STACK
K BLRVERN,BLRVERN2
;
S BLRVERN=$P($P($T(+1),";")," ")
; ----- END IHS/MSC/MKK - LR*5.2*1039
S:$L($G(TWO)) BLRVERN2=TWO
Q
;
; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039
ARRIVETM(LRDFN,LRSS,LRIDT) ; EP - Print Arrival Time on Interim Report -- called from LRRP1
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRDFN,LRSS,LRIDT,U,XPARSYS,XQXFLG)
;
Q:LRSS="MI" ; Micro Interim Reports already has RECEIVED date.
;
S UID=$G(^LR(LRDFN,LRSS,LRIDT,"ORU"))
Q:$L(UID)<1
;
S LRC=$Q(^LRO(68,"C",UID))
Q:$QS(LRC,3)'=UID
S LRAA=$QS(LRC,4),LRAD=$QS(LRC,5),LRAN=$QS(LRC,6)
S ARRIVTI=$$GET1^DIQ(68.02,LRAN_","_LRAD_","_LRAA,12,"I") ; Arrival Time Internal (FileMan)
Q:ARRIVTI<1
;
I LRSS'="MI" D
. S ARRIVTE="Lab Arrival Date/Time:"_$$FMTE^XLFDT(ARRIVTI,"2MZ") ; Arrival Time External
. W ?(IOM-$L(ARRIVTE)-1),ARRIVTE
Q
;
;
; Send MAILMAN/ALERT to a specified MAIL GROUP
MAILALMI(MESSAGE,MSGARRAY,FROMWHOM,NOUSER,MAILGROUP) ; EP - Generic MAILER/ALERTER - allows any MailGroup
NEW MAILARRY
;
S MAILGROUP="G."_$G(MAILGROUP,"LMI")
;
; Send MESSAGE string as ALERT
D SNDALERT(MESSAGE,$G(NOUSER),MAILGROUP)
;
; Setup variables for sending MailMan e-mail
I $L($G(MSGARRAY(1))) M MAILARRY=MSGARRAY
;
I $L($G(MSGARRAY(1)))<1 D ; If MSGARRAY null, create generic array
. S MAILARRY(1)="The Subject of this email is the message:"
. S MAILARRY(2)=" "_MESSAGE
;
I $G(FROMWHOM)="" S FROMWHOM="RPMS Lab Package"
;
D SENDMAIL(MESSAGE,.MAILARRY,FROMWHOM,$G(NOUSER),MAILGROUP)
;
Q
;
;
SNDALERT(ALERTMSG,NOUSER,MAILGROUP) ; EP - Send Alert
S XQAMSG=ALERTMSG
S XQA(MAILGROUP)=""
;
; If User NOT a member of the Mail Group, send them alert also, but
; If-And-Only-If the NOUSER variable is null.
S:$G(NOUSER)=""&($$NINMGRP(MAILGROUP,DUZ)) XQA(DUZ)=""
;
S X=$$SETUP1^XQALERT
K XQA,XQAMSG
Q:X
;
; If ALERT call failed, store information
NEW SUBSCRPT
S SUBSCRPT="BLR Alert^"_+$H_"^"_$J
S ^XTMP(SUBSCRPT,0)=$$FMADD^XLFDT($$DT^XLFDT,90)_"^"_$$DT^XLFDT_"^"_"Lab Package Alert."
S ^XTMP(SUBSCRPT,1)="Alert was not sent."
S ^XTMP(SUBSCRPT,2)=" Message that should have been sent follows:"
S ^XTMP(SUBSCRPT,3)=" "_ALERTMSG
S ^XTMP(SUBSCRPT,4)=" ALERT Error Message Follows:"
S ^XTMP(SUBSCRPT,5)=" "_XQALERR
Q
;
;
; Send MailMan E-mail to MailGroup
SENDMAIL(MAILMSG,MAILARRY,FROMWHOM,NOUSER,MAILGROUP) ; EP
NEW DIFROM
;
K XMY
S XMY(MAILGROUP)=""
;
; If User not part of MailGroup, send them e-mail also, but
; If-And-Only-If the NOUSER variable is null.
S:$G(NOUSER)=""&($$NINMGRP(MAILGROUP,DUZ)) XMY(DUZ)=""
;
S LRBLNOW=$E($$NOW^XLFDT,1,12)
;
S XMSUB=MAILMSG
S XMTEXT="MAILARRY("
S XMDUZ=FROMWHOM
S XMZ="NOT OKAY"
D ^XMD
;
I $G(XMMG)'=""!(XMZ="NOT OKAY") D
. NEW SUBSCRPT,ARRAY
. S SUBSCRPT="MailMan Message Failure for Group "_MAILGROUP_"^"_$$HTFM^XLFDT($H)_"^"_$J
. S ^XTMP(SUBSCRPT,0)=$$FMADD^XLFDT($$DT^XLFDT,90)_"^"_$$DT^XLFDT_"^"_"Lab Package MailMan Message."
. S ^XTMP(SUBSCRPT,1)="MailMan Message was not sent."
. S ^XTMP(SUBSCRPT,2)=" Message that should have been sent follows:"
. S ARRAY=0
. F S ARRAY=$O(MAILARRY(ARRAY)) Q:ARRAY<1 D
.. S ^XTMP(SUBSCRPT,(ARRAY+2))=" "_$G(MAILARRY(ARRAY))
;
K X,XMDUZ,XMSUB,XMTEXT,XMY,XMZ,Y ; Cleanup
Q
;
NINMGRP(MAILGROUP,USERDUZ) ; EP - Is User NOT a member of the MailGroup?
NEW MGIEN,XMDUZ,Y
S MGIEN=+$$FIND1^DIC(3.8,,,$P(MAILGROUP,".",2))
Q:MGIEN<1 0
;
S XMDUZ=USERDUZ,Y=MGIEN
D CHK^XMA21
Q '$T
;
RJZF(NUM,LEN) ; EP - Right Justify, Zero Fill function
Q $S((NUM'?.N):"",1:$TR($J(NUM,LEN)," ","0")) ; If NUM variable not a number, return NULL
;
; The following is called from LR7OF1
; If Urgency is ASAP or STAT or Hospital Location["EMER", send
; Alert & E-Mail to LAB HIGH URGENCY NOTIFICATION Mail Group
IHSURGNT ; EP
Q:+$$GET^XPAR("PKG","BLR EMERGENCY ALERT",1,"Q")<1 ; Skip if XPAR is 'OFF'
Q:+$G(ORIFN)<1 ; Skip if file 100 IEN < 1
;
NEW HOSPDIV,LABORD,MESSAGE,MSGARRAY,URGSTR
;
S HOSPDIV=$$UP^XLFSTR($$GET1^DIQ(100,ORIFN,"PATIENT LOCATION"))
S URGSTR=$$UP^XLFSTR($$GET1^DIQ(62.05,+$$VALUE^ORCSAVE2(ORIFN,"URGENCY"),.01))
;
; Skip if not URGENT and not ASAP and not from Emergency room
Q:URGSTR'["STAT"&(URGSTR'["ASAP")&(HOSPDIV'["EMER")
;
S LABORD=+$$GET1^DIQ(69.01,+$G(LRSN)_","_+$G(LRODT),9.5)
S:LABORD<1 LABORD=+$$GET1^DIQ(100,ORIFN,"PACKAGE REFERENCE")
;
S MESSAGE="**URGENT** Lab Order:"_LABORD_" Location:"_HOSPDIV_" HRCN:"_$G(HRCN)
;
S MSGARRAY(1)="Lab Order #:"_LABORD_" OERR #:"_ORIFN_" detail:"
S MSGARRAY(2)=" "
S MSGARRAY(3)=$J("",5)_"Patient Name:"_$G(LRPNM)_" HRCN:"_$G(HRCN)
S MSGARRAY(4)=" "
S MSGARRAY(5)=$J("",10)_"TEST:"_$P($G(MSG(5)),U,5)
;
D MAILALMI^BLRUTIL8(MESSAGE,.MSGARRAY,,1,"LAB HIGH URGENCY NOTIFICATION")
Q
;
;
LABGLOBR ; EP - Given Accession number/UID, list Data from Files 68, 69 & 63.
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
;
Q:$$DETAILIN("DETAIL")="Q"
;
D LRASDATA(LRAA,LRAD,LRAN,9)
;
D ORDRDATA
;
D LABDATA
;
D PRESSKEY^BLRGMENU(4)
Q
;
DETAILIN(SUBRTN) ; EP - Initialize variables
NEW COL,COL2
;
D ^XBCLS
D ^LRWU4
W !!
;
I $D(^LRO(68,LRAA,1,LRAD,1,LRAN,0))<1 Q $$BADSTUFF^BLRUTIL7("Accession does not Exist.")
;
S LRSS=$$GET1^DIQ(68,LRAA,.02,"I")
S LRAAIEN=LRAN_","_LRAD_","_LRAA
S ORDERNUM=$$GET1^DIQ(68.02,LRAAIEN,14,"I")
S LRAS=$$GET1^DIQ(68.02,LRAAIEN,15)
S UID=$$GET1^DIQ(68.02,LRAAIEN,16)
;
Q "OK"
;
;
LRASDATA(LRAA,LRAD,LRAN,LM,RM) ; EP - Display File 68 Data
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRAA,LRAD,LRAN,NOPRESS,LM,RM,U,XPARSYS,XQXFLG)
;
D ^XBCLS
;
W !
D LINEMSG("Accession (#68) file data","=",5)
;
S NOMORE="^LRO(68,"_LRAA_",1,"_LRAD_",1,"_LRAN
S NOMOREL=$L(NOMORE)
S LETSGO=NOMORE_")"
;
S LM=$G(LM,4) ; Left Margin
S RM=$G(RM,(IOM-5)) ; Right Margin
;
S STR1=$Q(@LETSGO@(""))
W ?LM,STR1,"=" S TAB=$X D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
F S STR1=$Q(@STR1) Q:STR1=""!($E(STR1,1,NOMOREL)'=NOMORE) D
. W ?(LM+5),STR1,"=" S TAB=$X
. D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
;
Q
;
;
ORDRDATA ; EP - Display data from the ORDER file
NEW ORDERDT,LRSN
;
W !
D LINEMSG("Lab Order Entry (#69) file Data","=",5)
;
I +ORDERNUM<1 W ?7,"No Order File Data",! Q
;
S LRODT=0
F S LRODT=$O(^LRO(69,"C",ORDERNUM,LRODT)) Q:LRODT<1 D
. S LRSP=0
. F S LRSP=$O(^LRO(69,"C",ORDERNUM,LRODT,LRSP)) Q:LRSP<1 D
.. D LRORDATA(LRODT,LRSP,9)
Q
;
;
LRORDATA(LRODT,LRSP,LM,RM) ; EP - Display File 69 Data
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRODT,LRSP,LM,NOPRESS,RM,U,XPARSYS,XQXFLG)
;
S NOMORE="^LRO(69,"_LRODT_",1,"_LRSP
S NOMOREL=$L(NOMORE)
S LETSGO=NOMORE_")"
;
S LM=$G(LM,4) ; Left Margin
S RM=$G(RM,(IOM-5)) ; Right Margin
;
S STR1=$Q(@LETSGO@(""))
W ?LM,STR1,"=" S TAB=$X D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
F S STR1=$Q(@STR1) Q:STR1=""!($E(STR1,1,NOMOREL)'=NOMORE) D
. W ?(LM+5),STR1,"=" S TAB=$X
. D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
;
Q
;
;
LABDATA ; EP - Display Data from Lab Data file, if it exists -- LRAA,LRAD,LRAN must exist
NEW CNT,LRDFN,LRIDT,LRSUB,STR
;
S LRDFN=$$GET1^DIQ(68.02,LRAAIEN,.01,"I")
S LRIDT=$$GET1^DIQ(68.02,LRAAIEN,13.5,"I")
S STR=$G(^LR(LRDFN,LRSS,LRIDT,0))
;
I $D(^LR(LRDFN,LRSS,LRIDT))<1 D Q
. W !
. D LINEONE("LRDFN:"_LRDFN_", LRIDT:"_LRIDT_", File #63 Data DOES NOT exist.","=")
. W !
;
W !
D LINEMSG("Lab Data (#63) file data","=",5)
;
D LABDATAD(LRDFN,LRSS,LRIDT,1,9)
Q
;
;
LABDATAD(LRDFN,LRSS,LRIDT,NOPRESS,LM,RM) ; EP - Display File 63 Data
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRDFN,LRSS,LRIDT,NOPRESS,LM,RM,U,XPARSYS,XQXFLG)
;
S NOMORE="^LR("_LRDFN_","_$C(34)_LRSS_$C(34)_","_LRIDT
S NOMOREL=$L(NOMORE)
S LETSGO=NOMORE_")"
;
S LM=$G(LM,4) ; Left Margin
S RM=$G(RM,(IOM-5)) ; Right Margin
S NOPRESS=$G(NOPRESS,0) ; Flag for PRESSKEY call below
;
S STR1=$Q(@LETSGO@(""))
W ?LM,STR1,"=" S TAB=$X D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
F S STR1=$Q(@STR1) Q:STR1=""!($E(STR1,1,NOMOREL)'=NOMORE) D
. W ?(LM+5),STR1,"=" S TAB=$X
. I $P(STR1,",",4)>1 D
.. S DN=$P($P(STR1,",",4),")")
.. S F60IEN=$O(^LAB(60,"C","CH;"_DN_";1",0))
.. W $S(LRSS="CH":$$GET1^DIQ(60,F60IEN,.01),1:""),!
. D LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB)) W !
;
Q:$G(NOPRESS) ; Skip if the PRESSKEY call is not wanted
;
D PRESSKEY^BLRGMENU(LM)
Q
;
LINEONE(MSG,FILLER) ; EP - Demarcation line
S MSG="@"_$TR(MSG," ","@")_"@"
S MSG=$TR($$CJ^XLFSTR(MSG,70)," @",FILLER_" ")
W ?4,MSG,!
Q
;
LINEMSG(MSG,FILLER,TAB) ; EP - Demarcation line, Version 2
S MSG="@"_$TR(MSG," ","@")_"@"
S MSG=$TR($$CJ^XLFSTR(MSG,(IOM-$S(+$G(TAB):TAB*2,1:0)))," @",FILLER_" ")
W ?($S(+$G(TAB):TAB-1,1:0)),MSG,!!
Q
;
;
LAHREPT ; EP - ^LAH Update Date Report
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
;
S HEADER(1)="^LAH Global Report"
D HEADERDT^BLRGMENU
D ^XBFMK
S DIR(0)="PO^68.2:EMZ"
D ^DIR
I +$G(DIRUT) D BADSTUFF^BLRUTIL7("No/Quit/Invalid Input.") Q
;
S LWL=+Y,LWLDESC=$P(Y,U,2)
;
S HEADER(2)="LOAD/WORK LIST "_LWLDESC_" ["_LWL_"]"
D HEADERDT^BLRGMENU
D HEADONE^BLRGMENU(.HDRONE)
D HEADERDT^BLRGMENU
;
S HEADER(3)=" "
S $E(HEADER(4),5)="UID"
S $E(HEADER(4),20)="Create Date/Time"
S $E(HEADER(4),40)="Update Date/Time"
S $E(HEADER(4),60)="Time Difference"
;
S MAXLINES=IOSL-4,LINES=MAXLINES+10
S (CNT,PG)=0,QFLG="NO"
;
S (ISQN,ISQNCNT)=0
F S ISQN=$O(^LAH(LWL,1,ISQN)) Q:ISQN<1!(QFLG="Q") D
. S ISQNCNT=ISQNCNT+1
. S LRUID=$G(^LAH(LWL,1,ISQN,.3))
. Q:LRUID=""
. ;
. S STRZERO=$G(^LAH(LWL,1,ISQN,0))
. S CREATDTT=$P(STRZERO,U,10)
. S UPDTDTT=$P(STRZERO,U,11)
. ;
. I LINES>MAXLINES D HEADERPG^BLRGMENU(.PG,.QFLG,HDRONE) Q:QFLG="Q"
. ;
. W ?4,LRUID
. W:CREATDTT ?19,$$FMTE^XLFDT(CREATDTT,"5MZ")
. W:UPDTDTT ?39,$$FMTE^XLFDT(UPDTDTT,"5MZ")
. I CREATDTT,UPDTDTT D
.. W:$E(CREATDTT,1,12)'=$E(UPDTDTT,1,12) ?60,$J($$FMDIFF^XLFDT(UPDTDTT,CREATDTT,3),13)
. W !
. S LINES=LINES+1
. S CNT=CNT+1
;
W !!,?4,ISQNCNT," entries analyzed."
W !!,?9,$S(CNT:CNT,1:"No")," entr",$$PLURALI^BLRUTIL7(CNT)," with UIDs."
D PRESSKEY^BLRGMENU(4)
Q
;
; ============================= UTILITIES =============================
;
JUSTNEW ; EP - Generic RPMS EXCLUSIVE NEW
NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
;
Q
; ----- END IHS/MSC/MKK - LR*5.2*1039
BLRUTIL8 ;IHS/MSC/MKK - MISC IHS LAB UTILITIES (Cont) ; 01-Jun-2016 06:49 ; MKK
+1 ;;5.2;IHS LABORATORY;**1037,1039**;NOV 01, 1997;Build 38
+2 ;
DUPDNAME ; EP - Find Instances of Duplicate DataNames
+1 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
+2 ;
+3 IF $$DUPNAMEI()="Q"
QUIT
+4 ;
+5 FOR
SET DATADESC=$ORDER(^DD(63.04,"B",DATADESC))
IF DATADESC=""!(QFLG="Q")
QUIT
DO DUPNAMEL
+6 ;
+7 ; W !!,?4,"Number of Duplicate Datanames = ",CNT
+8 ;
+9 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1034
+10 WRITE !!,?4,DATANCNT," DataNames Analyzed."
+11 WRITE !!,?9,$SELECT(CNT:CNT,1:"No")," Duplicate DataName",$SELECT(CNT=1:"",1:"s"),"."
+12 ; ----- END IHS/MSC/MKK - LR*5.2*1034
+13 ;
+14 DO ^%ZISC
+15 ;
+16 DO PRESSKEY^BLRGMENU(9)
+17 QUIT
+18 ;
DUPNAMEI() ; EP - Initialization
+1 DO SETBLRVS("DUPDNAME")
+2 ;
+3 SET HEADER(1)="Duplicate DataNames"
+4 SET HEADER(2)="File 63.04"
+5 ;
+6 DO HEADERDT^BLRGMENU
+7 DO HEADONE^BLRGMENU(.HDRONE)
+8 ;
+9 SET HEADER(3)=" "
+10 SET $EXTRACT(HEADER(4),10)="#"
+11 SET $EXTRACT(HEADER(4),20)="Description"
+12 SET $EXTRACT(HEADER(4),50)="Last Edit"
+13 SET $EXTRACT(HEADER(4),65)="F 60"
+14 ;
+15 DO ^%ZIS
+16 IF POP
Begin DoDot:1
+17 WRITE !,?4,"Invalid DEVICE call. Routine Ends."
+18 DO PRESSKEY^BLRGMENU(9)
End DoDot:1
QUIT "Q"
+19 ;
+20 USE IO
+21 ;
+22 SET (CNT,PG)=0
+23 SET MAXLINES=(IOSL-4)
SET LINES=MAXLINES+10
+24 SET QFLG="NO"
+25 SET DATADESC=""
+26 ; IHS/MSC/MKK - LR*5.2*1034
SET DATANCNT=0
+27 QUIT "OK"
+28 ;
DUPNAMEL ; EP - Line of Data
+1 IF $$DUPNAMEC(.DUPNAMEA)=0
QUIT
+2 ;
+3 IF LINES>MAXLINES
DO HEADERPG^BLRGMENU(.PG,.QFLG,HDRONE)
IF QFLG="Q"
QUIT
+4 ;
+5 SET (CNTDN,DATANAME)=0
+6 FOR
SET DATANAME=$ORDER(DUPNAMEA(DATANAME))
IF DATANAME<1!(QFLG="Q")
QUIT
Begin DoDot:1
+7 IF LINES>MAXLINES
DO HEADERPG^BLRGMENU(.PG,.QFLG,HDRONE)
IF QFLG="Q"
QUIT
+8 ;
+9 SET CNTDN=CNTDN+1
+10 WRITE $JUSTIFY(CNTDN,3)
+11 WRITE ?9,DATANAME
+12 WRITE ?19,$EXTRACT(DATADESC,1,28)
+13 SET CREATEDT=$GET(DUPNAMEA(DATANAME,"DT"))
+14 IF $LENGTH(CREATEDT)
WRITE ?49,$$FMTE^XLFDT(CREATEDT,"5DZ")
+15 WRITE ?65,$ORDER(^LAB(60,"C","CH;"_DATANAME_";1",0))
+16 WRITE !
+17 SET LINES=LINES+1
End DoDot:1
+18 ;
+19 WRITE !
+20 SET LINES=LINES+1
+21 SET CNT=CNT+1
+22 QUIT
+23 ;
DUPNAMEC(ARRAY) ; EP - Check on the DataName
+1 ; IHS/MSC/MKK - LR*5.2*1034
SET DATANCNT=DATANCNT+1
+2 ;
+3 NEW DN,NUMDUPS
+4 ;
+5 KILL ARRAY
+6 ;
+7 SET (DN,NUMDUPS)=0
+8 FOR
SET DN=$ORDER(^DD(63.04,"B",DATADESC,DN))
IF DN<1
QUIT
Begin DoDot:1
+9 SET NUMDUPS=NUMDUPS+1
+10 SET ARRAY(DN)=""
+11 SET ARRAY(DN,"DT")=$GET(^DD(63.04,DN,"DT"))
End DoDot:1
+12 ;
+13 QUIT $SELECT(NUMDUPS<2:1,1:0)
+14 ;
SETBLRVS(TWO) ; EP - Use the STACK to find the Routine and set the BLRVRN variable(S)
+1 ; S CONTXT=$STACK(-1)-1
+2 ; S:CONTXT<1 CONTXT=1
+3 ; S PLACE=$STACK(CONTXT,"PLACE")
+4 ; S BLRVERN=$P($P(PLACE,"^",2)," ")
+5 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039 - Don't use $STACK
+6 KILL BLRVERN,BLRVERN2
+7 ;
+8 SET BLRVERN=$PIECE($PIECE($TEXT(+1),";")," ")
+9 ; ----- END IHS/MSC/MKK - LR*5.2*1039
+10 IF $LENGTH($GET(TWO))
SET BLRVERN2=TWO
+11 QUIT
+12 ;
+13 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039
ARRIVETM(LRDFN,LRSS,LRIDT) ; EP - Print Arrival Time on Interim Report -- called from LRRP1
+1 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRDFN,LRSS,LRIDT,U,XPARSYS,XQXFLG)
+2 ;
+3 ; Micro Interim Reports already has RECEIVED date.
IF LRSS="MI"
QUIT
+4 ;
+5 SET UID=$GET(^LR(LRDFN,LRSS,LRIDT,"ORU"))
+6 IF $LENGTH(UID)<1
QUIT
+7 ;
+8 SET LRC=$QUERY(^LRO(68,"C",UID))
+9 IF $QSUBSCRIPT(LRC,3)'=UID
QUIT
+10 SET LRAA=$QSUBSCRIPT(LRC,4)
SET LRAD=$QSUBSCRIPT(LRC,5)
SET LRAN=$QSUBSCRIPT(LRC,6)
+11 ; Arrival Time Internal (FileMan)
SET ARRIVTI=$$GET1^DIQ(68.02,LRAN_","_LRAD_","_LRAA,12,"I")
+12 IF ARRIVTI<1
QUIT
+13 ;
+14 IF LRSS'="MI"
Begin DoDot:1
+15 ; Arrival Time External
SET ARRIVTE="Lab Arrival Date/Time:"_$$FMTE^XLFDT(ARRIVTI,"2MZ")
+16 WRITE ?(IOM-$LENGTH(ARRIVTE)-1),ARRIVTE
End DoDot:1
+17 QUIT
+18 ;
+19 ;
+20 ; Send MAILMAN/ALERT to a specified MAIL GROUP
MAILALMI(MESSAGE,MSGARRAY,FROMWHOM,NOUSER,MAILGROUP) ; EP - Generic MAILER/ALERTER - allows any MailGroup
+1 NEW MAILARRY
+2 ;
+3 SET MAILGROUP="G."_$GET(MAILGROUP,"LMI")
+4 ;
+5 ; Send MESSAGE string as ALERT
+6 DO SNDALERT(MESSAGE,$GET(NOUSER),MAILGROUP)
+7 ;
+8 ; Setup variables for sending MailMan e-mail
+9 IF $LENGTH($GET(MSGARRAY(1)))
MERGE MAILARRY=MSGARRAY
+10 ;
+11 ; If MSGARRAY null, create generic array
IF $LENGTH($GET(MSGARRAY(1)))<1
Begin DoDot:1
+12 SET MAILARRY(1)="The Subject of this email is the message:"
+13 SET MAILARRY(2)=" "_MESSAGE
End DoDot:1
+14 ;
+15 IF $GET(FROMWHOM)=""
SET FROMWHOM="RPMS Lab Package"
+16 ;
+17 DO SENDMAIL(MESSAGE,.MAILARRY,FROMWHOM,$GET(NOUSER),MAILGROUP)
+18 ;
+19 QUIT
+20 ;
+21 ;
SNDALERT(ALERTMSG,NOUSER,MAILGROUP) ; EP - Send Alert
+1 SET XQAMSG=ALERTMSG
+2 SET XQA(MAILGROUP)=""
+3 ;
+4 ; If User NOT a member of the Mail Group, send them alert also, but
+5 ; If-And-Only-If the NOUSER variable is null.
+6 IF $GET(NOUSER)=""&($$NINMGRP(MAILGROUP,DUZ))
SET XQA(DUZ)=""
+7 ;
+8 SET X=$$SETUP1^XQALERT
+9 KILL XQA,XQAMSG
+10 IF X
QUIT
+11 ;
+12 ; If ALERT call failed, store information
+13 NEW SUBSCRPT
+14 SET SUBSCRPT="BLR Alert^"_+$HOROLOG_"^"_$JOB
+15 SET ^XTMP(SUBSCRPT,0)=$$FMADD^XLFDT($$DT^XLFDT,90)_"^"_$$DT^XLFDT_"^"_"Lab Package Alert."
+16 SET ^XTMP(SUBSCRPT,1)="Alert was not sent."
+17 SET ^XTMP(SUBSCRPT,2)=" Message that should have been sent follows:"
+18 SET ^XTMP(SUBSCRPT,3)=" "_ALERTMSG
+19 SET ^XTMP(SUBSCRPT,4)=" ALERT Error Message Follows:"
+20 SET ^XTMP(SUBSCRPT,5)=" "_XQALERR
+21 QUIT
+22 ;
+23 ;
+24 ; Send MailMan E-mail to MailGroup
SENDMAIL(MAILMSG,MAILARRY,FROMWHOM,NOUSER,MAILGROUP) ; EP
+1 NEW DIFROM
+2 ;
+3 KILL XMY
+4 SET XMY(MAILGROUP)=""
+5 ;
+6 ; If User not part of MailGroup, send them e-mail also, but
+7 ; If-And-Only-If the NOUSER variable is null.
+8 IF $GET(NOUSER)=""&($$NINMGRP(MAILGROUP,DUZ))
SET XMY(DUZ)=""
+9 ;
+10 SET LRBLNOW=$EXTRACT($$NOW^XLFDT,1,12)
+11 ;
+12 SET XMSUB=MAILMSG
+13 SET XMTEXT="MAILARRY("
+14 SET XMDUZ=FROMWHOM
+15 SET XMZ="NOT OKAY"
+16 DO ^XMD
+17 ;
+18 IF $GET(XMMG)'=""!(XMZ="NOT OKAY")
Begin DoDot:1
+19 NEW SUBSCRPT,ARRAY
+20 SET SUBSCRPT="MailMan Message Failure for Group "_MAILGROUP_"^"_$$HTFM^XLFDT($HOROLOG)_"^"_$JOB
+21 SET ^XTMP(SUBSCRPT,0)=$$FMADD^XLFDT($$DT^XLFDT,90)_"^"_$$DT^XLFDT_"^"_"Lab Package MailMan Message."
+22 SET ^XTMP(SUBSCRPT,1)="MailMan Message was not sent."
+23 SET ^XTMP(SUBSCRPT,2)=" Message that should have been sent follows:"
+24 SET ARRAY=0
+25 FOR
SET ARRAY=$ORDER(MAILARRY(ARRAY))
IF ARRAY<1
QUIT
Begin DoDot:2
+26 SET ^XTMP(SUBSCRPT,(ARRAY+2))=" "_$GET(MAILARRY(ARRAY))
End DoDot:2
End DoDot:1
+27 ;
+28 ; Cleanup
KILL X,XMDUZ,XMSUB,XMTEXT,XMY,XMZ,Y
+29 QUIT
+30 ;
NINMGRP(MAILGROUP,USERDUZ) ; EP - Is User NOT a member of the MailGroup?
+1 NEW MGIEN,XMDUZ,Y
+2 SET MGIEN=+$$FIND1^DIC(3.8,,,$PIECE(MAILGROUP,".",2))
+3 IF MGIEN<1
QUIT 0
+4 ;
+5 SET XMDUZ=USERDUZ
SET Y=MGIEN
+6 DO CHK^XMA21
+7 QUIT '$TEST
+8 ;
RJZF(NUM,LEN) ; EP - Right Justify, Zero Fill function
+1 ; If NUM variable not a number, return NULL
QUIT $SELECT((NUM'?.N):"",1:$TRANSLATE($JUSTIFY(NUM,LEN)," ","0"))
+2 ;
+3 ; The following is called from LR7OF1
+4 ; If Urgency is ASAP or STAT or Hospital Location["EMER", send
+5 ; Alert & E-Mail to LAB HIGH URGENCY NOTIFICATION Mail Group
IHSURGNT ; EP
+1 ; Skip if XPAR is 'OFF'
IF +$$GET^XPAR("PKG","BLR EMERGENCY ALERT",1,"Q")<1
QUIT
+2 ; Skip if file 100 IEN < 1
IF +$GET(ORIFN)<1
QUIT
+3 ;
+4 NEW HOSPDIV,LABORD,MESSAGE,MSGARRAY,URGSTR
+5 ;
+6 SET HOSPDIV=$$UP^XLFSTR($$GET1^DIQ(100,ORIFN,"PATIENT LOCATION"))
+7 SET URGSTR=$$UP^XLFSTR($$GET1^DIQ(62.05,+$$VALUE^ORCSAVE2(ORIFN,"URGENCY"),.01))
+8 ;
+9 ; Skip if not URGENT and not ASAP and not from Emergency room
+10 IF URGSTR'["STAT"&(URGSTR'["ASAP")&(HOSPDIV'["EMER")
QUIT
+11 ;
+12 SET LABORD=+$$GET1^DIQ(69.01,+$GET(LRSN)_","_+$GET(LRODT),9.5)
+13 IF LABORD<1
SET LABORD=+$$GET1^DIQ(100,ORIFN,"PACKAGE REFERENCE")
+14 ;
+15 SET MESSAGE="**URGENT** Lab Order:"_LABORD_" Location:"_HOSPDIV_" HRCN:"_$GET(HRCN)
+16 ;
+17 SET MSGARRAY(1)="Lab Order #:"_LABORD_" OERR #:"_ORIFN_" detail:"
+18 SET MSGARRAY(2)=" "
+19 SET MSGARRAY(3)=$JUSTIFY("",5)_"Patient Name:"_$GET(LRPNM)_" HRCN:"_$GET(HRCN)
+20 SET MSGARRAY(4)=" "
+21 SET MSGARRAY(5)=$JUSTIFY("",10)_"TEST:"_$PIECE($GET(MSG(5)),U,5)
+22 ;
+23 DO MAILALMI^BLRUTIL8(MESSAGE,.MSGARRAY,,1,"LAB HIGH URGENCY NOTIFICATION")
+24 QUIT
+25 ;
+26 ;
LABGLOBR ; EP - Given Accession number/UID, list Data from Files 68, 69 & 63.
+1 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
+2 ;
+3 IF $$DETAILIN("DETAIL")="Q"
QUIT
+4 ;
+5 DO LRASDATA(LRAA,LRAD,LRAN,9)
+6 ;
+7 DO ORDRDATA
+8 ;
+9 DO LABDATA
+10 ;
+11 DO PRESSKEY^BLRGMENU(4)
+12 QUIT
+13 ;
DETAILIN(SUBRTN) ; EP - Initialize variables
+1 NEW COL,COL2
+2 ;
+3 DO ^XBCLS
+4 DO ^LRWU4
+5 WRITE !!
+6 ;
+7 IF $DATA(^LRO(68,LRAA,1,LRAD,1,LRAN,0))<1
QUIT $$BADSTUFF^BLRUTIL7("Accession does not Exist.")
+8 ;
+9 SET LRSS=$$GET1^DIQ(68,LRAA,.02,"I")
+10 SET LRAAIEN=LRAN_","_LRAD_","_LRAA
+11 SET ORDERNUM=$$GET1^DIQ(68.02,LRAAIEN,14,"I")
+12 SET LRAS=$$GET1^DIQ(68.02,LRAAIEN,15)
+13 SET UID=$$GET1^DIQ(68.02,LRAAIEN,16)
+14 ;
+15 QUIT "OK"
+16 ;
+17 ;
LRASDATA(LRAA,LRAD,LRAN,LM,RM) ; EP - Display File 68 Data
+1 NEW (DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,LRAA,LRAD,LRAN,NOPRESS,LM,RM,U,XPARSYS,XQXFLG)
+2 ;
+3 DO ^XBCLS
+4 ;
+5 WRITE !
+6 DO LINEMSG("Accession (#68) file data","=",5)
+7 ;
+8 SET NOMORE="^LRO(68,"_LRAA_",1,"_LRAD_",1,"_LRAN
+9 SET NOMOREL=$LENGTH(NOMORE)
+10 SET LETSGO=NOMORE_")"
+11 ;
+12 ; Left Margin
SET LM=$GET(LM,4)
+13 ; Right Margin
SET RM=$GET(RM,(IOM-5))
+14 ;
+15 SET STR1=$QUERY(@LETSGO@(""))
+16 WRITE ?LM,STR1,"="
SET TAB=$X
DO LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB))
WRITE !
+17 FOR
SET STR1=$QUERY(@STR1)
IF STR1=""!($EXTRACT(STR1,1,NOMOREL)'=NOMORE)
QUIT
Begin DoDot:1
+18 WRITE ?(LM+5),STR1,"="
SET TAB=$X
+19 DO LINEWRAP^BLRGMENU(TAB,@STR1,(RM-TAB))
WRITE !
End DoDot:1
+20 ;
+21 QUIT
+22 ;
+23 ;
ORDRDATA ; EP - Display data from the ORDER file
+1 NEW ORDERDT,LRSN
+2 ;
+3 WRITE !
+4 DO LINEMSG("Lab Order Entry (#69) file Data","=",5)
+5 ;
+6 IF +ORDERNUM<1
WRITE ?7,"No Order File Data",!