PXRMGEV ;SLC/AGP,RFR - Generic entry point to run different Reminder Evaluation ;Apr 09, 2025@11:34:42
;;2.0;CLINICAL REMINDERS;**45,71,87**;Feb 04, 2005;Build 35
Q
; Reference to ^%DT in ICR #10003
EN(RESULT,INPUT) ;
; INPUT
; INPUT("SUB")=^TMP subscript to output all evaluations under
; CAUTION: It is not recommended to mix different evaluation types in
; one call with the same output subscript.
; INPUT("SUB","ROC")=^TMP subscript to output reminder order check evaluations under
; INPUT("SUB","LR")=^TMP subscript to output reminder list rule evaluations under
; INPUT("SUB","REMINDERS")=^TMP subscript to output reminder evaluations under
; INPUT("SUB","TERMS")=^TMP subscript to output reminder term evaluations under
; NOTE: When specifying ^TMP subscripts for one or more evaluation types, you are
; required to set INPUT("SUB"); input validation errors are reported under this
; ^TMP subscript.
;
; For Reminder Order Checks:
; INPUT("DFN")=DFN The patient to perform orders checks on.
; INPUT("ROC START")=START Date to start searching for orders; applies to all orders.
; INPUT("ROC STOP")=STOP Date to stop search for orders; applies to all orders.
; INPUT("ROC DISPLAY GROUPS",DG)="" Array of Display Group Names used in searching for orders.
; INPUT("ROC DISPLAY GROUPS",DG,"START")=START
; Date to start searching for orders; applies to orders with this
; display group and overrides "ROC START".
; INPUT("ROC DISPLAY GROUPS",DG,"STOP")=STOP
; Date to stop searching for orders; applies to orders with this
; display group and overrides "ROC STOP".
; INPUT("ROC STATUS",STATUS)="" Array of order status(es) used in searching for orders.
; INPUT("ROC ORDERED WITHIN")="" Flag indicating order date should fall between START and STOP; used
; in searching for orders.
; INPUT("ROC ORDERS",ORDERIEN)="" Array of orders to evaluate Reminder Order Checks for. If defined,
; the inputs of "ROC START", "ROC STOP", "ROC DISPLAY GROUPS",
; "ROC STATUS" and "ROC ORDERED WITHIN" are not needed.
; INPUT("ROC",ROC)="" Array of Reminder Order Check Groups to check for.
; If ROC is ALL, run against ALL order checks.
; INPUT("ROC RETURN TYPE","GROUPS")="" for groups
; ,"RULES")="" for rules
; ,"OI")="" for orderable items
;
; For Reminder List Rule Sets:
; INPUT("LR",LIST RULE SET NAME,INSTANCE)=PNAME^START DATE^END DATE^SECURE^OVERWRITE^RETURN DATA
; LIST RULE SET NAME Reminder list rule set to evaluate; either the rule set's NAME or IEN
; INSTANCE Whole number; allows running of same list rule set with different parameters
; PNAME Name of the Patient List to create in file 810.5
; SECURE 1 or 0; should the list be secure
; OVERWRITE 1 or 0; if an existing patient list with the same name should be overwritten
; START DATE Date to start the list rule from;
; actual date (internal or external), FM symbolic date, or reminder symbolic date
; END DATE Date to end the list rule on;
; actual date (internal or external), FM symbolic date, or reminder symbolic date
; RETURN DATA 1 or 0 to determine if data should be return with the patient
;
; For Reminder Definitions:
; INPUT("DFN")=DFN The patient to execute the reminder definition for.
; INPUT("REMINDERS",REMINDER)=SAVE_FIEVAL^MAINTENANCE_FORMAT^TODAY
; REMINDER Reminder definition to execute; either the definition's IEN,
; NAME or PRINT NAME
; SAVE_FIEVAL Copy the FIEVAL array into the return TMP global (boolean flag)
; MAINTENANCE_FORMAT How to format the maintenance section that is copied into the return TMP
; global; see the description for the OUTPUT parameter in the MAIN^PXRM
; line tag for acceptable values
; TODAY Date to use for evaluation in FileMan format
;
; For Reminder Terms:
; INPUT("DFN")=DFN The patient to execute the reminder term for.
; INPUT("TERMS",TERM)=DATE^RETURN FIEVAL^RETURN TEXT
; DATE if defined the date used for the term evaluation or use DT.
; RETURN FIEVAL = 1 the FIEVAL array will be returned in the FIEVAL subscript
; RETRUN TEXT = 1 the Term output will be returned in the DETAIL TEXT subscript
; OUTPUT
; ^TMP($J,SUB,0)=-1^ERROR MESSAGE There is a problem with the INPUT array.
; ^TMP($J,SUB,0)=1 There is data in the OUTPUT.
; ^TMP($J,SUB,0)=0 There is no data in the OUTPUT.
;
; For Reminder Order Checks:
; ^TMP($J,SUB,ORDER IEN)="Details from EN^ORQ1"^CURRENT AGENT/PROVIDER
; ^TMP($J,SUB,ORDER IEN,"RULES",ORDER CHECK RULE NAME)=""
; ^TMP($J,SUB,ORDER IEN,"GROUPS",ORDER CHECK GROUP NAME)=""
; ^TMP($J,SUB,ORDER IEN,"TX",N)=TEXT <= ORDER TEXT FROM EN^ORQ1
; ^TMP($J,SUB,ORDER IEN,"OI",OI)="Data from OIS^ORX8" <=ORDERABLE ITEMS
;
; For Reminder List Rule Sets:
; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE)=# OF PATIENTS
; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,DFN)=""
; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,DFN,"DATA",TYPE)=VALUE
; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,"PATIENT LIST CREATED")=NAME OF PATIENT LIST, from file 810.4
;
; For Reminder Definitions:
; ^TMP($J,SUB,REMINDER)="STATUS^DUE DATE^LAST DONE"
; ^TMP($J,SUB,REMINDER,"PRINT NAME")=Reminder's print name (or name if print name is null)
; ^TMP($J,SUB,REMINDER,"FIEVAL")=
; Merged copy of the FIEVAL array
; ^TMP($J,SUB,REMINDER,"MAINTENANCE",X)=Line X of the maintenance output
; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER)="STATUS^DUE DATE^LAST DONE"
; If REMINDER has the VA-REMINDER DEFINITION computed finding and its
; SAVETEMP parameter value is 1, then data for the COMPONENT REMINDER
; that is executed is returned under this node
; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"FIEVAL")=
; Merged copy of the FIEVAL array for COMPONENT REMINDER that is
; executed as a finding, where COMPONENT REMINDER is the PRINT
; NAME of that reminder
; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"MAINTENANCE",X)=
; Line X of the maintenance output for COMPONENT REMINDER that is
; executed as a finding, where COMPONENT REMINDER is the PRINT
; NAME of that reminder
;
; For Reminder Terms:
; ^TMP($J,SUB,"TERMS",NAME)=RESULT
; ^TMP($J,SUB,"TERMS","FIEVAL")=FIEVAL(ARRAY)
; ^TMP($J,SUB,"TERMS","DETAIL TEXT")=OUTPUT TEXT
; RESULT is either 1 for True or 0 for False
;
; INTERNAL INPUT ARRAY STRUCTURE
; DATA("ROC ORDERS",ORDER IEN (FILE 100))= SET TO ZERO NODE DOCUMENTED IN EN^ORQ1
; DATA("ROC ORDERS",ORDER IEN,"OI",OI)="" OI is the orderable item IEN (file 101.43) for the corresponding order
; DATA("ROC ORDERS",ORDER IEN,"PKG ID")=PACKAGE REFERENCE FIELD (#33)
; DATA("ROC ORDERS",ORDER IEN,"MODIFIERS",N)=EXTERNAL VALUE OF PROMPT WITH ID "MODIFIER"
; DATA("EVAL",TYPE,SUB,PIECE)=VALUE internal format used to updating reminder definition findings
; DATA("EVAL","EVAL DATE")=DATE internal format use to set the reminder evaluation date.
;
N DGIENS,ORDLST,REMTYPE,SUB,DATA
S SUB=$G(INPUT("SUB")) I SUB="" Q
K ^TMP($J,SUB)
S RESULT=$NA(^TMP($J,SUB))
S @RESULT@(0)=0
M DATA=INPUT
;Perform INPUT array checks
I $$CINPUTS(.RESULT,.DATA)=1 Q
I $D(DATA("ROC ORDERS")) D GETOIS^PXRMGEVA(.DATA)
I $D(DATA("ROC DISPLAY GROUPS"))>0 D
.; find display group IEN needed to find orders
.D FINDDGS^PXRMGEVA(.RESULT,.DATA) I '$D(DATA("DG IEN")) D ERROR^PXRMGEVA(.RESULT,"No Display Group Found") Q
.I +$G(@RESULT@(0))<0 Q
.; find orders based off Display Groups and Status
.D GTORDERS^PXRMGEVA(.DATA)
I +$G(@RESULT@(0))<0 Q
D REM^PXRMGEVA(.RESULT,.DATA)
I $D(DATA("SUB"))=10 S RESULT=$NA(^TMP($J))
Q
;
CINPUTS(RESULT,INPUT) ;
N DGIEN,FAIL,GNAME,NAME,NODE,RETTYPE,ROC,ROCIENS,ROCTYPE,RIEN,TIEN,%DT,X,Y,INSTANCE
I '$D(INPUT("ROC")),'$D(INPUT("REMINDERS")),'$D(INPUT("LR")),'$D(INPUT("TERMS")) D ERROR^PXRMGEVA(.RESULT,"No reminders items defined") Q 1
I $D(INPUT("ROC"))!($D(INPUT("REMINDERS"))!($D(INPUT("TERMS")))) D I +$G(@RESULT@(0))<0 Q 1
.I +$G(INPUT("DFN"))<1 D ERROR^PXRMGEVA(.RESULT,"Patient is not properly defined") Q
.I '$D(^DPT(INPUT("DFN"),0)) D ERROR^PXRMGEVA(.RESULT,"Invalid patient specified") Q
;check order checks array
I $D(INPUT("ROC")) D I +$G(@RESULT@(0))<0 Q 1
.S ROCTYPE="",ROCTYPE("VALID")=0 F S ROCTYPE=$O(INPUT("ROC RETURN TYPE",ROCTYPE)) Q:ROCTYPE="" D
..I "^GROUPS^RULES^GROUPS/RULES^OI^"'[(U_ROCTYPE_U) D ERROR^PXRMGEVA(.RESULT,"Return type must be either GROUPS, RULES, GROUPS/RULES, or OI.") Q
..I "^GROUPS^RULES^GROUPS/RULES^"[(U_ROCTYPE_U) S ROCTYPE("VALID")=1
.Q:+$G(@RESULT@(0))<0
.I 'ROCTYPE("VALID") D ERROR^PXRMGEVA(.RESULT,"A return type of either GROUPS, RULES or GROUPS/RULES is required.") Q
.I $D(INPUT("ROC ORDERS")),$D(INPUT("ROC DISPLAY GROUPS")) D ERROR^PXRMGEVA(.RESULT,"Cannot search for both Orders and Display Groups") Q
.I $D(INPUT("ROC ORDERS")) Q
.I '$D(INPUT("ROC STATUS")) D ERROR^PXRMGEVA(.RESULT,"No statuses or search criteria defined") Q
.I '$D(INPUT("ROC DISPLAY GROUPS")) D ERROR^PXRMGEVA(.RESULT,"No Display Groups define")
.S FAIL=0
.I $D(INPUT("ROC ORDERED WITHIN")) D
..S DGIEN=0 F S DGIEN=$O(INPUT("ROC DISPLAY GROUPS",DGIEN)) Q:DGIEN'>0!(FAIL=1) D
...I +$G(INPUT("ROC DISPLAY GROUPS",DGIEN,"START"))=0 S FAIL=1 Q
...I +$G(INPUT("ROC DISPLAY GROUPS",DGIEN,"STOP"))=0 S FAIL=1 Q
.I FAIL=1 D ERROR^PXRMGEVA(.RESULT,"No search date range defined") Q
.I '$D(INPUT("ROC","ALL")) D
..S GNAME="" F S GNAME=$O(INPUT("ROC",GNAME)) Q:GNAME=""!(FAIL=1) D
...I '$D(^PXD(801,"B",GNAME)) D ERROR^PXRMGEVA(.RESULT,"Reminder Order Check Group: "_GNAME_" not found") S FAIL=1
;check list rule array
I $D(INPUT("LR")) D I +$G(@RESULT@(0))<0 Q 1
.S NAME="" F S NAME=$O(INPUT("LR",NAME)) Q:NAME="" D
..S RIEN=0
..I NAME'?1.N S RIEN=+$O(^PXRM(810.4,"B",$E(NAME,1,96),0))
..I NAME?1.N S RIEN=NAME
..I ('RIEN)!('$D(^PXRM(810.4,RIEN,0))) D ERROR^PXRMGEVA(.RESULT,"Reminder list rule/rule set """_NAME_""" does not exist") Q
..I $P($G(^PXRM(810.4,RIEN,0)),U,3)'=3 D ERROR^PXRMGEVA(.RESULT,""""_NAME_""" is not a reminder list rule set") Q
..S INPUT("LR",NAME,"IEN")=RIEN
..S INSTANCE="" F S INSTANCE=$O(INPUT("LR",NAME,INSTANCE)) Q:'+INSTANCE D
...S NODE=$G(INPUT("LR",NAME,INSTANCE))
...I $P(NODE,U)="" D ERROR^PXRMGEVA(.RESULT,"Patient List Name not defined for """_NAME_""" instance "_INSTANCE) Q
...I $P(NODE,U,2)="" D ERROR^PXRMGEVA(.RESULT,"Start Date not defined for """_NAME_""" instance "_INSTANCE) Q
...I $P(NODE,U,3)="" D ERROR^PXRMGEVA(.RESULT,"End Date not defined for """_NAME_""" instance "_INSTANCE) Q
...I $P(NODE,U,4)="" D ERROR^PXRMGEVA(.RESULT,"Secure not defined for """_NAME_""" instance "_INSTANCE) Q
...I $P(NODE,U,5)="" D ERROR^PXRMGEVA(.RESULT,"Overwrite not defined for """_NAME_""" instance "_INSTANCE)
;check reminder definitions array
I $D(INPUT("REMINDERS")) D I +$G(@RESULT@(0))<0 Q 1
.S NAME="" F S NAME=$O(INPUT("REMINDERS",NAME)) Q:NAME="" D
..S RIEN=0
..I NAME'?1.N D
...S RIEN=+$O(^PXD(811.9,"B",$E(NAME,1,64),0)) Q:RIEN>0
...S RIEN=+$O(^PXD(811.9,"D",$E(NAME,1,35),0))
..I NAME?1.N S RIEN=NAME
..I ('RIEN)!('$D(^PXD(811.9,RIEN,0))) D ERROR^PXRMGEVA(.RESULT,"Reminder definition does not exist") Q
..I $P($G(^PXD(811.9,RIEN,0)),U,6)=1 D ERROR^PXRMGEVA(.RESULT,"The reminder definition is inactive") Q
..S INPUT("REMINDERS",RIEN)=NAME_U_INPUT("REMINDERS",NAME)
..I NAME'=RIEN K INPUT("REMINDERS",NAME)
..S NODE=$G(INPUT("REMINDERS",RIEN)) Q:NODE=""
..I "^0^1^"'[(U_$P(NODE,U,2)_U) D ERROR^PXRMGEVA(.RESULT,"Invalid SAVE_FIEVAL flag; set it to either 0 or 1") Q
..I $P(NODE,U,4)'="" D
...S %DT="",X=$P(NODE,U,4)
...D ^%DT
...I Y=-1 D ERROR^PXRMGEVA(.RESULT,"Invalid value for TODAY") Q
...S $P(INPUT("REMINDERS",RIEN),U,4)=Y
;check reminder terms array
I $D(INPUT("TERMS")) D I +$G(@RESULT@(0))<0 Q 1
.S NAME="" F S NAME=$O(INPUT("TERMS",NAME)) Q:NAME="" D
..S NODE=INPUT("TERMS",NAME)
..S TIEN=0
..I NAME'?1.N S TIEN=+$O(^PXRMD(811.5,"B",$E(NAME,1,64),0)) S RETTYPE="NAME"
..I NAME?1.N S TIEN=NAME S RETTYPE="IEN"
..I ('TIEN)!('$D(^PXRMD(811.5,TIEN,0))) D ERROR^PXRMGEVA(.RESULT,"Reminder term """_NAME_"""does not exist") Q
..S INPUT("TERMS",TIEN)=NAME_U_NODE_U_RETTYPE
..I NAME'=TIEN K INPUT("TERMS",NAME)
Q 0
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMGEV 13696 printed May 25, 2026@11:49:30 Page 2
PXRMGEV ;SLC/AGP,RFR - Generic entry point to run different Reminder Evaluation ;Apr 09, 2025@11:34:42
+1 ;;2.0;CLINICAL REMINDERS;**45,71,87**;Feb 04, 2005;Build 35
+2 QUIT
+3 ; Reference to ^%DT in ICR #10003
EN(RESULT,INPUT) ;
+1 ; INPUT
+2 ; INPUT("SUB")=^TMP subscript to output all evaluations under
+3 ; CAUTION: It is not recommended to mix different evaluation types in
+4 ; one call with the same output subscript.
+5 ; INPUT("SUB","ROC")=^TMP subscript to output reminder order check evaluations under
+6 ; INPUT("SUB","LR")=^TMP subscript to output reminder list rule evaluations under
+7 ; INPUT("SUB","REMINDERS")=^TMP subscript to output reminder evaluations under
+8 ; INPUT("SUB","TERMS")=^TMP subscript to output reminder term evaluations under
+9 ; NOTE: When specifying ^TMP subscripts for one or more evaluation types, you are
+10 ; required to set INPUT("SUB"); input validation errors are reported under this
+11 ; ^TMP subscript.
+12 ;
+13 ; For Reminder Order Checks:
+14 ; INPUT("DFN")=DFN The patient to perform orders checks on.
+15 ; INPUT("ROC START")=START Date to start searching for orders; applies to all orders.
+16 ; INPUT("ROC STOP")=STOP Date to stop search for orders; applies to all orders.
+17 ; INPUT("ROC DISPLAY GROUPS",DG)="" Array of Display Group Names used in searching for orders.
+18 ; INPUT("ROC DISPLAY GROUPS",DG,"START")=START
+19 ; Date to start searching for orders; applies to orders with this
+20 ; display group and overrides "ROC START".
+21 ; INPUT("ROC DISPLAY GROUPS",DG,"STOP")=STOP
+22 ; Date to stop searching for orders; applies to orders with this
+23 ; display group and overrides "ROC STOP".
+24 ; INPUT("ROC STATUS",STATUS)="" Array of order status(es) used in searching for orders.
+25 ; INPUT("ROC ORDERED WITHIN")="" Flag indicating order date should fall between START and STOP; used
+26 ; in searching for orders.
+27 ; INPUT("ROC ORDERS",ORDERIEN)="" Array of orders to evaluate Reminder Order Checks for. If defined,
+28 ; the inputs of "ROC START", "ROC STOP", "ROC DISPLAY GROUPS",
+29 ; "ROC STATUS" and "ROC ORDERED WITHIN" are not needed.
+30 ; INPUT("ROC",ROC)="" Array of Reminder Order Check Groups to check for.
+31 ; If ROC is ALL, run against ALL order checks.
+32 ; INPUT("ROC RETURN TYPE","GROUPS")="" for groups
+33 ; ,"RULES")="" for rules
+34 ; ,"OI")="" for orderable items
+35 ;
+36 ; For Reminder List Rule Sets:
+37 ; INPUT("LR",LIST RULE SET NAME,INSTANCE)=PNAME^START DATE^END DATE^SECURE^OVERWRITE^RETURN DATA
+38 ; LIST RULE SET NAME Reminder list rule set to evaluate; either the rule set's NAME or IEN
+39 ; INSTANCE Whole number; allows running of same list rule set with different parameters
+40 ; PNAME Name of the Patient List to create in file 810.5
+41 ; SECURE 1 or 0; should the list be secure
+42 ; OVERWRITE 1 or 0; if an existing patient list with the same name should be overwritten
+43 ; START DATE Date to start the list rule from;
+44 ; actual date (internal or external), FM symbolic date, or reminder symbolic date
+45 ; END DATE Date to end the list rule on;
+46 ; actual date (internal or external), FM symbolic date, or reminder symbolic date
+47 ; RETURN DATA 1 or 0 to determine if data should be return with the patient
+48 ;
+49 ; For Reminder Definitions:
+50 ; INPUT("DFN")=DFN The patient to execute the reminder definition for.
+51 ; INPUT("REMINDERS",REMINDER)=SAVE_FIEVAL^MAINTENANCE_FORMAT^TODAY
+52 ; REMINDER Reminder definition to execute; either the definition's IEN,
+53 ; NAME or PRINT NAME
+54 ; SAVE_FIEVAL Copy the FIEVAL array into the return TMP global (boolean flag)
+55 ; MAINTENANCE_FORMAT How to format the maintenance section that is copied into the return TMP
+56 ; global; see the description for the OUTPUT parameter in the MAIN^PXRM
+57 ; line tag for acceptable values
+58 ; TODAY Date to use for evaluation in FileMan format
+59 ;
+60 ; For Reminder Terms:
+61 ; INPUT("DFN")=DFN The patient to execute the reminder term for.
+62 ; INPUT("TERMS",TERM)=DATE^RETURN FIEVAL^RETURN TEXT
+63 ; DATE if defined the date used for the term evaluation or use DT.
+64 ; RETURN FIEVAL = 1 the FIEVAL array will be returned in the FIEVAL subscript
+65 ; RETRUN TEXT = 1 the Term output will be returned in the DETAIL TEXT subscript
+66 ; OUTPUT
+67 ; ^TMP($J,SUB,0)=-1^ERROR MESSAGE There is a problem with the INPUT array.
+68 ; ^TMP($J,SUB,0)=1 There is data in the OUTPUT.
+69 ; ^TMP($J,SUB,0)=0 There is no data in the OUTPUT.
+70 ;
+71 ; For Reminder Order Checks:
+72 ; ^TMP($J,SUB,ORDER IEN)="Details from EN^ORQ1"^CURRENT AGENT/PROVIDER
+73 ; ^TMP($J,SUB,ORDER IEN,"RULES",ORDER CHECK RULE NAME)=""
+74 ; ^TMP($J,SUB,ORDER IEN,"GROUPS",ORDER CHECK GROUP NAME)=""
+75 ; ^TMP($J,SUB,ORDER IEN,"TX",N)=TEXT <= ORDER TEXT FROM EN^ORQ1
+76 ; ^TMP($J,SUB,ORDER IEN,"OI",OI)="Data from OIS^ORX8" <=ORDERABLE ITEMS
+77 ;
+78 ; For Reminder List Rule Sets:
+79 ; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE)=# OF PATIENTS
+80 ; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,DFN)=""
+81 ; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,DFN,"DATA",TYPE)=VALUE
+82 ; ^TMP($J,SUB,LIST RULE SET NAME,INSTANCE,"PATIENT LIST CREATED")=NAME OF PATIENT LIST, from file 810.4
+83 ;
+84 ; For Reminder Definitions:
+85 ; ^TMP($J,SUB,REMINDER)="STATUS^DUE DATE^LAST DONE"
+86 ; ^TMP($J,SUB,REMINDER,"PRINT NAME")=Reminder's print name (or name if print name is null)
+87 ; ^TMP($J,SUB,REMINDER,"FIEVAL")=
+88 ; Merged copy of the FIEVAL array
+89 ; ^TMP($J,SUB,REMINDER,"MAINTENANCE",X)=Line X of the maintenance output
+90 ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER)="STATUS^DUE DATE^LAST DONE"
+91 ; If REMINDER has the VA-REMINDER DEFINITION computed finding and its
+92 ; SAVETEMP parameter value is 1, then data for the COMPONENT REMINDER
+93 ; that is executed is returned under this node
+94 ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"FIEVAL")=
+95 ; Merged copy of the FIEVAL array for COMPONENT REMINDER that is
+96 ; executed as a finding, where COMPONENT REMINDER is the PRINT
+97 ; NAME of that reminder
+98 ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"MAINTENANCE",X)=
+99 ; Line X of the maintenance output for COMPONENT REMINDER that is
+100 ; executed as a finding, where COMPONENT REMINDER is the PRINT
+101 ; NAME of that reminder
+102 ;
+103 ; For Reminder Terms:
+104 ; ^TMP($J,SUB,"TERMS",NAME)=RESULT
+105 ; ^TMP($J,SUB,"TERMS","FIEVAL")=FIEVAL(ARRAY)
+106 ; ^TMP($J,SUB,"TERMS","DETAIL TEXT")=OUTPUT TEXT
+107 ; RESULT is either 1 for True or 0 for False
+108 ;
+109 ; INTERNAL INPUT ARRAY STRUCTURE
+110 ; DATA("ROC ORDERS",ORDER IEN (FILE 100))= SET TO ZERO NODE DOCUMENTED IN EN^ORQ1
+111 ; DATA("ROC ORDERS",ORDER IEN,"OI",OI)="" OI is the orderable item IEN (file 101.43) for the corresponding order
+112 ; DATA("ROC ORDERS",ORDER IEN,"PKG ID")=PACKAGE REFERENCE FIELD (#33)
+113 ; DATA("ROC ORDERS",ORDER IEN,"MODIFIERS",N)=EXTERNAL VALUE OF PROMPT WITH ID "MODIFIER"
+114 ; DATA("EVAL",TYPE,SUB,PIECE)=VALUE internal format used to updating reminder definition findings
+115 ; DATA("EVAL","EVAL DATE")=DATE internal format use to set the reminder evaluation date.
+116 ;
+117 NEW DGIENS,ORDLST,REMTYPE,SUB,DATA
+118 SET SUB=$GET(INPUT("SUB"))
IF SUB=""
QUIT
+119 KILL ^TMP($JOB,SUB)
+120 SET RESULT=$NAME(^TMP($JOB,SUB))
+121 SET @RESULT@(0)=0
+122 MERGE DATA=INPUT
+123 ;Perform INPUT array checks
+124 IF $$CINPUTS(.RESULT,.DATA)=1
QUIT
+125 IF $DATA(DATA("ROC ORDERS"))
DO GETOIS^PXRMGEVA(.DATA)
+126 IF $DATA(DATA("ROC DISPLAY GROUPS"))>0
Begin DoDot:1
+127 ; find display group IEN needed to find orders
+128 DO FINDDGS^PXRMGEVA(.RESULT,.DATA)
IF '$DATA(DATA("DG IEN"))
DO ERROR^PXRMGEVA(.RESULT,"No Display Group Found")
QUIT
+129 IF +$GET(@RESULT@(0))<0
QUIT
+130 ; find orders based off Display Groups and Status
+131 DO GTORDERS^PXRMGEVA(.DATA)
End DoDot:1
+132 IF +$GET(@RESULT@(0))<0
QUIT
+133 DO REM^PXRMGEVA(.RESULT,.DATA)
+134 IF $DATA(DATA("SUB"))=10
SET RESULT=$NAME(^TMP($JOB))
+135 QUIT
+136 ;
CINPUTS(RESULT,INPUT) ;
+1 NEW DGIEN,FAIL,GNAME,NAME,NODE,RETTYPE,ROC,ROCIENS,ROCTYPE,RIEN,TIEN,%DT,X,Y,INSTANCE
+2 IF '$DATA(INPUT("ROC"))
IF '$DATA(INPUT("REMINDERS"))
IF '$DATA(INPUT("LR"))
IF '$DATA(INPUT("TERMS"))
DO ERROR^PXRMGEVA(.RESULT,"No reminders items defined")
QUIT 1
+3 IF $DATA(INPUT("ROC"))!($DATA(INPUT("REMINDERS"))!($DATA(INPUT("TERMS"))))
Begin DoDot:1
+4 IF +$GET(INPUT("DFN"))<1
DO ERROR^PXRMGEVA(.RESULT,"Patient is not properly defined")
QUIT
+5 IF '$DATA(^DPT(INPUT("DFN"),0))
DO ERROR^PXRMGEVA(.RESULT,"Invalid patient specified")
QUIT
End DoDot:1
IF +$GET(@RESULT@(0))<0
QUIT 1
+6 ;check order checks array
+7 IF $DATA(INPUT("ROC"))
Begin DoDot:1
+8 SET ROCTYPE=""
SET ROCTYPE("VALID")=0
FOR
SET ROCTYPE=$ORDER(INPUT("ROC RETURN TYPE",ROCTYPE))
if ROCTYPE=""
QUIT
Begin DoDot:2
+9 IF "^GROUPS^RULES^GROUPS/RULES^OI^"'[(U_ROCTYPE_U)
DO ERROR^PXRMGEVA(.RESULT,"Return type must be either GROUPS, RULES, GROUPS/RULES, or OI.")
QUIT
+10 IF "^GROUPS^RULES^GROUPS/RULES^"[(U_ROCTYPE_U)
SET ROCTYPE("VALID")=1
End DoDot:2
+11 if +$GET(@RESULT@(0))<0
QUIT
+12 IF 'ROCTYPE("VALID")
DO ERROR^PXRMGEVA(.RESULT,"A return type of either GROUPS, RULES or GROUPS/RULES is required.")
QUIT
+13 IF $DATA(INPUT("ROC ORDERS"))
IF $DATA(INPUT("ROC DISPLAY GROUPS"))
DO ERROR^PXRMGEVA(.RESULT,"Cannot search for both Orders and Display Groups")
QUIT
+14 IF $DATA(INPUT("ROC ORDERS"))
QUIT
+15 IF '$DATA(INPUT("ROC STATUS"))
DO ERROR^PXRMGEVA(.RESULT,"No statuses or search criteria defined")
QUIT
+16 IF '$DATA(INPUT("ROC DISPLAY GROUPS"))
DO ERROR^PXRMGEVA(.RESULT,"No Display Groups define")
+17 SET FAIL=0
+18 IF $DATA(INPUT("ROC ORDERED WITHIN"))
Begin DoDot:2
+19 SET DGIEN=0
FOR
SET DGIEN=$ORDER(INPUT("ROC DISPLAY GROUPS",DGIEN))
if DGIEN'>0!(FAIL=1)
QUIT
Begin DoDot:3
+20 IF +$GET(INPUT("ROC DISPLAY GROUPS",DGIEN,"START"))=0
SET FAIL=1
QUIT
+21 IF +$GET(INPUT("ROC DISPLAY GROUPS",DGIEN,"STOP"))=0
SET FAIL=1
QUIT
End DoDot:3
End DoDot:2
+22 IF FAIL=1
DO ERROR^PXRMGEVA(.RESULT,"No search date range defined")
QUIT
+23 IF '$DATA(INPUT("ROC","ALL"))
Begin DoDot:2
+24 SET GNAME=""
FOR
SET GNAME=$ORDER(INPUT("ROC",GNAME))
if GNAME=""!(FAIL=1)
QUIT
Begin DoDot:3
+25 IF '$DATA(^PXD(801,"B",GNAME))
DO ERROR^PXRMGEVA(.RESULT,"Reminder Order Check Group: "_GNAME_" not found")
SET FAIL=1
End DoDot:3
End DoDot:2
End DoDot:1
IF +$GET(@RESULT@(0))<0
QUIT 1
+26 ;check list rule array
+27 IF $DATA(INPUT("LR"))
Begin DoDot:1
+28 SET NAME=""
FOR
SET NAME=$ORDER(INPUT("LR",NAME))
if NAME=""
QUIT
Begin DoDot:2
+29 SET RIEN=0
+30 IF NAME'?1.N
SET RIEN=+$ORDER(^PXRM(810.4,"B",$EXTRACT(NAME,1,96),0))
+31 IF NAME?1.N
SET RIEN=NAME
+32 IF ('RIEN)!('$DATA(^PXRM(810.4,RIEN,0)))
DO ERROR^PXRMGEVA(.RESULT,"Reminder list rule/rule set """_NAME_""" does not exist")
QUIT
+33 IF $PIECE($GET(^PXRM(810.4,RIEN,0)),U,3)'=3
DO ERROR^PXRMGEVA(.RESULT,""""_NAME_""" is not a reminder list rule set")
QUIT
+34 SET INPUT("LR",NAME,"IEN")=RIEN
+35 SET INSTANCE=""
FOR
SET INSTANCE=$ORDER(INPUT("LR",NAME,INSTANCE))
if '+INSTANCE
QUIT
Begin DoDot:3
+36 SET NODE=$GET(INPUT("LR",NAME,INSTANCE))
+37 IF $PIECE(NODE,U)=""
DO ERROR^PXRMGEVA(.RESULT,"Patient List Name not defined for """_NAME_""" instance "_INSTANCE)
QUIT
+38 IF $PIECE(NODE,U,2)=""
DO ERROR^PXRMGEVA(.RESULT,"Start Date not defined for """_NAME_""" instance "_INSTANCE)
QUIT
+39 IF $PIECE(NODE,U,3)=""
DO ERROR^PXRMGEVA(.RESULT,"End Date not defined for """_NAME_""" instance "_INSTANCE)
QUIT
+40 IF $PIECE(NODE,U,4)=""
DO ERROR^PXRMGEVA(.RESULT,"Secure not defined for """_NAME_""" instance "_INSTANCE)
QUIT
+41 IF $PIECE(NODE,U,5)=""
DO ERROR^PXRMGEVA(.RESULT,"Overwrite not defined for """_NAME_""" instance "_INSTANCE)
End DoDot:3
End DoDot:2
End DoDot:1
IF +$GET(@RESULT@(0))<0
QUIT 1
+42 ;check reminder definitions array
+43 IF $DATA(INPUT("REMINDERS"))
Begin DoDot:1
+44 SET NAME=""
FOR
SET NAME=$ORDER(INPUT("REMINDERS",NAME))
if NAME=""
QUIT
Begin DoDot:2
+45 SET RIEN=0
+46 IF NAME'?1.N
Begin DoDot:3
+47 SET RIEN=+$ORDER(^PXD(811.9,"B",$EXTRACT(NAME,1,64),0))
if RIEN>0
QUIT
+48 SET RIEN=+$ORDER(^PXD(811.9,"D",$EXTRACT(NAME,1,35),0))
End DoDot:3
+49 IF NAME?1.N
SET RIEN=NAME
+50 IF ('RIEN)!('$DATA(^PXD(811.9,RIEN,0)))
DO ERROR^PXRMGEVA(.RESULT,"Reminder definition does not exist")
QUIT
+51 IF $PIECE($GET(^PXD(811.9,RIEN,0)),U,6)=1
DO ERROR^PXRMGEVA(.RESULT,"The reminder definition is inactive")
QUIT
+52 SET INPUT("REMINDERS",RIEN)=NAME_U_INPUT("REMINDERS",NAME)
+53 IF NAME'=RIEN
KILL INPUT("REMINDERS",NAME)
+54 SET NODE=$GET(INPUT("REMINDERS",RIEN))
if NODE=""
QUIT
+55 IF "^0^1^"'[(U_$PIECE(NODE,U,2)_U)
DO ERROR^PXRMGEVA(.RESULT,"Invalid SAVE_FIEVAL flag; set it to either 0 or 1")
QUIT
+56 IF $PIECE(NODE,U,4)'=""
Begin DoDot:3
+57 SET %DT=""
SET X=$PIECE(NODE,U,4)
+58 DO ^%DT
+59 IF Y=-1
DO ERROR^PXRMGEVA(.RESULT,"Invalid value for TODAY")
QUIT
+60 SET $PIECE(INPUT("REMINDERS",RIEN),U,4)=Y
End DoDot:3
End DoDot:2
End DoDot:1
IF +$GET(@RESULT@(0))<0
QUIT 1
+61 ;check reminder terms array
+62 IF $DATA(INPUT("TERMS"))
Begin DoDot:1
+63 SET NAME=""
FOR
SET NAME=$ORDER(INPUT("TERMS",NAME))
if NAME=""
QUIT
Begin DoDot:2
+64 SET NODE=INPUT("TERMS",NAME)
+65 SET TIEN=0
+66 IF NAME'?1.N
SET TIEN=+$ORDER(^PXRMD(811.5,"B",$EXTRACT(NAME,1,64),0))
SET RETTYPE="NAME"
+67 IF NAME?1.N
SET TIEN=NAME
SET RETTYPE="IEN"
+68 IF ('TIEN)!('$DATA(^PXRMD(811.5,TIEN,0)))
DO ERROR^PXRMGEVA(.RESULT,"Reminder term """_NAME_"""does not exist")
QUIT
+69 SET INPUT("TERMS",TIEN)=NAME_U_NODE_U_RETTYPE
+70 IF NAME'=TIEN
KILL INPUT("TERMS",NAME)
End DoDot:2
End DoDot:1
IF +$GET(@RESULT@(0))<0
QUIT 1
+71 QUIT 0
+72 ;