ORQQXQA ; slc/CLA - Functions which return patient/user alert and mailman data ;5/27/98
;;3.0;ORDER ENTRY/RESULTS REPORTING;**9**;Dec 17, 1997
ALLPAT(ORY,ORPT) ;return all patient's alerts regardless of recipient
N STRTDATE,STOPDATE S STRTDATE="",STOPDATE=""
D PATIENT^XQALERT("^TMP(""ORB"",$J)",ORPT,STRTDATE,STOPDATE)
N ORX,ORTOT
S ORTOT=^TMP("ORB",$J)
I ORTOT=0 S ORY(1)="^No notifications found."
E F I=1:1:ORTOT S ORX=$P(^TMP("ORB",$J,I),U,2) I $P(ORX,";")["OR" D
.S ORY(I)=ORX_U_$P(^TMP("ORB",$J,I),U)_U_$P($P(ORX,";"),",",2)
K ^TMP("ORB",$J),I
Q
PATIENT(ORY,ORPT) ;return current user's notifications for patient ORPT
Q:'$L($G(ORPT))
N STRTDATE,STOPDATE S STRTDATE="",STOPDATE=""
D USER^XQALERT("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
N I,J,INFO,ORX,URG,ORN,ORPTN,SORT,SVAL,TVAL,MSG,ORNAME,INVDT,PT,NODE,ORT
N ORTOT
S ORTOT=^TMP("ORB",$J)
S J=0,NODE="",TVAL=""
F I=1:1:ORTOT S ORX=$P(^TMP("ORB",$J,I),U,2) I ($P(ORX,";")["OR"),($P(ORX,",",2)=ORPT) D
.S ORN=$P($P(ORX,";"),",",3)
.S INVDT=9999999-$P(ORX,";",3)
.D SORT^ORQORB(.SORT) S SORT=$S($L($G(SORT)):SORT,1:"P") ;sort method
.I SORT'="P" D
..D URGENCY^ORQORB(.URG,ORN) S URG=$S($G(URG)>0:URG,1:2)
..S ORNAME=$P(^ORD(100.9,ORN,0),U)
.S INFO=$P(^TMP("ORB",$J,I)," ")
.S MSG=$S(INFO="I":INFO,1:" ")_" "_$P($P(^TMP("ORB",$J,I),U),"):",2)
.I SORT="U" S SVAL=URG_U_ORNAME
.I SORT="T" S SVAL=ORNAME
.I SORT="P" S SVAL=""
.S ^TMP("ORB2",$J,SVAL_U_INVDT)=ORX_U_MSG_U_ORPT_U_$P(ORX,";",3)
F S NODE=$O(^TMP("ORB2",$J,NODE)) Q:NODE="" S J=J+1 D
.S SVAL=$P(NODE,U)
.I SORT'="P",(TVAL'=SVAL) D
..S ORY(J)=U_$S(SORT="U":$S(SVAL=1:"HIGH",SVAL=3:"LOW",1:"MODERATE"),1:SVAL)_":",TVAL=SVAL,J=J+1
.S ORY(J)=^TMP("ORB2",$J,NODE)
I J=0 S ORY(1)="^No notifications found."
K ^TMP("ORB",$J),^TMP("ORB2",$J)
Q
USER(ORY) ;return current user's notifications across all patients
N STRTDATE,STOPDATE S STRTDATE="",STOPDATE=""
D USER^XQALERT("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
N I,J,INFO,ORX,URG,ORN,ORNAME,ORPT,ORPTN,SORT,SVAL,TVAL,SVAL2,TVAL2
N MSG,NODE,ORT,ORTOT,INVDT
S NODE="",TVAL="",TVAL2=""
D SORT^ORQORB(.SORT) S SORT=$S($L($G(SORT)):SORT,1:"P") ;sort method
S ORTOT=^TMP("ORB",$J)
F I=1:1:ORTOT S ORX=$P(^TMP("ORB",$J,I),U,2) I $P(ORX,";")["OR" D
.S ORN=$P($P(ORX,";"),",",3) ;type of notification (ien)
.S ORPT=$P($P(ORX,";"),",",2) ;DFN
.S INVDT=9999999-$P(ORX,";",3) ;reverse d/t
.D URGENCY^ORQORB(.URG,ORN) S URG=$S($G(URG)>0:URG,1:2) ;urgency of notification type
.S ORNAME=$P(^ORD(100.9,ORN,0),U) ;name of notification type (external)
.S ORPTN=$$LOWER^VALM1($P(^DPT(ORPT,0),U)) ;change patient's name to mixed case
.S INFO=$P(^TMP("ORB",$J,I)," ")
.S MSG=$S(INFO="I":INFO,1:" ")_" "_$P($P(^TMP("ORB",$J,I),U),"):",2)
.;sorting
.I SORT="U" S SVAL=URG_U_ORPTN_U_ORNAME ;by urgency
.I SORT="T" S SVAL=ORNAME_U_ORPTN ;by type
.I SORT="P" S SVAL=ORPTN_U_URG_U_ORNAME ;by patient
.;below is set to: XQAID^ notification name^DFN^date/time
.S ^TMP("ORB2",$J,SVAL_U_INVDT)=ORX_U_" "_MSG_U_ORPT_U_$P(ORX,";",3)
S J=0
F S NODE=$O(^TMP("ORB2",$J,NODE)) Q:NODE="" S J=J+1 D
.S SVAL=$P(NODE,U),SVAL2=$P(NODE,U,2)
.;set sorting heading
.I TVAL'=SVAL D
..S ORY(J)=U_$S(SORT="U":$S(SVAL=1:"HIGH",SVAL=3:"LOW",1:"MODERATE"),1:SVAL)_":",TVAL=SVAL,TVAL2="",J=J+1
.I SORT'="P",TVAL2'=SVAL2 S ORY(J)=U_" "_SVAL2,TVAL2=SVAL2,J=J+1
.;set to alert information to return
.S ORY(J)=^TMP("ORB2",$J,NODE)
I J=0 S ORY(1)="^No notifications found."
K ^TMP("ORB",$J),^TMP("ORB2",$J)
Q
MAILG(ORY) ; return mail groups in a system
N ORI S ORI=1
;DIC access to MAIL GROUPS FILE [#3.8] granted via DBIA #10111
D LIST^DIC(3.8,"","","","","","","","","","ORBMG($J)")
F ORI=1:1:$P(ORBMG($J,"DILIST",0),U) S ORY(ORI)=ORBMG($J,"DILIST",2,ORI)_U_ORBMG($J,"DILIST",1,ORI)
D CLEAN^DILF
K ORBMG
Q
ORQQXQA ; slc/CLA - Functions which return patient/user alert and mailman data ;5/27/98
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9**;Dec 17, 1997
ALLPAT(ORY,ORPT) ;return all patient's alerts regardless of recipient
+1 NEW STRTDATE,STOPDATE
SET STRTDATE=""
SET STOPDATE=""
+2 DO PATIENT^XQALERT("^TMP(""ORB"",$J)",ORPT,STRTDATE,STOPDATE)
+3 NEW ORX,ORTOT
+4 SET ORTOT=^TMP("ORB",$JOB)
+5 IF ORTOT=0
SET ORY(1)="^No notifications found."
+6 IF '$TEST
FOR I=1:1:ORTOT
SET ORX=$PIECE(^TMP("ORB",$JOB,I),U,2)
IF $PIECE(ORX,";")["OR"
Begin DoDot:1
+7 SET ORY(I)=ORX_U_$PIECE(^TMP("ORB",$JOB,I),U)_U_$PIECE($PIECE(ORX,";"),",",2)
End DoDot:1
+8 KILL ^TMP("ORB",$JOB),I
+9 QUIT
PATIENT(ORY,ORPT) ;return current user's notifications for patient ORPT
+1 IF '$LENGTH($GET(ORPT))
QUIT
+2 NEW STRTDATE,STOPDATE
SET STRTDATE=""
SET STOPDATE=""
+3 DO USER^XQALERT("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
+4 NEW I,J,INFO,ORX,URG,ORN,ORPTN,SORT,SVAL,TVAL,MSG,ORNAME,INVDT,PT,NODE,ORT
+5 NEW ORTOT
+6 SET ORTOT=^TMP("ORB",$JOB)
+7 SET J=0
SET NODE=""
SET TVAL=""
+8 FOR I=1:1:ORTOT
SET ORX=$PIECE(^TMP("ORB",$JOB,I),U,2)
IF ($PIECE(ORX,";")["OR")
IF ($PIECE(ORX,",",2)=ORPT)
Begin DoDot:1
+9 SET ORN=$PIECE($PIECE(ORX,";"),",",3)
+10 SET INVDT=9999999-$PIECE(ORX,";",3)
+11 ;sort method
DO SORT^ORQORB(.SORT)
SET SORT=$SELECT($LENGTH($GET(SORT)):SORT,1:"P")
+12 IF SORT'="P"
Begin DoDot:2
+13 DO URGENCY^ORQORB(.URG,ORN)
SET URG=$SELECT($GET(URG)>0:URG,1:2)
+14 SET ORNAME=$PIECE(^ORD(100.9,ORN,0),U)
End DoDot:2
+15 SET INFO=$PIECE(^TMP("ORB",$JOB,I)," ")
+16 SET MSG=$SELECT(INFO="I":INFO,1:" ")_" "_$PIECE($PIECE(^TMP("ORB",$JOB,I),U),"):",2)
+17 IF SORT="U"
SET SVAL=URG_U_ORNAME
+18 IF SORT="T"
SET SVAL=ORNAME
+19 IF SORT="P"
SET SVAL=""
+20 SET ^TMP("ORB2",$JOB,SVAL_U_INVDT)=ORX_U_MSG_U_ORPT_U_$PIECE(ORX,";",3)
End DoDot:1
+21 FOR
SET NODE=$ORDER(^TMP("ORB2",$JOB,NODE))
IF NODE=""
QUIT
SET J=J+1
Begin DoDot:1
+22 SET SVAL=$PIECE(NODE,U)
+23 IF SORT'="P"
IF (TVAL'=SVAL)
Begin DoDot:2
+24 SET ORY(J)=U_$SELECT(SORT="U":$SELECT(SVAL=1:"HIGH",SVAL=3:"LOW",1:"MODERATE"),1:SVAL)_":"
SET TVAL=SVAL
SET J=J+1
End DoDot:2
+25 SET ORY(J)=^TMP("ORB2",$JOB,NODE)
End DoDot:1
+26 IF J=0
SET ORY(1)="^No notifications found."
+27 KILL ^TMP("ORB",$JOB),^TMP("ORB2",$JOB)
+28 QUIT
USER(ORY) ;return current user's notifications across all patients
+1 NEW STRTDATE,STOPDATE
SET STRTDATE=""
SET STOPDATE=""
+2 DO USER^XQALERT("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
+3 NEW I,J,INFO,ORX,URG,ORN,ORNAME,ORPT,ORPTN,SORT,SVAL,TVAL,SVAL2,TVAL2
+4 NEW MSG,NODE,ORT,ORTOT,INVDT
+5 SET NODE=""
SET TVAL=""
SET TVAL2=""
+6 ;sort method
DO SORT^ORQORB(.SORT)
SET SORT=$SELECT($LENGTH($GET(SORT)):SORT,1:"P")
+7 SET ORTOT=^TMP("ORB",$JOB)
+8 FOR I=1:1:ORTOT
SET ORX=$PIECE(^TMP("ORB",$JOB,I),U,2)
IF $PIECE(ORX,";")["OR"
Begin DoDot:1
+9 ;type of notification (ien)
SET ORN=$PIECE($PIECE(ORX,";"),",",3)
+10 ;DFN
SET ORPT=$PIECE($PIECE(ORX,";"),",",2)
+11 ;reverse d/t
SET INVDT=9999999-$PIECE(ORX,";",3)
+12 ;urgency of notification type
DO URGENCY^ORQORB(.URG,ORN)
SET URG=$SELECT($GET(URG)>0:URG,1:2)
+13 ;name of notification type (external)
SET ORNAME=$PIECE(^ORD(100.9,ORN,0),U)
+14 ;change patient's name to mixed case
SET ORPTN=$$LOWER^VALM1($PIECE(^DPT(ORPT,0),U))
+15 SET INFO=$PIECE(^TMP("ORB",$JOB,I)," ")
+16 SET MSG=$SELECT(INFO="I":INFO,1:" ")_" "_$PIECE($PIECE(^TMP("ORB",$JOB,I),U),"):",2)
+17 ;sorting
+18 ;by urgency
IF SORT="U"
SET SVAL=URG_U_ORPTN_U_ORNAME
+19 ;by type
IF SORT="T"
SET SVAL=ORNAME_U_ORPTN
+20 ;by patient
IF SORT="P"
SET SVAL=ORPTN_U_URG_U_ORNAME
+21 ;below is set to: XQAID^ notification name^DFN^date/time
+22 SET ^TMP("ORB2",$JOB,SVAL_U_INVDT)=ORX_U_" "_MSG_U_ORPT_U_$PIECE(ORX,";",3)
End DoDot:1
+23 SET J=0
+24 FOR
SET NODE=$ORDER(^TMP("ORB2",$JOB,NODE))
IF NODE=""
QUIT
SET J=J+1
Begin DoDot:1
+25 SET SVAL=$PIECE(NODE,U)
SET SVAL2=$PIECE(NODE,U,2)
+26 ;set sorting heading
+27 IF TVAL'=SVAL
Begin DoDot:2
+28 SET ORY(J)=U_$SELECT(SORT="U":$SELECT(SVAL=1:"HIGH",SVAL=3:"LOW",1:"MODERATE"),1:SVAL)_":"
SET TVAL=SVAL
SET TVAL2=""
SET J=J+1
End DoDot:2
+29 IF SORT'="P"
IF TVAL2'=SVAL2
SET ORY(J)=U_" "_SVAL2
SET TVAL2=SVAL2
SET J=J+1
+30 ;set to alert information to return
+31 SET ORY(J)=^TMP("ORB2",$JOB,NODE)
End DoDot:1
+32 IF J=0
SET ORY(1)="^No notifications found."
+33 KILL ^TMP("ORB",$JOB),^TMP("ORB2",$JOB)
+34 QUIT
MAILG(ORY) ; return mail groups in a system
+1 NEW ORI
SET ORI=1
+2 ;DIC access to MAIL GROUPS FILE [#3.8] granted via DBIA #10111
+3 DO LIST^DIC(3.8,"","","","","","","","","","ORBMG($J)")
+4 FOR ORI=1:1:$PIECE(ORBMG($JOB,"DILIST",0),U)
SET ORY(ORI)=ORBMG($JOB,"DILIST",2,ORI)_U_ORBMG($JOB,"DILIST",1,ORI)
+5 DO CLEAN^DILF
+6 KILL ORBMG
+7 QUIT