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

PXRMGEVA.m

Go to the documentation of this file.
PXRMGEVA ;SLC/AGP,RFR - Generic entry point to run different Reminder Evaluation ;Jan 13, 2023@17:06
 ;;2.0;CLINICAL REMINDERS;**45,71,84**;Feb 04, 2005;Build 2
 ;
 ; Reference to OIS^ORX8 in ICR #2467
 ; Reference to EN^ORQ1 in ICR #3154
 ; Reference to EN^ORX8 in ICR #871
 ; Reference to PKGID^ORX8 in ICR #3071
 ; Reference to VALUE^ORX8 in ICR #2467
 ; Reference to ^ORD(100.98,"B", in ICR #873
 ; 
ERROR(RESULT,MSG) ;
 S @RESULT@(0)=-1_U_MSG
 Q
 ;
FINDDGS(RESULT,INPUT) ;
 N FAIL,IEN,NAME
 S NAME="",FAIL=0 F  S NAME=$O(INPUT("ROC DISPLAY GROUPS",NAME)) Q:NAME=""!(FAIL>0)  D
 .S IEN=$O(^ORD(100.98,"B",NAME,"")) I IEN'>0 D ERROR(.RESULT,"Could not find Display Group: "_NAME) S FAIL=1
 .S INPUT("DG IEN",IEN)=""
 .S INPUT("DG IEN",IEN,"START")=+$G(INPUT("ROC DISPLAY GROUPS",NAME,"START"))
 .S INPUT("DG IEN",IEN,"STOP")=+$G(INPUT("ROC DISPLAY GROUPS",NAME,"STOP"))
 Q
 ;
GETOIS(INPUT) ; find orderable items for each order
 N CNT,NUM,ARRAY,OI,ORDIEN,POS,PXRMOIS
 S ORDIEN=0 F  S ORDIEN=$O(INPUT("ROC ORDERS",ORDIEN)) Q:ORDIEN'>0  D
 .K PXRMOIS D OIS^ORX8(.PXRMOIS,ORDIEN) I '$D(PXRMOIS) Q
 .M INPUT("ROC ORDERS",ORDIEN,"OI")=PXRMOIS
 Q
 ;
GTORDERS(INPUT) ;
 N DIEN,DATE,END,NODE,PAT,ORDIEN,ORN,PXRMOIS,START,STOP,ORLIST,MOD,PXRMINST,ORUPCHUK
 S PAT=$G(INPUT("DFN"))
 S DIEN=0 F  S DIEN=$O(INPUT("DG IEN",DIEN)) Q:DIEN'>0  D
 .K ^TMP("ORR",$J)
 .S START=$S(INPUT("DG IEN",DIEN,"START")>0:INPUT("DG IEN",DIEN,"START"),1:$G(INPUT("ROC START")))
 .S STOP=$S(INPUT("DG IEN",DIEN,"STOP")>0:INPUT("DG IEN",DIEN,"STOP"),1:$G(INPUT("ROC STOP")))
 .;call for current activities
 .D EN^ORQ1(PAT_";DPT(",DIEN,1,,START,STOP,1)
 .S DATE="" F  S DATE=$O(^TMP("ORR",$J,DATE)) Q:DATE=""  D
 ..F ORN=1:1:$G(^TMP("ORR",$J,DATE,"TOT"))  D
 ...S NODE=$G(^TMP("ORR",$J,DATE,ORN))
 ...I $D(INPUT("ROC ORDERS",+$P(NODE,U))) Q
 ...I ('$D(INPUT("ROC STATUS","*"))&('$D(INPUT("ROC STATUS",$P(NODE,U,6))))) Q
 ...I $D(INPUT("ROC ORDERED WITHIN"))&(($P(NODE,U,3)<START)!($P(NODE,U,3)>STOP)) Q
 ...S ORDIEN=+$P(NODE,U)
 ...D EN^ORX8(ORDIEN)
 ...S NODE=NODE_U_$P(ORUPCHUK("ORNP"),U)
 ...K ORUPCHUK
 ...S INPUT("ROC ORDERS",ORDIEN)=NODE
 ...M INPUT("ROC ORDERS",ORDIEN,"TX")=^TMP("ORR",$J,DATE,ORN,"TX")
 ...S INPUT("ROC ORDERS",ORDIEN,"PKG ID")=$$PKGID^ORX8(ORDIEN)
 ...F PXRMINST=1:1  S MOD=$$VALUE^ORX8(ORDIEN,"MODIFIER",PXRMINST,"E") Q:MOD=""  D
 ....S INPUT("ROC ORDERS",ORDIEN,"MODIFIERS",PXRMINST)=MOD
 ...K PXRMOIS D OIS^ORX8(.PXRMOIS,ORDIEN)
 ...I $D(PXRMOIS) M INPUT("ROC ORDERS",ORDIEN,"OI")=PXRMOIS
 K ^TMP("ORR",$J)
 Q
 ;
