PXRMOUTU ;SLC/PKR - Utilities for preparing output. ;01/28/2013
;;2.0;CLINICAL REMINDERS;**17,18,26**;Feb 04, 2005;Build 404
;
;==================================================
ADDTXT(LM,RM,NTXT,TXT) ;
N IND,NOUT,TEXTOUT
D FORMATS^PXRMTEXT(LM,RM,.TXT,.NOUT,.TEXTOUT)
F IND=1:1:NOUT S NTXT=NTXT+1,^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXTOUT(IND)
Q
;
;==================================================
ADDTXTA(LM,RM,NTXT,NLINES,TXTA) ;Add an array of text.
I NLINES=0 Q
N IND,NOUT,TEXTOUT
D FORMAT^PXRMTEXT(LM,RM,NLINES,.TXTA,.NOUT,.TEXTOUT)
F IND=1:1:NOUT S NTXT=NTXT+1,^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXTOUT(IND)
Q
;
;==================================================
COPYTXT(NTXT,NLINES,TEXT) ;Copy NLINES of TEXT into ^TMP output.
N IND
F IND=1:1:NLINES S NTXT=NTXT+1,^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXT(IND)
Q
;
;==================================================
FERROR(NTXT) ; Check for a fatal error and output a message.
I '$D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR")) Q 0
N ERROR,TEXT
;Error trap
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","ERROR TRAP")) D
. S TEXT="There was an error processing this reminder. It could not be properly evaluated; please notify your Clinical Reminder coordinator."
. D ADDTXT(1,PXRMRM,.NTXT,TEXT)
;
;Reminder errors
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","NO REMINDER")) D
. S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"FERROR","NO REMINDER")
. D ADDTXT(1,PXRMRM,.NTXT,TEXT)
;
;Expanded taxonomy errors
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","EXPANDED TAXONOMY")) D
. S ERROR=$O(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","EXPANDED TAXONOMY",""))
. I ERROR="NO LOCK" S TEXT="Could not get a lock for expanded taxonomy "_+PXRMXTLK_", try again!"
. D ADDTXT(1,PXRMRM,.NTXT,TEXT)
;
;Patient errors
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","PATIENT")) D
. S ERROR=$O(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","PATIENT",""))
. I ERROR="NOPAT" S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"FERROR","PATIENT","NOPAT")
. I ERROR="NO LOCK" S TEXT="Could not get a lock for patient "_PXRMPDEM("DFN")_", try again!"
. D ADDTXT(1,PXRMRM,.NTXT,TEXT)
;
;Recursion
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","RECURSION")) D
. K TEXT
. S TEXT(1)=""
. S TEXT(2)="This reminder definition is being called recursively, check CF.VA-REMINDER DEFINITION."
. D ADDTXTA(1,PXRMRM,.NTXT,2,.TEXT)
;
Q 1
;
;==================================================
INFO(PXRMITEM,NTXT) ;Output INFO text. An INFO node has the structure:
;(PXRMPID,$J,PXRMITEM,"INFO",DESCRIPTION)=TEXT
I '$D(^TMP(PXRMPID,$J,PXRMITEM,"INFO")) Q
N DES,TEXT
S TEXT="Information about the reminder evaluation:"
D ADDTXT(1,PXRMRM,.NTXT,TEXT)
S DES=""
F S DES=$O(^TMP(PXRMPID,$J,PXRMITEM,"INFO",DES)) Q:DES="" D
. S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"INFO",DES)
. D ADDTXT(2,PXRMRM,.NTXT,TEXT)
Q
;
;==================================================
WARN(PXRMITEM,PXRMPDEM) ;Output WARNING text. An WARN node has the structure:
;(PXRMPID,$J,PXRMITEM,"WARN",DESCRIPTION)=TEXT
I '$D(^TMP(PXRMPID,$J,PXRMITEM,"WARN")) Q
N DES,NL,REMINDER,SUB
K ^TMP("PXRMXMZ",$J)
S SUB="Reminder evaluation warnings"
S REMINDER=$S($G(PXRMITEM)>0:$P(^PXD(811.9,PXRMITEM,0),U,1),1:"?")
S ^TMP("PXRMXMZ",$J,1,0)="The following warnings were encountered:",NL=1
S DES=""
F S DES=$O(^TMP(PXRMPID,$J,PXRMITEM,"WARN",DES)) Q:DES="" D
. S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"WARN",DES)
. S NL=NL+1 S ^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP(PXRMPID,$J,PXRMITEM,"WARN",DES)
S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="While evaluating reminder "_REMINDER
S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="For patient DFN="_PXRMPDEM("DFN")
S NL=NL+1,^TMP("PXRMXMZ",$J,NL,0)="The time of the evaluation was "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
D SEND^PXRMMSG("PXRMXMZ",SUB,"",DUZ)
K ^TMP("PXRMXMZ",$J)
Q
;
PXRMOUTU ;SLC/PKR - Utilities for preparing output. ;01/28/2013
+1 ;;2.0;CLINICAL REMINDERS;**17,18,26**;Feb 04, 2005;Build 404
+2 ;
+3 ;==================================================
ADDTXT(LM,RM,NTXT,TXT) ;
+1 NEW IND,NOUT,TEXTOUT
+2 DO FORMATS^PXRMTEXT(LM,RM,.TXT,.NOUT,.TEXTOUT)
+3 FOR IND=1:1:NOUT
SET NTXT=NTXT+1
SET ^TMP("PXRHM",$JOB,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXTOUT(IND)
+4 QUIT
+5 ;
+6 ;==================================================
ADDTXTA(LM,RM,NTXT,NLINES,TXTA) ;Add an array of text.
+1 IF NLINES=0
QUIT
+2 NEW IND,NOUT,TEXTOUT
+3 DO FORMAT^PXRMTEXT(LM,RM,NLINES,.TXTA,.NOUT,.TEXTOUT)
+4 FOR IND=1:1:NOUT
SET NTXT=NTXT+1
SET ^TMP("PXRHM",$JOB,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXTOUT(IND)
+5 QUIT
+6 ;
+7 ;==================================================
COPYTXT(NTXT,NLINES,TEXT) ;Copy NLINES of TEXT into ^TMP output.
+1 NEW IND
+2 FOR IND=1:1:NLINES
SET NTXT=NTXT+1
SET ^TMP("PXRHM",$JOB,PXRMITEM,PXRMRNAM,"TXT",NTXT)=TEXT(IND)
+3 QUIT
+4 ;
+5 ;==================================================
FERROR(NTXT) ; Check for a fatal error and output a message.
+1 IF '$DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR"))
QUIT 0
+2 NEW ERROR,TEXT
+3 ;Error trap
+4 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","ERROR TRAP"))
Begin DoDot:1
+5 SET TEXT="There was an error processing this reminder. It could not be properly evaluated; please notify your Clinical Reminder coordinator."
+6 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+7 ;
+8 ;Reminder errors
+9 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NO REMINDER"))
Begin DoDot:1
+10 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NO REMINDER")
+11 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+12 ;
+13 ;Expanded taxonomy errors
+14 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","EXPANDED TAXONOMY"))
Begin DoDot:1
+15 SET ERROR=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","EXPANDED TAXONOMY",""))
+16 IF ERROR="NO LOCK"
SET TEXT="Could not get a lock for expanded taxonomy "_+PXRMXTLK_", try again!"
+17 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+18 ;
+19 ;Patient errors
+20 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT"))
Begin DoDot:1
+21 SET ERROR=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT",""))
+22 IF ERROR="NOPAT"
SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT","NOPAT")
+23 IF ERROR="NO LOCK"
SET TEXT="Could not get a lock for patient "_PXRMPDEM("DFN")_", try again!"
+24 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+25 ;
+26 ;Recursion
+27 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","RECURSION"))
Begin DoDot:1
+28 KILL TEXT
+29 SET TEXT(1)=""
+30 SET TEXT(2)="This reminder definition is being called recursively, check CF.VA-REMINDER DEFINITION."
+31 DO ADDTXTA(1,PXRMRM,.NTXT,2,.TEXT)
End DoDot:1
+32 ;
+33 QUIT 1
+34 ;
+35 ;==================================================
INFO(PXRMITEM,NTXT) ;Output INFO text. An INFO node has the structure:
+1 ;(PXRMPID,$J,PXRMITEM,"INFO",DESCRIPTION)=TEXT
+2 IF '$DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"INFO"))
QUIT
+3 NEW DES,TEXT
+4 SET TEXT="Information about the reminder evaluation:"
+5 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
+6 SET DES=""
+7 FOR
SET DES=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"INFO",DES))
IF DES=""
QUIT
Begin DoDot:1
+8 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"INFO",DES)
+9 DO ADDTXT(2,PXRMRM,.NTXT,TEXT)
End DoDot:1
+10 QUIT
+11 ;
+12 ;==================================================
WARN(PXRMITEM,PXRMPDEM) ;Output WARNING text. An WARN node has the structure:
+1 ;(PXRMPID,$J,PXRMITEM,"WARN",DESCRIPTION)=TEXT
+2 IF '$DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"WARN"))
QUIT
+3 NEW DES,NL,REMINDER,SUB
+4 KILL ^TMP("PXRMXMZ",$JOB)
+5 SET SUB="Reminder evaluation warnings"
+6 SET REMINDER=$SELECT($GET(PXRMITEM)>0:$PIECE(^PXD(811.9,PXRMITEM,0),U,1),1:"?")
+7 SET ^TMP("PXRMXMZ",$JOB,1,0)="The following warnings were encountered:"
SET NL=1
+8 SET DES=""
+9 FOR
SET DES=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"WARN",DES))
IF DES=""
QUIT
Begin DoDot:1
+10 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"WARN",DES)
+11 SET NL=NL+1
SET ^TMP("PXRMXMZ",$JOB,NL,0)=" "_^TMP(PXRMPID,$JOB,PXRMITEM,"WARN",DES)
End DoDot:1
+12 SET NL=NL+1
SET ^TMP("PXRMXMZ",$JOB,NL,0)="While evaluating reminder "_REMINDER
+13 SET NL=NL+1
SET ^TMP("PXRMXMZ",$JOB,NL,0)="For patient DFN="_PXRMPDEM("DFN")
+14 SET NL=NL+1
SET ^TMP("PXRMXMZ",$JOB,NL,0)="The time of the evaluation was "_$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
+15 DO SEND^PXRMMSG("PXRMXMZ",SUB,"",DUZ)
+16 KILL ^TMP("PXRMXMZ",$JOB)
+17 QUIT
+18 ;