PXRMNTFY ;SLC/PKR - Routines for notifications. ;07/25/2012
;;2.0;CLINICAL REMINDERS;**24**;Feb 04, 2005;Build 193
;
;========================
DELOPEN(DFN,ORN) ;Delete open OE/RR Notifications.
N ALIST,IND,ORID,XQAID
;DBIA #10081
D PATIENT^XQALERT("ALIST",DFN)
F IND=1:1:ALIST D
. S XQAID=$P(ALIST(IND),U,2)
. S ORID=$P(XQAID,";",1)
. I $P(ORID,",",3)=ORN D DELETE^XQALERT
Q
;
;========================
SUICIDE(EVENT,DFN,VISIT) ;Send an alert if the patient attempted or
;completed suicide, as marked by a health factor. This is called
;from DATACHGR^PXRMPINF which is invoked by the protocol PXK VISIT
;DATA EVENT.
N DATE,HAFIEN,HFBIEN,HFSAIEN,HFSCIEN,MSG,VHFIEN
S HFSAIEN=$$FIND1^DIC(9999999.64,"","","MH SUICIDE ATTEMPTED")
S HFSCIEN=$$FIND1^DIC(9999999.64,"","","MH SUICIDE COMPLETED")
S (MSG,VHFIEN)=""
F S VHFIEN=$O(^XTMP(EVENT,VISIT,"HF",VHFIEN)) Q:VHFIEN="" D
. S HFAIEN=$P($G(^XTMP(EVENT,VISIT,"HF",VHFIEN,0,"AFTER")),U,1)
. S HFBIEN=$P($G(^XTMP(EVENT,VISIT,"HF",VHFIEN,0,"BEFORE")),U,1)
.;If after is null then the health factor has been deleted so delete
.;any open alerts.
. I HFAIEN="",HFBIEN'="" D DELOPEN^PXRMNTFY(DFN,77) Q
.;If the before and after are the same the HF is not new so do not
.;send the alert.
. I HFAIEN=HFBIEN Q
. I HFAIEN=HFSAIEN S MSG="Suicide attempted"
. I HFAIEN=HFSCIEN S MSG="Suicide completed"
I MSG="" Q
;DBIA #2028
S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
;If DATE is more than 30 days in the past do not send the alert.
I $$FMDIFF^XLFDT(DT,DATE)>30 Q
S MSG=MSG_" on "_$$FMTE^XLFDT(DATE,"5Z")
;DBIA #1362
D EN^ORB3(77,DFN,"","",MSG,"")
Q
;
PXRMNTFY ;SLC/PKR - Routines for notifications. ;07/25/2012
+1 ;;2.0;CLINICAL REMINDERS;**24**;Feb 04, 2005;Build 193
+2 ;
+3 ;========================
DELOPEN(DFN,ORN) ;Delete open OE/RR Notifications.
+1 NEW ALIST,IND,ORID,XQAID
+2 ;DBIA #10081
+3 DO PATIENT^XQALERT("ALIST",DFN)
+4 FOR IND=1:1:ALIST
Begin DoDot:1
+5 SET XQAID=$PIECE(ALIST(IND),U,2)
+6 SET ORID=$PIECE(XQAID,";",1)
+7 IF $PIECE(ORID,",",3)=ORN
DO DELETE^XQALERT
End DoDot:1
+8 QUIT
+9 ;
+10 ;========================
SUICIDE(EVENT,DFN,VISIT) ;Send an alert if the patient attempted or
+1 ;completed suicide, as marked by a health factor. This is called
+2 ;from DATACHGR^PXRMPINF which is invoked by the protocol PXK VISIT
+3 ;DATA EVENT.
+4 NEW DATE,HAFIEN,HFBIEN,HFSAIEN,HFSCIEN,MSG,VHFIEN
+5 SET HFSAIEN=$$FIND1^DIC(9999999.64,"","","MH SUICIDE ATTEMPTED")
+6 SET HFSCIEN=$$FIND1^DIC(9999999.64,"","","MH SUICIDE COMPLETED")
+7 SET (MSG,VHFIEN)=""
+8 FOR
SET VHFIEN=$ORDER(^XTMP(EVENT,VISIT,"HF",VHFIEN))
IF VHFIEN=""
QUIT
Begin DoDot:1
+9 SET HFAIEN=$PIECE($GET(^XTMP(EVENT,VISIT,"HF",VHFIEN,0,"AFTER")),U,1)
+10 SET HFBIEN=$PIECE($GET(^XTMP(EVENT,VISIT,"HF",VHFIEN,0,"BEFORE")),U,1)
+11 ;If after is null then the health factor has been deleted so delete
+12 ;any open alerts.
+13 IF HFAIEN=""
IF HFBIEN'=""
DO DELOPEN^PXRMNTFY(DFN,77)
QUIT
+14 ;If the before and after are the same the HF is not new so do not
+15 ;send the alert.
+16 IF HFAIEN=HFBIEN
QUIT
+17 IF HFAIEN=HFSAIEN
SET MSG="Suicide attempted"
+18 IF HFAIEN=HFSCIEN
SET MSG="Suicide completed"
End DoDot:1
+19 IF MSG=""
QUIT
+20 ;DBIA #2028
+21 SET DATE=$PIECE(^AUPNVSIT(VISIT,0),U,1)
+22 ;If DATE is more than 30 days in the past do not send the alert.
+23 IF $$FMDIFF^XLFDT(DT,DATE)>30
QUIT
+24 SET MSG=MSG_" on "_$$FMTE^XLFDT(DATE,"5Z")
+25 ;DBIA #1362
+26 DO EN^ORB3(77,DFN,"","",MSG,"")
+27 QUIT
+28 ;