ORB3UTL ;SLC/JMH - OE/RR Notification Utilities ;Oct 27, 2023@11:55
;;3.0;ORDER ENTRY/RESULTS REPORTING;**377,539,535**;Dec 17, 1997;Build 20
;
; Reference to DEFALERT^XQALDATA,GETPAT3^XQALDATA in ICR #4834
; Reference to ^TIU(8925) in ICR #2937
; Reference to ^GMR(123) in ICR #2586
; Reference to ^SRF() in ICR #7436
; Reference to $$CANDO^TIULP in #2322
; Reference to ^TIU(8925.1) in #4476
; Reference to $$BOIL^TIUSRVD in #2876
; Reference to ^DPT( in ICR #10035
; Reference to ^DIE in ICR #10018
; Reference to FILE^DIE,UPDATE^DIE,WP^DIE in ICR #2053
; Reference to $$GET1^DIQ in ICR #2056
; Reference to $$NOW^XLFDT in ICR #10103
; Reference to ALERTDAT^XQALBUTL in ICR #2788
; Reference to DEFALERT^XQALDATA,GETPAT3^XQALDATA in ICR #4834
;
GENALRTS ;fire off due alerts
;get unfired records
N ORI S ORI=0
F S ORI=$O(^OR(100.97,"C",0,ORI)) Q:'ORI D
.N ORWHEN S ORWHEN=$P($G(^OR(100.97,ORI,0)),U,3)
.I ORWHEN<$$NOW^XLFDT() D GENALRT(ORI) W !,ORI
Q
;
GENALRT(ORID) ;fire a specific scheduled alert
N ORDUZ,ORMSG
S ORDUZ($P($G(^OR(100.97,ORID,0)),U,4))=$P($G(^OR(100.97,ORID,0)),U,4)
S ORMSG=$G(^OR(100.97,ORID,2))
N ORI S ORI=0 F S ORI=$O(^OR(100.97,ORID,3,ORI)) Q:'ORI S ORMSG(ORI)=$G(^OR(100.97,ORID,3,ORI,0))
N ORDFN S ORDFN=+$G(^OR(100.97,ORID,0))
D EN^ORB3(90,ORDFN,"",.ORDUZ,.ORMSG,"")
N ORXQAID S ORXQAID="OR,"_ORDFN_",90;"_$P($G(^OR(100.97,ORID,0)),U,4)_";"_$$NOW^XLFDT()
K ORFDART,ORMSGRT
S ORFDART(100.97,ORID_",",4)=ORXQAID
S ORFDART(100.97,ORID_",",7)=$$NOW^XLFDT()
D FILE^DIE("","ORFDART","ORMSGRT")
Q ORXQAID
;
SCHALRT(ORDATA) ;Schedule a long text alert
;ORDATA fields
; PATIENT - File 2 IEN - for the patient this alert is for
; WHEN - date/time of when this alert will be generated
; WHO - File 200 IEN of who will receive this alert
; TITLE - Free Text title of alert
; BODY(D0) - Word Processing body of the alert for long text
N DIC,DIE,DR,DA,ORFDART,ORIENRT,ORMSGRT
S ORFDART(100.97,"+1,",.01)=ORDATA("PATIENT")
D UPDATE^DIE("","ORFDART","ORIENRT","ORMSGRT")
I $D(ORIENRT(1)) S DA=ORIENRT(1)
S DIC="^OR(100.97,",DIC(0)="F",DIE=DIC
S DR="1////"_$$NOW^XLFDT()_";2////"_ORDATA("WHEN")_";3////"_ORDATA("WHO")_";5////"_ORDATA("TITLE")_";4////0"_";8////"_$G(ORDATA("IFN"))
D ^DIE
D WP^DIE(100.97,DA_",",6,,"ORDATA(""BODY"")","ERROR")
Q
;
DEFER(ORY,ORPROV,ORALERT,ORDT) ;defer an alert
;ORALERT - alert to defer
;ORPROV - provider to defer the alert for
;ORDT - date/time to defer the alert until
N ORROOT
S ORY=1
;CALL KERNEL API FOR DEFERRAL
D DEFALERT^XQALDATA("ORROOT",ORPROV,ORDT,ORALERT)
N ORRES S ORRES=$G(ORROOT(1),1)
I $P(ORRES,U)<0 S ORY=ORRES
Q
NOTIFPG(ORY,ORPAT,ORFROM,ORTO) ;page through a patients alerts
;ORPAT - patient DFN
;ORPG - page to get
;ORPGSZ - page size (defaults to 25)
N URGLIST,REMLIST,NONORLST,ORY2,I,ORTOTU,ORTOT
N ALRT,ALRTDFN,ALRTDT,ALRTI,ALRTLOC,ALRTMSG,ALRTPT,ALRTXQA,FWDBY,J,NONOR,ORHAS,ORN,ORN0,ORURG,PRE,REM,URG
D INDNOT(.ORY2)
K ORY
K ^TMP("ORB2",$J),^TMP("ORBG",$J)
D GETPAT3^XQALDATA("^TMP(""ORB2"",$J)",ORPAT,ORFROM,ORTO)
D URGLIST^ORQORB(.URGLIST)
D REMLIST^ORQORB(.REMLIST)
D REMNONOR^ORQORB(.NONORLST)
S (I,J)=0
F S I=$O(^TMP("ORB2",$J,I)) Q:'I D
.N ORPROV,ORALRTDAT ; ajb
.S ALRTDFN=""
.S ALRT=^TMP("ORB2",$J,I)
.S PRE=$E(ALRT,1,1)
.S ALRTXQA=$P(ALRT,U,2) ;XQAID
.D ALERTDAT^XQALBUTL(ALRTXQA,"ORALRTDAT")
.S NONOR="" F S NONOR=$O(NONORLST(NONOR)) Q:NONOR="" D
..I ALRTXQA[NONOR S REM=1 ;allow this type of alert to be Removed
.S ALRTMSG=$P($P(ALRT,U),PRE_" ",2)
.I $E(ALRT,4,8)'="-----" D ;not forwarded alert info/comment
..S ORURG="n/a"
..S ALRTI=$P(ALRT," ")
..S ALRTPT=""
..S ALRTLOC=""
..I $E($P(ALRTXQA,";"),1,3)="TIU" D
... N ORIEN,ORREF,ORTIU
... S ORPROV="N/A"
... S ORURG="Moderate"
... S ORTIU=+$G(ORALRTDAT(2)) D Q:'ORTIU
.... N ORTIUTXT,ORTIUTXT6
.... I ORTIU Q
.... S ORTIUTXT=$P(ALRTXQA,";"),ORTIUTXT6=$E(ORTIUTXT,1,6)
.... I "^TIUADD^TIUERR^"[ORTIUTXT6 S ORTIU=$E(ORTIUTXT,7,999) Q
.... I ORTIUTXT?3A1.99999999N S ORTIU=$E(ORTIUTXT,4,999)
... S ORIEN=+$P($G(^TIU(8925,ORTIU,12)),U,10) I 'ORIEN D
.... S ORREF=$P($G(^TIU(8925,ORTIU,14)),U,5) Q:ORREF=""
.... I $P(ORREF,";",2)="GMR(123," S ORIEN=$P($G(^GMR(123,+ORREF,0)),U,3) I ORIEN="" S ORPROV="UNKNOWN"
.... I $P(ORREF,";",2)="SRF(" S ORIEN=$P($G(^SRF(+ORREF,0)),U,14) I ORIEN="" S ORPROV="UNKNOWN"
... I +ORIEN>0 S ORPROV=$$GETPRVNM^ORWORB(ORIEN)
..I $P(ALRTXQA,",")="OR" D
...N NOPROV
...S NOPROV=0
...S ORN=$P($P(ALRTXQA,";"),",",3)
...S URG=$G(URGLIST(ORN))
...S ORURG=$S(URG=1:"HIGH",URG=2:"Moderate",1:"low")
...S REM=$G(REMLIST(ORN))
...S ORN0=$G(^ORD(100.9,+ORN,0))
...S ALRTI=$S(ORN=90:"L",$P(ORN0,U,6)="INFODEL":"I",1:"")
...S ALRTDFN=$P(ALRTXQA,",",2)
...S ALRTLOC=$G(^DPT(+$G(ALRTDFN),.1))
...I $G(ORN)=6,$P(ALRT,U)["Your task #" S ALRTMSG=$E($P(ALRT,U),2,999),NOPROV=1,ORPROV="N/A"
...; ajb
... I 'NOPROV S ORPROV=$$GETPROV^ORWORB(ORN,ALRTDFN,.ORALRTDAT)
...; ajb
..S ALRTI=$S(ALRTI="I":"I",ALRTI="L":"L",1:"")
..I (ALRT["): ")!($G(ORN)=27&(ALRT[") CV")) D ;WAT
...S ALRTPT=$P(ALRT,": ")
...N ORTRM S ORTRM=$S($E(ALRTPT,1,2)="G ":3,$E(ALRTPT,1,2)="I ":3,1:2)
...S ALRTPT=$E(ALRTPT,ORTRM,$L(ALRTPT))
...I $G(ORN)=27&(ALRT[") CV") S ALRTMSG=$P($P(ALRT,U),": ",2) ;WAT
...E S ALRTMSG=$P($P(ALRT,U),"): ",2) ;WAT
...I $E(ALRTMSG,1,1)="[" D
....S:'$L(ALRTLOC) ALRTLOC=$P($P(ALRTMSG,"]"),"[",2)
....S ALRTMSG=$P(ALRTMSG,"] ",2)
..I '$L($G(ALRTPT)) S ALRTPT="no patient"
..S ALRTDT=$P(ALRTXQA,";",3)
..S ALRTDT=$P(ALRTDT,".")_"."_$E($P(ALRTDT,".",2)_"0000",1,4)
..S ALRTDT=$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"/"_($E(ALRTDT,1,3)+1700)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
..;S ALRTDT=($E(ALRTDT,1,3)+1700)_"/"_$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
..S J=J+1,^TMP("ORBG",$J,J)=ALRTI_U_ALRTPT_U_ALRTLOC_U_ORURG_U_ALRTDT_U
..S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_ALRTMSG_U_U_ALRTXQA_U_$G(REM)_U
.;
.;if alert forward info/comment:
.I $E(ALRTMSG,1,5)="-----" D
..S ALRTMSG=$P(ALRTMSG,"-----",2)
..I $E(ALRTMSG,1,14)=FWDBY D
...S J=J+1,^TMP("ORBG",$J,J)=FWDBY_U_$P($P(ALRTMSG,FWDBY,2),"Generated: ")_$P($P(ALRTMSG,FWDBY,2),"Generated: ",2)
..E S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_U_""""_ALRTMSG_""""
.S ORHAS=$S($D(ORY2(ALRTXQA)):1,1:0)
.S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_U_ORHAS
.I $G(ORPROV)'="" S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_U_ORPROV ; ajb
;S ^TMP("ORBG",$J)=""
S ^TMP("ORBG",$J,0)=^TMP("ORB2",$J,0)
S ORY=$NA(^TMP("ORBG",$J))
Q
;
INDNOT(ORY) ;index the user's alerts by the xqaldata, include deferred alerts
N ORY2 D FASTUSER^ORWORB(.ORY2,0)
N ORI S ORI=0 F S ORI=$O(@ORY2@(ORI)) Q:'ORI D
. I $L($P(@ORY2@(ORI),U,8))>0 S ORY($P(@ORY2@(ORI),U,8))=@ORY2@(ORI)
Q
;
GETNOTIF(RETURN,ALERT) ; Return a notification structure to the SMART Dialog System
Set RETURN=$NA(^TMP($J)) Kill @RETURN
New ORTMP,X,IEN,IENS,DFN
Set DFN=+$Piece(ALERT,",",2)
Set IEN=+$Piece(ALERT,",",3),IENS=IEN_","
Set @RETURN@(0)="PROCESS AS SMART NOTIFICATION="_+$$GET1^DIQ(100.9,IENS,6.1,"I")
Quit:'$Piece(@RETURN@(0),"=",2) ; Flag not set for SMART processing
Set @RETURN@(1)="NOTE TITLE="_$$GET1^DIQ(100.9,IENS,6.2,"E")
Set @RETURN@(2)="NOTE TITLE IEN="_+$$GET1^DIQ(100.9,IENS,6.2,"I")
Set @RETURN@(3)="NOTIFICATION IEN="_IEN
Set @RETURN@(4)="NOTIFICATION NAME="_$$GET1^DIQ(100.9,IENS,.01,"E")
Set @RETURN@(5)="ALLOW ADDENDUM="_+$$GET1^DIQ(100.9,IENS,6.3,"I")
Set @RETURN@(6)="TIU OBJECT="_+$$GET1^DIQ(100.9,IENS,6.4,"I")
Set @RETURN@(7)="DFN="_DFN
Set @RETURN@(8)="ALERT="_ALERT
Set @RETURN@(9)="PATIENT NAME="_$P($G(^DPT(DFN,0)),U)
Quit
;
GETNOTES(RETURN,DOC,DFN) ; Returns existing notes that can be addended
Set RETURN=$NA(^TMP($J)) Kill @RETURN
New ROOT,STAT,IEN,LOOP
For STAT=7,8 Do
. Set LOOP=$Name(^TIU(8925,"APT",DFN,DOC,STAT))
. Set ROOT=$Extract(LOOP,1,$Length(LOOP)-1)_","
. For Set LOOP=$Query(@LOOP) Quit:$Piece(LOOP,ROOT)'="" Do
. . S IEN=$QSubscript(LOOP,$QLength(LOOP))
. . ; Validate MAKE ADDENDUM
. . Q:'$$CANDO^TIULP(IEN,"MAKE ADDENDUM")
. . Set @RETURN@(0)=$Get(@RETURN@(0))+1
. . Set @RETURN@(@RETURN@(0))=IEN_U_$$GET1^DIQ(8925,IEN,.01)_U_$$GET1^DIQ(8925,IEN,1301)_U_$$GET1^DIQ(8925,IEN,1211)
S @RETURN@(0)="COUNT="_$G(@RETURN@(0))
Quit
;
GETDESC(RETURN,ALERT) ; Returns notification description
S RETURN=$NA(^TMP($J)) K @RETURN
N ORNOTID S ORNOTID=$P($P(ALERT,";"),",",3)
I 'ORNOTID D Q
.S @RETURN@(0)="UNABLE TO DETERMINE ALERT"
N ORTIUOBJ S ORTIUOBJ=$P($G(^ORD(100.9,ORNOTID,6)),U,4)
I 'ORTIUOBJ D Q
.S @RETURN@(0)="NO DATA OBJECT SETUP"
S ORTIUOBJ=$P($G(^TIU(8925.1,ORTIUOBJ,0)),U,1)
I '$L(ORTIUOBJ) D Q
.S @RETURN@(0)="NO DATA OBJECT SETUP"
N DFN S DFN=$P($P(ALERT,";"),",",2)
I 'DFN D Q
.S @RETURN@(0)="UNABLE TO DETERMINE PATIENT"
; Value from the TIU OBJECT specified in file 100.9, field 6.4
N ORBOIL S ORBOIL=$$BOIL^TIUSRVD("|"_ORTIUOBJ_"|")
I $E(ORBOIL,0,2)="~@" D
.N ORGLOB S ORGLOB=$P(ORBOIL,"~@",2)
.I $D(@ORGLOB) D
..N ORGLOBI S ORGLOBI=0 F S ORGLOBI=$O(@ORGLOB@(ORGLOBI)) Q:'ORGLOBI D
...S @RETURN@(ORGLOBI-1)=@ORGLOB@(ORGLOBI,0)
E S @RETURN@(0)=ORBOIL
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORB3UTL 9368 printed Dec 13, 2024@02:27:35 Page 2
ORB3UTL ;SLC/JMH - OE/RR Notification Utilities ;Oct 27, 2023@11:55
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**377,539,535**;Dec 17, 1997;Build 20
+2 ;
+3 ; Reference to DEFALERT^XQALDATA,GETPAT3^XQALDATA in ICR #4834
+4 ; Reference to ^TIU(8925) in ICR #2937
+5 ; Reference to ^GMR(123) in ICR #2586
+6 ; Reference to ^SRF() in ICR #7436
+7 ; Reference to $$CANDO^TIULP in #2322
+8 ; Reference to ^TIU(8925.1) in #4476
+9 ; Reference to $$BOIL^TIUSRVD in #2876
+10 ; Reference to ^DPT( in ICR #10035
+11 ; Reference to ^DIE in ICR #10018
+12 ; Reference to FILE^DIE,UPDATE^DIE,WP^DIE in ICR #2053
+13 ; Reference to $$GET1^DIQ in ICR #2056
+14 ; Reference to $$NOW^XLFDT in ICR #10103
+15 ; Reference to ALERTDAT^XQALBUTL in ICR #2788
+16 ; Reference to DEFALERT^XQALDATA,GETPAT3^XQALDATA in ICR #4834
+17 ;
GENALRTS ;fire off due alerts
+1 ;get unfired records
+2 NEW ORI
SET ORI=0
+3 FOR
SET ORI=$ORDER(^OR(100.97,"C",0,ORI))
if 'ORI
QUIT
Begin DoDot:1
+4 NEW ORWHEN
SET ORWHEN=$PIECE($GET(^OR(100.97,ORI,0)),U,3)
+5 IF ORWHEN<$$NOW^XLFDT()
DO GENALRT(ORI)
WRITE !,ORI
End DoDot:1
+6 QUIT
+7 ;
GENALRT(ORID) ;fire a specific scheduled alert
+1 NEW ORDUZ,ORMSG
+2 SET ORDUZ($PIECE($GET(^OR(100.97,ORID,0)),U,4))=$PIECE($GET(^OR(100.97,ORID,0)),U,4)
+3 SET ORMSG=$GET(^OR(100.97,ORID,2))
+4 NEW ORI
SET ORI=0
FOR
SET ORI=$ORDER(^OR(100.97,ORID,3,ORI))
if 'ORI
QUIT
SET ORMSG(ORI)=$GET(^OR(100.97,ORID,3,ORI,0))
+5 NEW ORDFN
SET ORDFN=+$GET(^OR(100.97,ORID,0))
+6 DO EN^ORB3(90,ORDFN,"",.ORDUZ,.ORMSG,"")
+7 NEW ORXQAID
SET ORXQAID="OR,"_ORDFN_",90;"_$PIECE($GET(^OR(100.97,ORID,0)),U,4)_";"_$$NOW^XLFDT()
+8 KILL ORFDART,ORMSGRT
+9 SET ORFDART(100.97,ORID_",",4)=ORXQAID
+10 SET ORFDART(100.97,ORID_",",7)=$$NOW^XLFDT()
+11 DO FILE^DIE("","ORFDART","ORMSGRT")
+12 QUIT ORXQAID
+13 ;
SCHALRT(ORDATA) ;Schedule a long text alert
+1 ;ORDATA fields
+2 ; PATIENT - File 2 IEN - for the patient this alert is for
+3 ; WHEN - date/time of when this alert will be generated
+4 ; WHO - File 200 IEN of who will receive this alert
+5 ; TITLE - Free Text title of alert
+6 ; BODY(D0) - Word Processing body of the alert for long text
+7 NEW DIC,DIE,DR,DA,ORFDART,ORIENRT,ORMSGRT
+8 SET ORFDART(100.97,"+1,",.01)=ORDATA("PATIENT")
+9 DO UPDATE^DIE("","ORFDART","ORIENRT","ORMSGRT")
+10 IF $DATA(ORIENRT(1))
SET DA=ORIENRT(1)
+11 SET DIC="^OR(100.97,"
SET DIC(0)="F"
SET DIE=DIC
+12 SET DR="1////"_$$NOW^XLFDT()_";2////"_ORDATA("WHEN")_";3////"_ORDATA("WHO")_";5////"_ORDATA("TITLE")_";4////0"_";8////"_$GET(ORDATA("IFN"))
+13 DO ^DIE
+14 DO WP^DIE(100.97,DA_",",6,,"ORDATA(""BODY"")","ERROR")
+15 QUIT
+16 ;
DEFER(ORY,ORPROV,ORALERT,ORDT) ;defer an alert
+1 ;ORALERT - alert to defer
+2 ;ORPROV - provider to defer the alert for
+3 ;ORDT - date/time to defer the alert until
+4 NEW ORROOT
+5 SET ORY=1
+6 ;CALL KERNEL API FOR DEFERRAL
+7 DO DEFALERT^XQALDATA("ORROOT",ORPROV,ORDT,ORALERT)
+8 NEW ORRES
SET ORRES=$GET(ORROOT(1),1)
+9 IF $PIECE(ORRES,U)<0
SET ORY=ORRES
+10 QUIT
NOTIFPG(ORY,ORPAT,ORFROM,ORTO) ;page through a patients alerts
+1 ;ORPAT - patient DFN
+2 ;ORPG - page to get
+3 ;ORPGSZ - page size (defaults to 25)
+4 NEW URGLIST,REMLIST,NONORLST,ORY2,I,ORTOTU,ORTOT
+5 NEW ALRT,ALRTDFN,ALRTDT,ALRTI,ALRTLOC,ALRTMSG,ALRTPT,ALRTXQA,FWDBY,J,NONOR,ORHAS,ORN,ORN0,ORURG,PRE,REM,URG
+6 DO INDNOT(.ORY2)
+7 KILL ORY
+8 KILL ^TMP("ORB2",$JOB),^TMP("ORBG",$JOB)
+9 DO GETPAT3^XQALDATA("^TMP(""ORB2"",$J)",ORPAT,ORFROM,ORTO)
+10 DO URGLIST^ORQORB(.URGLIST)
+11 DO REMLIST^ORQORB(.REMLIST)
+12 DO REMNONOR^ORQORB(.NONORLST)
+13 SET (I,J)=0
+14 FOR
SET I=$ORDER(^TMP("ORB2",$JOB,I))
if 'I
QUIT
Begin DoDot:1
+15 ; ajb
NEW ORPROV,ORALRTDAT
+16 SET ALRTDFN=""
+17 SET ALRT=^TMP("ORB2",$JOB,I)
+18 SET PRE=$EXTRACT(ALRT,1,1)
+19 ;XQAID
SET ALRTXQA=$PIECE(ALRT,U,2)
+20 DO ALERTDAT^XQALBUTL(ALRTXQA,"ORALRTDAT")
+21 SET NONOR=""
FOR
SET NONOR=$ORDER(NONORLST(NONOR))
if NONOR=""
QUIT
Begin DoDot:2
+22 ;allow this type of alert to be Removed
IF ALRTXQA[NONOR
SET REM=1
End DoDot:2
+23 SET ALRTMSG=$PIECE($PIECE(ALRT,U),PRE_" ",2)
+24 ;not forwarded alert info/comment
IF $EXTRACT(ALRT,4,8)'="-----"
Begin DoDot:2
+25 SET ORURG="n/a"
+26 SET ALRTI=$PIECE(ALRT," ")
+27 SET ALRTPT=""
+28 SET ALRTLOC=""
+29 IF $EXTRACT($PIECE(ALRTXQA,";"),1,3)="TIU"
Begin DoDot:3
+30 NEW ORIEN,ORREF,ORTIU
+31 SET ORPROV="N/A"
+32 SET ORURG="Moderate"
+33 SET ORTIU=+$GET(ORALRTDAT(2))
Begin DoDot:4
+34 NEW ORTIUTXT,ORTIUTXT6
+35 IF ORTIU
QUIT
+36 SET ORTIUTXT=$PIECE(ALRTXQA,";")
SET ORTIUTXT6=$EXTRACT(ORTIUTXT,1,6)
+37 IF "^TIUADD^TIUERR^"[ORTIUTXT6
SET ORTIU=$EXTRACT(ORTIUTXT,7,999)
QUIT
+38 IF ORTIUTXT?3A1.99999999N
SET ORTIU=$EXTRACT(ORTIUTXT,4,999)
End DoDot:4
if 'ORTIU
QUIT
+39 SET ORIEN=+$PIECE($GET(^TIU(8925,ORTIU,12)),U,10)
IF 'ORIEN
Begin DoDot:4
+40 SET ORREF=$PIECE($GET(^TIU(8925,ORTIU,14)),U,5)
if ORREF=""
QUIT
+41 IF $PIECE(ORREF,";",2)="GMR(123,"
SET ORIEN=$PIECE($GET(^GMR(123,+ORREF,0)),U,3)
IF ORIEN=""
SET ORPROV="UNKNOWN"
+42 IF $PIECE(ORREF,";",2)="SRF("
SET ORIEN=$PIECE($GET(^SRF(+ORREF,0)),U,14)
IF ORIEN=""
SET ORPROV="UNKNOWN"
End DoDot:4
+43 IF +ORIEN>0
SET ORPROV=$$GETPRVNM^ORWORB(ORIEN)
End DoDot:3
+44 IF $PIECE(ALRTXQA,",")="OR"
Begin DoDot:3
+45 NEW NOPROV
+46 SET NOPROV=0
+47 SET ORN=$PIECE($PIECE(ALRTXQA,";"),",",3)
+48 SET URG=$GET(URGLIST(ORN))
+49 SET ORURG=$SELECT(URG=1:"HIGH",URG=2:"Moderate",1:"low")
+50 SET REM=$GET(REMLIST(ORN))
+51 SET ORN0=$GET(^ORD(100.9,+ORN,0))
+52 SET ALRTI=$SELECT(ORN=90:"L",$PIECE(ORN0,U,6)="INFODEL":"I",1:"")
+53 SET ALRTDFN=$PIECE(ALRTXQA,",",2)
+54 SET ALRTLOC=$GET(^DPT(+$GET(ALRTDFN),.1))
+55 IF $GET(ORN)=6
IF $PIECE(ALRT,U)["Your task #"
SET ALRTMSG=$EXTRACT($PIECE(ALRT,U),2,999)
SET NOPROV=1
SET ORPROV="N/A"
+56 ; ajb
+57 IF 'NOPROV
SET ORPROV=$$GETPROV^ORWORB(ORN,ALRTDFN,.ORALRTDAT)
+58 ; ajb
End DoDot:3
+59 SET ALRTI=$SELECT(ALRTI="I":"I",ALRTI="L":"L",1:"")
+60 ;WAT
IF (ALRT["): ")!($GET(ORN)=27&(ALRT[") CV"))
Begin DoDot:3
+61 SET ALRTPT=$PIECE(ALRT,": ")
+62 NEW ORTRM
SET ORTRM=$SELECT($EXTRACT(ALRTPT,1,2)="G ":3,$EXTRACT(ALRTPT,1,2)="I ":3,1:2)
+63 SET ALRTPT=$EXTRACT(ALRTPT,ORTRM,$LENGTH(ALRTPT))
+64 ;WAT
IF $GET(ORN)=27&(ALRT[") CV")
SET ALRTMSG=$PIECE($PIECE(ALRT,U),": ",2)
+65 ;WAT
IF '$TEST
SET ALRTMSG=$PIECE($PIECE(ALRT,U),"): ",2)
+66 IF $EXTRACT(ALRTMSG,1,1)="["
Begin DoDot:4
+67 if '$LENGTH(ALRTLOC)
SET ALRTLOC=$PIECE($PIECE(ALRTMSG,"]"),"[",2)
+68 SET ALRTMSG=$PIECE(ALRTMSG,"] ",2)
End DoDot:4
End DoDot:3
+69 IF '$LENGTH($GET(ALRTPT))
SET ALRTPT="no patient"
+70 SET ALRTDT=$PIECE(ALRTXQA,";",3)
+71 SET ALRTDT=$PIECE(ALRTDT,".")_"."_$EXTRACT($PIECE(ALRTDT,".",2)_"0000",1,4)
+72 SET ALRTDT=$EXTRACT(ALRTDT,4,5)_"/"_$EXTRACT(ALRTDT,6,7)_"/"_($EXTRACT(ALRTDT,1,3)+1700)_"@"_$EXTRACT($PIECE(ALRTDT,".",2),1,2)_":"_$EXTRACT($PIECE(ALRTDT,".",2),3,4)
+73 ;S ALRTDT=($E(ALRTDT,1,3)+1700)_"/"_$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
+74 SET J=J+1
SET ^TMP("ORBG",$JOB,J)=ALRTI_U_ALRTPT_U_ALRTLOC_U_ORURG_U_ALRTDT_U
+75 SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_ALRTMSG_U_U_ALRTXQA_U_$GET(REM)_U
End DoDot:2
+76 ;
+77 ;if alert forward info/comment:
+78 IF $EXTRACT(ALRTMSG,1,5)="-----"
Begin DoDot:2
+79 SET ALRTMSG=$PIECE(ALRTMSG,"-----",2)
+80 IF $EXTRACT(ALRTMSG,1,14)=FWDBY
Begin DoDot:3
+81 SET J=J+1
SET ^TMP("ORBG",$JOB,J)=FWDBY_U_$PIECE($PIECE(ALRTMSG,FWDBY,2),"Generated: ")_$PIECE($PIECE(ALRTMSG,FWDBY,2),"Generated: ",2)
End DoDot:3
+82 IF '$TEST
SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_U_""""_ALRTMSG_""""
End DoDot:2
+83 SET ORHAS=$SELECT($DATA(ORY2(ALRTXQA)):1,1:0)
+84 SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_U_ORHAS
+85 ; ajb
IF $GET(ORPROV)'=""
SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_U_ORPROV
End DoDot:1
+86 ;S ^TMP("ORBG",$J)=""
+87 SET ^TMP("ORBG",$JOB,0)=^TMP("ORB2",$JOB,0)
+88 SET ORY=$NAME(^TMP("ORBG",$JOB))
+89 QUIT
+90 ;
INDNOT(ORY) ;index the user's alerts by the xqaldata, include deferred alerts
+1 NEW ORY2
DO FASTUSER^ORWORB(.ORY2,0)
+2 NEW ORI
SET ORI=0
FOR
SET ORI=$ORDER(@ORY2@(ORI))
if 'ORI
QUIT
Begin DoDot:1
+3 IF $LENGTH($PIECE(@ORY2@(ORI),U,8))>0
SET ORY($PIECE(@ORY2@(ORI),U,8))=@ORY2@(ORI)
End DoDot:1
+4 QUIT
+5 ;
GETNOTIF(RETURN,ALERT) ; Return a notification structure to the SMART Dialog System
+1 SET RETURN=$NAME(^TMP($JOB))
KILL @RETURN
+2 NEW ORTMP,X,IEN,IENS,DFN
+3
*** ERROR ***
SET DFN=+$Piece(ALERT,",",2)
+4
*** ERROR ***
SET IEN=+$Piece(ALERT,",",3)
SET IENS=IEN_","
+5 SET @RETURN@(0)="PROCESS AS SMART NOTIFICATION="_+$$GET1^DIQ(100.9,IENS,6.1,"I")
+6 ; Flag not set for SMART processing