GETVAL(INPUT,TYPE) ;
 Q $G(INPUT("VARIABLES",TYPE))
 ;
REM(RESULT,INPUT) ; controller for reminder evaluation types
 I $D(INPUT("LR")) D REMLIST(.RESULT,.INPUT) Q
 I $D(INPUT("REMINDERS")) D REMEVAL(.RESULT,.INPUT) Q
 D REMOC(.RESULT,.INPUT)
 Q
 ;
REMMDEF(INPUT,DEFARR) ; update DEFARR with modifiers
 N ITEM,NUM,SUB,PIECE,TEMP,VALUE
 S NUM=0 F  S NUM=$O(DEFARR(20,NUM)) Q:NUM'>0  D
 .S ITEM=$P($G(DEFARR(20,NUM,0)),U) I ITEM="" Q
 .I '$D(INPUT("EVAL","FINDINGS",ITEM)) Q
 .S SUB="" F  S SUB=$O(INPUT("EVAL","FINDINGS",ITEM,SUB)) Q:SUB=""  D
 ..S PIECE=0 F  S PIECE=$O(INPUT("EVAL","FINDINGS",ITEM,SUB,PIECE)) Q:PIECE'>0  D
 ...S VALUE=$G(INPUT("EVAL","FINDINGS",ITEM,SUB,PIECE)) I VALUE="" Q
 ...I VALUE["$$" S TEMP="S VALUE="_VALUE X TEMP
 ...S $P(DEFARR(20,NUM,SUB),U,PIECE)=VALUE
 I $G(INPUT("EVAL","EVAL DATE"))["$$" D  Q
 .S TEMP="S VALUE="_INPUT("EVAL","EVAL DATE") X TEMP
 .S INPUT("EVAL","NEW EVAL DATE")=VALUE
 Q
 ;
REMEVAL(RESULT,INPUT) ;
 N RIEN,FIEVAL,TODAY,OUTTYPE,PNAME,ONAME,PXRMSRCFF
 S PXRMSRCFF=1
 K ^TMP("PXRHM",$J)
 S RIEN=0 F  S RIEN=$O(INPUT("REMINDERS",RIEN)) Q:'+RIEN  D
 .S ONAME=$P(INPUT("REMINDERS",RIEN),U),FIEVAL=$P(INPUT("REMINDERS",RIEN),U,2)
 .S OUTTYPE=+$P(INPUT("REMINDERS",RIEN),U,3),TODAY=+$P(INPUT("REMINDERS",RIEN),U,4)
 .D MAINDF(INPUT("DFN"),RIEN,OUTTYPE,TODAY,FIEVAL)
 .S PNAME=$P($G(^PXD(811.9,RIEN,0)),U,3)
 .I PNAME="" S PNAME=$P($G(^PXD(811.9,RIEN,0)),U)
 .S @RESULT@(ONAME)=$G(^TMP("PXRHM",$J,RIEN,PNAME))
 .S @RESULT@(ONAME,"PRINT NAME")=PNAME
 .I FIEVAL M @RESULT@(ONAME,"FIEVAL")=^TMP("PXRHM",$J,RIEN,"FIEVAL")
 .I OUTTYPE>0 M @RESULT@(ONAME,"MAINTENANCE")=^TMP("PXRHM",$J,RIEN,PNAME,"TXT")
 .K ^TMP("PXRHM",$J)
 .I $D(^TMP("PXRM BL DATA",$J)) D
 ..S RIEN("C")=$G(^TMP("PXRM BL DATA",$J,"REMINDER IEN"))
 ..S PNAME=$G(^TMP("PXRM BL DATA",$J,"REMINDER NAME"))
 ..I RIEN("C")=""!(PNAME="") Q
 ..S @RESULT@(ONAME,"FINDINGS",PNAME)=$G(^TMP("PXRM BL DATA",$J,"PXRHM",RIEN("C"),PNAME))
 ..I FIEVAL M @RESULT@(ONAME,"FINDINGS",PNAME,"FIEVAL")=^TMP("PXRM BL DATA",$J,"FIEVAL")
 ..I OUTTYPE>0 M @RESULT@(ONAME,"FINDINGS",PNAME,"MAINTENANCE")=^TMP("PXRM BL DATA",$J,"PXRHM",RIEN("C"),PNAME,"TXT")
 ..K ^TMP("PXRM BL DATA",$J)
 Q
 ;
MAINDF(DFN,PXRMITEM,OUTTYPE,EVALDT,SAVEFIE) ;
 N DEFARR,FIEVAL,REMCFIEN,MESSAGE,FINDING
 D DEF^PXRMLDR(PXRMITEM,.DEFARR)
 I OUTTYPE>0 D
 .S REMCFIEN=+$O(^PXRMD(811.4,"B","VA-REMINDER DEFINITION","")) Q:REMCFIEN<1
 .S FINDING=0 F  S FINDING=+$O(DEFARR("E","PXRMD(811.4,",REMCFIEN,FINDING)) Q:'+FINDING  S $P(DEFARR(20,FINDING,15),U,4)=OUTTYPE
 I $G(EVALDT)?7N S SAVEFIE=1 ;MAINDF^PXRM, which allows passing evaluation date, always saved the FIEVAL array
 E  S EVALDT=$$NOW^XLFDT
 D EVAL^PXRM(DFN,.DEFARR,OUTTYPE,0,.FIEVAL,EVALDT)
 I $G(SAVEFIE) M ^TMP("PXRHM",$J,PXRMITEM,"FIEVAL")=FIEVAL
 Q
 ;
REMLIST(RESULT,INPUT) ;
 N BEG,END,CNT,DATA,DATANAM,DATAVAL,FAIL,INC,LIEN,LNAME,NODE,NUM,OVER,PAT,PFNAME,PNAME,PLIST,PATCREAT,RETDATA,SECURE
 S LNAME="",FAIL=0 F  S LNAME=$O(INPUT("LR",LNAME)) Q:LNAME=""!(FAIL=1)  D
 .K BEG,END,LIEN,PFNAME,PNAME,PLIST,SECURE,OVER,RETDATA
 .S LIEN=+$O(^PXRM(810.4,"B",LNAME,"")) I LIEN'>0 D ERROR(.RESULT,"List Rule: "_LNAME_" not found") S FAIL=1 Q
 .S NODE=$G(INPUT("LR",LNAME)),PNAME=$P(NODE,U),BEG=$P(NODE,U,2),END=$P(NODE,U,3),SECURE=$P(NODE,U,4),OVER=$P(NODE,U,5),RETDATA=+$P(NODE,U,6)
 .S PLIST=$$REMPLCRE(PNAME,SECURE,OVER) I +PLIST'>0 D ERROR(.RESULT,"Error could not find or create patient list "_PLNAME) S FAIL=1 Q
 .S PFNAME=$P(PLIST,U,2)
 .D RUN^PXRMLCR(LIEN,+PLIST,"PXRMRULE",BEG,END,0,1)
 .I '$D(^PXRMXP(810.5,+PLIST,30)) Q
 .S NUM=0 F  S NUM=$O(^PXRMXP(810.5,+PLIST,30,NUM)) Q:NUM'>0  D
 ..S PAT=$P($G(^PXRMXP(810.5,+PLIST,30,NUM,0)),U) I PAT="" Q
 ..S @RESULT@(LNAME,PAT)=""
 ..I RETDATA=0 Q
 ..S CNT=0 F  S CNT=$O(^PXRMXP(810.5,+PLIST,30,NUM,"DATA",CNT)) Q:CNT'>0  D
 ...S DATA=$G(^PXRMXP(810.5,+PLIST,30,NUM,"DATA",CNT,0)) I DATA="" Q
 ...S DATANAM=$P($P(DATA,U),",",2),DATAVAL=$P(DATA,U,2) I DATANAM="" Q
 ...S @RESULT@(LNAME,PAT,"DATA",DATANAM)=DATAVAL
 .S @RESULT@(LNAME,"PATIENT LIST CREATED")=PFNAME
 .S @RESULT@(0)=1
 Q
 ;
REMPLCRE(PLNAME,SECURE,OVER) ;
 N FDA,IENS,NAME,NUM,RESULT,UNIQUE
 S (NUM,RESULT,UNIQUE)=0
 ;if overwrite check to see if the list exist
 I OVER=1 S RESULT=$O(^PXRMXP(810.5,"B",PLNAME,""))
 I RESULT>0 Q RESULT
 S NAME=PLNAME
 ;if not overwrite find unique and name exist create unique name
 I OVER=0,$D(^PXRMXP(810.5,"B",NAME))>0 D
 .F  Q:UNIQUE=1  D
 ..S NAME=PLNAME_" ("_$$NOW^XLFDT()_")"
 ..I $D(^PXRMXP(810.5,"B",NAME))=0 S UNIQUE=1 Q
 ..H 1
 ;create stub in 810.5
 S IENS="?+1,"
 S FDA(810.5,IENS,.01)=NAME,FDA(810.5,IENS,100)="L",FDA(810.5,IENS,.07)=DUZ,FDA(810.5,IENS,.08)=$S(SECURE=0:"PUB",1:"PVT")
 D UPDATE^DIE("","FDA","","MSG")
 ;if error display message and quit
 I $D(MSG) Q 0
 S RESULT=$O(^PXRMXP(810.5,"B",NAME,""))
 Q RESULT_U_NAME
 ;
REMOC(RESULT,INPUT) ; controller for reminder order checks
 N DISPLAY,FOUND,GROUPS,NUM,OI,OINAME,ORDIEN,PAT,PNAME,SEV,STATUS,RNAME,RIEN,GNAME,OIGROUPS
 I '$D(INPUT("ROC","ALL")) M GROUPS=INPUT("ROC")
 I '$D(INPUT("ROC ORDERS")) Q
 S PAT=$G(INPUT("DFN"))
 S STATUS=0
 ;loop through orders
 S ORDIEN=0,FOUND=0 F  S ORDIEN=$O(INPUT("ROC ORDERS",ORDIEN)) Q:ORDIEN'>0  D
 .;loop through orderable items for each order
 .S OI=0 F  S OI=$O(INPUT("ROC ORDERS",ORDIEN,"OI",OI)) Q:OI'>0  D
 ..S OINAME=$P($G(INPUT("ROC ORDERS",ORDIEN,"OI",OI)),U)
 ..I $D(INPUT("ROC RETURN TYPE","GROUPS")) D
 ...D GETGRPS^PXRMORCH(OI,.OIGROUPS) Q:'$D(OIGROUPS)
 ...S @RESULT@(0)=1
 ...M @RESULT@(ORDIEN,"GROUPS")=OIGROUPS
 ..;does not process reminder order checks
 ..I '$D(INPUT("ROC RETURN TYPE","RULES")) Q
 ..;Process OI against all Production Reminder Order checks Rule
 ..I '$D(GROUPS) D ORDERCHK^PXRMORCH(PAT,OI,STATUS,0,0)
 ..;Process OI against Production Reminder Order Checks only found in the array of groups
 ..I $D(GROUPS) D ORDERGRP^PXRMORCH(PAT,OI,STATUS,0,.GROUPS)
 ..;quit if no order checks found
 ..I '$D(^TMP($J,OI)) Q
 ..S @RESULT@(0)=1
 ..S SEV=0 F  S SEV=$O(^TMP($J,OI,SEV)) Q:SEV'>0  D
 ...S DISPLAY="" F  S DISPLAY=$O(^TMP($J,OI,SEV,DISPLAY)) Q:DISPLAY=""  D
 ....S RIEN=$O(^PXD(801.1,"D",DISPLAY,0)) I RIEN>0 S RNAME=$P($G(^PXD(801.1,RIEN,0)),U)
 ....I RNAME="" S RNAME=DISPLAY
 ....S @RESULT@(ORDIEN,"RULES",RNAME)=""
 ..K ^TMP($J,OI)
 .I '(($D(@RESULT@(ORDIEN,"RULES")))!($D(@RESULT@(ORDIEN,"GROUPS")))) Q
 .S @RESULT@(ORDIEN)=$G(INPUT("ROC ORDERS",ORDIEN))
 .M @RESULT@(ORDIEN,"TX")=INPUT("ROC ORDERS",ORDIEN,"TX")
 .I $D(INPUT("ROC RETURN TYPE","OI")) M @RESULT@(ORDIEN,"OI")=INPUT("ROC ORDERS",ORDIEN,"OI")
 Q
 ;