Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PXRMGEV

PXRMGEV.m

Go to the documentation of this file.
  1. PXRMGEV ;SLC/AGP,RFR - Generic entry point to run different Reminder Evaluation ;Apr 07, 2021@13:57
  1. ;;2.0;CLINICAL REMINDERS;**45,71**;Feb 04, 2005;Build 43
  1. Q
  1. ;
  1. EN(RESULT,INPUT) ;
  1. ; INPUT
  1. ; INPUT("SUB")=Temp Global Subscript
  1. ;
  1. ; For Reminder Order Checks:
  1. ; INPUT("DFN")=DFN The patient to perform orders checks on.
  1. ; INPUT("ROC START")=START Date to start searching for orders; applies to all orders.
  1. ; INPUT("ROC STOP")=STOP Date to stop search for orders; applies to all orders.
  1. ; INPUT("ROC DISPLAY GROUPS",DG)="" Array of Display Group Names used in searching for orders.
  1. ; INPUT("ROC DISPLAY GROUPS",DG,"START")=START
  1. ; Date to start searching for orders; applies to orders with this
  1. ; display group and overrides "ROC START".
  1. ; INPUT("ROC DISPLAY GROUPS",DG,"STOP")=STOP
  1. ; Date to stop searching for orders; applies to orders with this
  1. ; display group and overrides "ROC STOP".
  1. ; INPUT("ROC STATUS",STATUS)="" Array of order status(es) used in searching for orders.
  1. ; INPUT("ROC ORDERED WITHIN")="" Flag indicating order date should fall between START and STOP; used
  1. ; in searching for orders.
  1. ; INPUT("ROC ORDERS",ORDERIEN)="" Array of orders to evaluate Reminder Order Checks for. If defined,
  1. ; the inputs of "ROC START", "ROC STOP", "ROC DISPLAY GROUPS",
  1. ; "ROC STATUS" and "ROC ORDERED WITHIN" are not needed.
  1. ; INPUT("ROC",ROC)="" Array of Reminder Order Check Groups to check for.
  1. ; If ROC is ALL, run against ALL order checks.
  1. ; INPUT("ROC RETURN TYPE","GROUPS")="" for groups
  1. ; ,"RULES")="" for rules
  1. ; ,"OI")="" for orderable items
  1. ;
  1. ; For Reminder List Rules:
  1. ; INPUT("LR",LIST RULE NAME)=PNAME^START DATE^END DATE^SECURE^OVERWRITE^RETURN DATA
  1. ; LIST RULE NAME Name of the List Rule to evaluate file 810.4
  1. ; PNAME Name of the Patient List to create file 810.5
  1. ; SECURE 1 or 0 should the list be secure
  1. ; OVERWRITE 1 or 0 if an existing patient list with the same name should be overwritten
  1. ; START DATE FM date to start the list rule from
  1. ; END DATE FM date to end the list rule from
  1. ; RETURN DATA 1 or 0 to determine if data should be return with the patient
  1. ;
  1. ; For Reminder Definitions:
  1. ; INPUT("DFN")=DFN The patient to execute the reminder definition for.
  1. ; INPUT("REMINDERS",REMINDER)=SAVE_FIEVAL^MAINTENANCE_FORMAT^TODAY
  1. ; REMINDER Reminder definition to execute; either the definition's IEN,
  1. ; NAME or PRINT NAME
  1. ; SAVE_FIEVAL Copy the FIEVAL array into the return TMP global (boolean flag)
  1. ; MAINTENANCE_FORMAT How to format the maintenance section that is copied into the return TMP
  1. ; global; see the description for the OUTPUT parameter in the MAIN^PXRM
  1. ; line tag for acceptable values
  1. ; TODAY Date to use for evaluation in FileMan format
  1. ;
  1. ; OUTPUT
  1. ; ^TMP($J,SUB,0)=-1^ERROR MESSAGE There is a problem with the INPUT array.
  1. ; ^TMP($J,SUB,0)=1 There is data in the OUTPUT.
  1. ; ^TMP($J,SUB,0)=0 There is no data in the OUTPUT.
  1. ;
  1. ; For Reminder Order Checks:
  1. ; ^TMP($J,SUB,ORDER IEN)="Details from EN^ORQ1"^CURRENT AGENT/PROVIDER
  1. ; ^TMP($J,SUB,ORDER IEN,"RULES",ORDER CHECK RULE NAME)=""
  1. ; ^TMP($J,SUB,ORDER IEN,"GROUPS",ORDER CHECK GROUP NAME)=""
  1. ; ^TMP($J,SUB,ORDER IEN,"TX",N)=TEXT <= ORDER TEXT FROM EN^ORQ1
  1. ; ^TMP($J,SUB,ORDER IEN,"OI",OI)="Data from OIS^ORX8" <=ORDERABLE ITEMS
  1. ;
  1. ; For Reminder List Rules:
  1. ; ^TMP($J,SUB,LIST RULE NAME,DFN)=""
  1. ; ^TMP($J,SUB,RULE,DFN,"DATA",TYPE)=VALUE
  1. ; ^TMP($J,SUB,LIST RULE NAME,"PATIENT LIST CREATED")=NAME OF PATIENT LIST, from file 810.4
  1. ;
  1. ; For Reminder Definitions:
  1. ; ^TMP($J,SUB,REMINDER)="STATUS^DUE DATE^LAST DONE"
  1. ; ^TMP($J,SUB,REMINDER,"PRINT NAME")=Reminder's print name (or name if print name is null)
  1. ; ^TMP($J,SUB,REMINDER,"FIEVAL")=
  1. ; Merged copy of the FIEVAL array
  1. ; ^TMP($J,SUB,REMINDER,"MAINTENANCE",X)=Line X of the maintenance output
  1. ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER)="STATUS^DUE DATE^LAST DONE"
  1. ; If REMINDER has the VA-REMINDER DEFINITION computed finding and its
  1. ; SAVETEMP parameter value is 1, then data for the COMPONENT REMINDER
  1. ; that is executed is returned under this node
  1. ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"FIEVAL")=
  1. ; Merged copy of the FIEVAL array for COMPONENT REMINDER that is
  1. ; executed as a finding, where COMPONENT REMINDER is the PRINT
  1. ; NAME of that reminder
  1. ; ^TMP($J,SUB,REMINDER,"FINDINGS",COMPONENT REMINDER,"MAINTENANCE",X)=
  1. ; Line X of the maintenance output for COMPONENT REMINDER that is
  1. ; executed as a finding, where COMPONENT REMINDER is the PRINT
  1. ; NAME of that reminder
  1. ;
  1. ; INTERNAL INPUT ARRAY STRUCTURE
  1. ; DATA("ROC ORDERS",ORDER IEN (FILE 100))= SET TO ZERO NODE DOCUMENTED IN EN^ORQ1
  1. ; DATA("ROC ORDERS",ORDER IEN,"OI",OI)="" OI is the orderable item IEN (file 101.43) for the corresponding order
  1. ; DATA("ROC ORDERS",ORDER IEN,"PKG ID")=PACKAGE REFERENCE FIELD (#33)
  1. ; DATA("ROC ORDERS",ORDER IEN,"MODIFIERS",N)=EXTERNAL VALUE OF PROMPT WITH ID "MODIFIER"
  1. ; DATA("EVAL",TYPE,SUB,PIECE)=VALUE internal format used to updating reminder definition findings
  1. ; DATA("EVAL","EVAL DATE")=DATE internal format use to set the reminder evaluation date.
  1. ;
  1. N DGIENS,ORDLST,REMTYPE,SUB,DATA
  1. S SUB=$G(INPUT("SUB")) I SUB="" Q
  1. K ^TMP($J,SUB)
  1. S RESULT=$NA(^TMP($J,SUB))
  1. S @RESULT@(0)=0
  1. M DATA=INPUT
  1. ;Perform INPUT array checks
  1. I $$CINPUTS(.RESULT,.DATA)=1 Q
  1. I $D(DATA("ROC ORDERS")) D GETOIS^PXRMGEVA(.DATA)
  1. I $D(DATA("ROC DISPLAY GROUPS"))>0 D
  1. .; find display group IEN needed to find orders
  1. .D FINDDGS^PXRMGEVA(.RESULT,.DATA) I '$D(DATA("DG IEN")) D ERROR^PXRMGEVA(.RESULT,"No Display Group Found") Q
  1. .I +$G(@RESULT@(0))<0 Q
  1. .; find orders based off Display Groups and Status
  1. .D GTORDERS^PXRMGEVA(.DATA)
  1. I +$G(@RESULT@(0))<0 Q
  1. D REM^PXRMGEVA(.RESULT,.DATA)
  1. Q
  1. ;
  1. CINPUTS(RESULT,INPUT) ;
  1. N DGIEN,FAIL,GNAME,NAME,NODE,ROC,ROCIENS,ROCTYPE,RIEN,%DT,X,Y
  1. I '$D(INPUT("ROC")),'$D(INPUT("REMINDERS")),'$D(INPUT("LR")) D ERROR^PXRMGEVA(.RESULT,"No reminders items defined") Q 1
  1. I '$D(INPUT("LR")) D I +$G(@RESULT@(0))<0 Q 1
  1. .I +$G(INPUT("DFN"))<0 D ERROR^PXRMGEVA(.RESULT,"Patient is not properly defined") Q
  1. .I '$D(^DPT(INPUT("DFN"),0)) D ERROR^PXRMGEVA(.RESULT,"Invalid patient specified") Q
  1. ;check order checks array
  1. I $D(INPUT("ROC")) D I +$G(@RESULT@(0))<0 Q 1
  1. .S ROCTYPE="",ROCTYPE("VALID")=0 F S ROCTYPE=$O(INPUT("ROC RETURN TYPE",ROCTYPE)) Q:ROCTYPE="" D
  1. ..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
  1. ..I "^GROUPS^RULES^GROUPS/RULES^"[(U_ROCTYPE_U) S ROCTYPE("VALID")=1
  1. .Q:+$G(@RESULT@(0))<0
  1. .I 'ROCTYPE("VALID") D ERROR^PXRMGEVA(.RESULT,"A return type of either GROUPS, RULES or GROUPS/RULES is required.") Q
  1. .I $D(INPUT("ROC ORDERS")),$D(INPUT("ROC DISPLAY GROUPS")) D ERROR^PXRMGEVA(.RESULT,"Cannot search for both Orders and Display Groups") Q
  1. .I $D(INPUT("ROC ORDERS")) Q
  1. .I '$D(INPUT("ROC STATUS")) D ERROR^PXRMGEVA(.RESULT,"No statuses or search criteria defined") Q
  1. .I '$D(INPUT("ROC DISPLAY GROUPS")) D ERROR^PXRMGEVA(.RESULT,"No Display Groups define")
  1. .S FAIL=0
  1. .I $D(INPUT("ROC ORDERED WITHIN")) D
  1. ..S DGIEN=0 F S DGIEN=$O(INPUT("ROC DISPLAY GROUPS",DGIEN)) Q:DGIEN'>0!(FAIL=1) D
  1. ...I +$G(INPUT("ROC DISPLAY GROUPS",DGIEN,"START"))=0 S FAIL=1 Q
  1. ...I +$G(INPUT("ROC DISPLAY GROUPS",DGIEN,"STOP"))=0 S FAIL=1 Q
  1. .I FAIL=1 D ERROR^PXRMGEVA(.RESULT,"No search date range defined") Q
  1. .I '$D(INPUT("ROC","ALL")) D
  1. ..S GNAME="" F S GNAME=$O(INPUT("ROC",GNAME)) Q:GNAME=""!(FAIL=1) D
  1. ...I '$D(^PXD(801,"B",GNAME)) D ERROR^PXRMGEVA(.RESULT,"Reminder Order Check Group: "_GNAME_" not found") S FAIL=1
  1. ;check list rule array
  1. I $D(INPUT("LR")) D I +$G(@RESULT@(0))<0 Q 1
  1. . S NAME="" F S NAME=$O(INPUT("LR",NAME)) Q:NAME="" D
  1. . .S NODE=$G(INPUT("LR",NAME))
  1. . .I $P(NODE,U)="" D ERROR^PXRMGEVA(.RESULT,"Patient List Name not define") Q
  1. . .I $P(NODE,U,2)="" D ERROR^PXRMGEVA(.RESULT,"Start Date not define") Q
  1. . .I $P(NODE,U,3)="" D ERROR^PXRMGEVA(.RESULT,"End Date not define") Q
  1. . .I $P(NODE,U,4)="" D ERROR^PXRMGEVA(.RESULT,"Secure not define") Q
  1. . .I $P(NODE,U,5)="" D ERROR^PXRMGEVA(.RESULT,"Overwrite not define")
  1. ;check reminder definitions array
  1. I $D(INPUT("REMINDERS")) D I +$G(@RESULT@(0))<0 Q 1
  1. .S NAME="" F S NAME=$O(INPUT("REMINDERS",NAME)) Q:NAME="" D
  1. ..S RIEN=0
  1. ..I NAME'?1.N D
  1. ...S RIEN=+$O(^PXD(811.9,"B",$E(NAME,1,64),0)) Q:RIEN>0
  1. ...S RIEN=+$O(^PXD(811.9,"D",$E(NAME,1,35),0))
  1. ..I NAME?1.N S RIEN=NAME
  1. ..I ('RIEN)!('$D(^PXD(811.9,RIEN,0))) D ERROR^PXRMGEVA(.RESULT,"Reminder definition does not exist") Q
  1. ..I $P($G(^PXD(811.9,RIEN,0)),U,6)=1 D ERROR^PXRMGEVA(.RESULT,"The reminder definition is inactive") Q
  1. ..S INPUT("REMINDERS",RIEN)=NAME_U_INPUT("REMINDERS",NAME)
  1. ..I NAME'=RIEN K INPUT("REMINDERS",NAME)
  1. ..S NODE=$G(INPUT("REMINDERS",RIEN)) Q:NODE=""
  1. ..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
  1. ..I $P(NODE,U,4)'="" D
  1. ...S %DT="",X=$P(NODE,U,4)
  1. ...D ^%DT
  1. ...I Y=-1 D ERROR^PXRMGEVA(.RESULT,"Invalid value for TODAY") Q
  1. ...S $P(INPUT("REMINDERS",RIEN),U,4)=Y
  1. Q 0
  1. ;