PXRMOUTU ;SLC/PKR - Utilities for preparing output. ;02/14/2022
;;2.0;CLINICAL REMINDERS;**17,18,26,47,42,65**;Feb 04, 2005;Build 438
;
;==================================================
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(1)="There was an error processing this reminder, it could not be properly evaluated."
. S TEXT(2)="There may be additional information in the error trap."
. D ADDTXTA(2,PXRMRM,.NTXT,2,.TEXT)
;
;Frequency errors
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","NOFREQ")) D
. S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"FERROR","NOFREQ")
. 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="NO PAT" S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"FERROR","PATIENT","NO PAT")
. D ADDTXT(1,PXRMRM,.NTXT,TEXT)
;
;Problems with CF.VA-REMINDER DEFINITION
;No reminder definition
I $D(^TMP(PXRMPID,$J,PXRMITEM,"FERROR","CF.VA-REMINDER DEFINITION")) D
. K TEXT
. S TEXT(1)=""
. S TEXT(2)="The computed finding parameter for CF.VA-REMINDER DEFINITION is missing, invalid, or inactive."
. D ADDTXTA(1,PXRMRM,.NTXT,2,.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(2,PXRMRM,.NTXT,2,.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)
;
;General text
K TEXT
S TEXT(1)=""
S TEXT(2)="Please notify your Clinical Reminder Manager about this error."
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(1)=""
S TEXT(2)="Information about the reminder evaluation:"
D ADDTXTA(1,PXRMRM,.NTXT,2,.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,"WARNING",DESCRIPTION)=TEXT
I '$D(^TMP(PXRMPID,$J,PXRMITEM,"WARNING")) 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,"WARNING",DES)) Q:DES="" D
. S TEXT=^TMP(PXRMPID,$J,PXRMITEM,"WARNING",DES)
. S NL=NL+1 S ^TMP("PXRMXMZ",$J,NL,0)=" "_^TMP(PXRMPID,$J,PXRMITEM,"WARNING",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
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMOUTU 4202 printed Oct 16, 2024@17:47:51 Page 2
PXRMOUTU ;SLC/PKR - Utilities for preparing output. ;02/14/2022
+1 ;;2.0;CLINICAL REMINDERS;**17,18,26,47,42,65**;Feb 04, 2005;Build 438
+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(1)="There was an error processing this reminder, it could not be properly evaluated."
+6 SET TEXT(2)="There may be additional information in the error trap."
+7 DO ADDTXTA(2,PXRMRM,.NTXT,2,.TEXT)
End DoDot:1
+8 ;
+9 ;Frequency errors
+10 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NOFREQ"))
Begin DoDot:1
+11 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NOFREQ")
+12 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+13 ;
+14 ;Patient errors
+15 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT"))
Begin DoDot:1
+16 SET ERROR=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT",""))
+17 IF ERROR="NO PAT"
SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","PATIENT","NO PAT")
+18 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+19 ;
+20 ;Problems with CF.VA-REMINDER DEFINITION
+21 ;No reminder definition
+22 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","CF.VA-REMINDER DEFINITION"))
Begin DoDot:1
+23 KILL TEXT
+24 SET TEXT(1)=""
+25 SET TEXT(2)="The computed finding parameter for CF.VA-REMINDER DEFINITION is missing, invalid, or inactive."
+26 DO ADDTXTA(1,PXRMRM,.NTXT,2,.TEXT)
End DoDot:1
+27 ;
+28 ;Recursion
+29 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","RECURSION"))
Begin DoDot:1
+30 KILL TEXT
+31 SET TEXT(1)=""
+32 SET TEXT(2)="This reminder definition is being called recursively, check CF.VA-REMINDER DEFINITION."
+33 DO ADDTXTA(2,PXRMRM,.NTXT,2,.TEXT)
End DoDot:1
+34 ;
+35 ;Reminder errors
+36 IF $DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NO REMINDER"))
Begin DoDot:1
+37 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"FERROR","NO REMINDER")
+38 DO ADDTXT(1,PXRMRM,.NTXT,TEXT)
End DoDot:1
+39 ;
+40 ;General text
+41 KILL TEXT
+42 SET TEXT(1)=""
+43 SET TEXT(2)="Please notify your Clinical Reminder Manager about this error."
+44 DO ADDTXTA(1,PXRMRM,.NTXT,2,.TEXT)
+45 ;
+46 QUIT 1
+47 ;
+48 ;==================================================
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(1)=""
+5 SET TEXT(2)="Information about the reminder evaluation:"
+6 DO ADDTXTA(1,PXRMRM,.NTXT,2,.TEXT)
+7 SET DES=""
+8 FOR
SET DES=$ORDER(^TMP(PXRMPID,$JOB,PXRMITEM,"INFO",DES))
if DES=""
QUIT
Begin DoDot:1
+9 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"INFO",DES)
+10 DO ADDTXT(2,PXRMRM,.NTXT,TEXT)
End DoDot:1
+11 QUIT
+12 ;
+13 ;==================================================
WARN(PXRMITEM,PXRMPDEM) ;Output WARNING text. An WARN node has the structure:
+1 ;(PXRMPID,$J,PXRMITEM,"WARNING",DESCRIPTION)=TEXT
+2 IF '$DATA(^TMP(PXRMPID,$JOB,PXRMITEM,"WARNING"))
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,"WARNING",DES))
if DES=""
QUIT
Begin DoDot:1
+10 SET TEXT=^TMP(PXRMPID,$JOB,PXRMITEM,"WARNING",DES)
+11 SET NL=NL+1
SET ^TMP("PXRMXMZ",$JOB,NL,0)=" "_^TMP(PXRMPID,$JOB,PXRMITEM,"WARNING",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 ;