ORQQPX ; SLC/JM - PCE and Reminder routines ;11/16/2004
;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,184,187,190,226**;Dec 17, 1997
Q
IMMLIST(ORY,ORPT) ;return pt's immunization list:
;id^name^date/time^reaction^inverse d/t
I $L($T(IMMUN^PXRHS03))<1 S ORY(1)="^Immunizations not available." Q
K ^TMP("PXI",$J)
D IMMUN^PXRHS03(ORPT)
N ORI,IMM,IVDT,IEN,X
S ORI=0,IMM="",IVDT="",IEN=0
F S IMM=$O(^TMP("PXI",$J,IMM)) Q:IMM="" D
.F S IVDT=$O(^TMP("PXI",$J,IMM,IVDT)) Q:IVDT="" D
..F S IEN=$O(^TMP("PXI",$J,IMM,IVDT,IEN)) Q:IEN<1 D
...S ORI=ORI+1,X=$G(^TMP("PXI",$J,IMM,IVDT,IEN,0)) Q:'$L(X)
...S ORY(ORI)=IEN_U_IMM_U_$P(X,U,3)
...I $P(X,U,7)=1 S ORY(ORI)=ORY(ORI)_U_$P(X,U,6)_U_IVDT
...E S ORY(ORI)=ORY(ORI)_U_U_IVDT
S:+$G(ORY(1))<1 ORY(1)="^No immunizations found.^2900101^^9999999"
K ^TMP("PXI",$J)
Q
DETAIL(ORY,IMM) ; return detailed information for an immunization
S ORY(1)="Detailed information on immunizations is not available."
Q
REMIND(ORY,ORPT) ;return pt's currently due PCE clinical reminders
; in the format file 811.9 ien^reminder print name^date due^last occur.
N ORTMPLST,ORI,ORJ,ORIEN,ORTXT,ORX,ORLASTDT,ORDUEDT,ORLOC
S ORJ=0
;
;get patient's location flag (INPATIENT ONLY - outpt locations cannot be
;reliably determined, and many simultaneous outpt locations can occur):
I +$G(ORPT)>0 D
.N DFN S DFN=ORPT,VA200="" D OERR^VADPT
.I +$G(VAIN(4))>0 S ORLOC=+$G(^DIC(42,+$G(VAIN(4)),44))
.K VA200,VAIN
;
D REMLIST(.ORTMPLST,$G(ORLOC))
;D GETLST^XPAR(.ORTMPLST,"USR^LOC.`"_$G(ORLOC)_"^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQPX SEARCH ITEMS","Q",.ORERR)
;I ORERR>0 S ORY(1)=U_"Error: "_$P(ORERR,U,2) Q
S ORI=0 F S ORI=$O(ORTMPLST(ORI)) Q:'ORI D
.S ORIEN=$P(ORTMPLST(ORI),U,2)
.K ^TMP("PXRHM",$J)
.N ORPRI,ORDUE,ORSTA
.D MAIN^PXRM(ORPT,ORIEN,0)
.S ORTXT="",ORTXT=$O(^TMP("PXRHM",$J,ORIEN,ORTXT)) Q:ORTXT="" D
..S ORX=^TMP("PXRHM",$J,ORIEN,ORTXT)
..S ORSTA=$P(ORX,U)
..S ORDUEDT=$P(ORX,U,2),ORLASTDT=$P(ORX,U,3)
..S ORLASTDT=$S(+$G(ORLASTDT)>0:ORLASTDT,1:"") ;null if not a date
..S ORJ=ORJ+1
..S ORDUE=$S(ORSTA["DUE":1,ORSTA["ERROR":3,ORSTA["CNBD":4,1:2)
..I ORDUE'=2 D
...S ORPRI=$P($G(^PXD(811.9,ORIEN,0)),U,10) I ORPRI="" S ORPRI=2
...S ORY(ORJ)=ORIEN_U_ORTXT_U_ORDUEDT_U_ORLASTDT_U_ORPRI_U_ORDUE_U_$$DLG^PXRMRPCA(ORIEN)_U_U_U_U_$$DLGWIPE^PXRMRPCA(ORIEN)
..I ORDUE=2 D
...S ORY(ORJ)=ORIEN_U_ORTXT_U_U_U_U_ORDUE_U_$$DLG^PXRMRPCA(ORIEN)_U_U_U_U_$$DLGWIPE^PXRMRPCA(ORIEN)
.K ^TMP("PXRHM",$J)
Q
REMDET(ORY,ORPT,ORIEN) ;return detail for a pt's clinical reminder
; ORY - return array
; ORPT - patient DFN
; ORIEN - clinical reminder (811.9 ien)
K ^TMP("PXRHM",$J)
D MAIN^PXRM(ORPT,ORIEN,5) ; 5 returns all reminder info
N CR,I,J,ORTXT S I=1
S ORTXT="",ORTXT=$O(^TMP("PXRHM",$J,ORIEN,ORTXT)) Q:ORTXT="" D
.S J=0 F S J=$O(^TMP("PXRHM",$J,ORIEN,ORTXT,"TXT",J)) Q:J="" D
..S ORY(I)=^TMP("PXRHM",$J,ORIEN,ORTXT,"TXT",J),I=I+1
K ^TMP("PXRHM",$J)
Q
NEWACTIV(ORY) ;Return true if Interactive Reminders are active
S ORY=0
I $T(APPL^PXRMRPCA)'="",+$G(DUZ) D
. N SRV
. ;S SRV=$P($G(^VA(200,DUZ,5)),U)
. S SRV=$$GET1^DIQ(200,DUZ,29,"I")
. S ORY=$$GET^XPAR(DUZ_";VA(200,^SRV.`"_+$G(SRV)_"^DIV^SYS","PXRM GUI REMINDERS ACTIVE",1,"Q")
. I +ORY S ORY=1
. E S ORY=0
Q
HISTLOC(LST) ;Returns a list of historical locations
N IDX,PTR,LINE,NAME
K ^TMP("OR",$J,"LOC")
S LST=$NA(^TMP("OR",$J,"LOC"))
S (LINE,IDX)=0
F S IDX=$O(^AUTTLOC(IDX)) Q:'IDX D
.S PTR=+$G(^AUTTLOC(IDX,0))
.I +PTR D
..;S NAME=$P($G(^DIC(4,PTR,0)),U)
..S NAME=$$GET1^DIQ(4,PTR,.01,"I")
..I NAME'="" D
...S LINE=LINE+1
...S ^TMP("OR",$J,"LOC",LINE)=PTR_U_NAME
Q
GETFLDRS(ORFLDRS) ;Return Visible Reminder Folders
; Codes: D=Due, A=Applicable, N=Not Applicable, E=Evaluated, O=Other
N SRV,ORERR,ORTMP
;S SRV=$P($G(^VA(200,DUZ,5)),U)
S SRV=$$GET1^DIQ(200,DUZ,29,"I")
D GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$G(SRV)_"^DIV^SYS^PKG","ORQQPX REMINDER FOLDERS","Q",.ORERR)
I +ORTMP S ORFLDRS=$P($G(ORTMP(1)),U,2)
E S ORFLDRS="DAO"
Q
SETFLDRS(ORY,ORFLDRS) ;Sets Visible Reminder Folders for the current user
N ORERR
D EN^XPAR(DUZ_";VA(200,","ORQQPX REMINDER FOLDERS",1,ORFLDRS,.ORERR)
S ORY=1
Q
GETDEFOL(ORDEFLOC) ;Return Default Outside Locations
N SRV,ORERR
;S SRV=$P($G(^VA(200,DUZ,5)),U)
S SRV=$$GET1^DIQ(200,DUZ,29,"I")
D GETLST^XPAR(.ORDEFLOC,"USR^SRV.`"_+$G(SRV)_"^DIV^SYS^PKG","ORQQPX DEFAULT LOCATIONS","Q",.ORERR)
Q
INSCURS(ORY) ; Returns status of ORQQPX REMINDER TEXT AT CURSOR
N SRV,ORERR,ORTMP
;S ORY=0,SRV=$P($G(^VA(200,DUZ,5)),U)
S ORY=0,SRV=$$GET1^DIQ(200,DUZ,29,"I")
D GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$G(SRV)_"^DIV^SYS^PKG","ORQQPX REMINDER TEXT AT CURSOR","Q",.ORERR)
I +ORTMP S ORY=$P($G(ORTMP(1)),U,2)
Q
NEWCVOK(ORY) ; Returns status of
N SRV,ORERR,ORTMP
;S ORY=0,SRV=$P($G(^VA(200,DUZ,5)),U)
S ORY=0,SRV=$$GET1^DIQ(200,DUZ,29,"I")
D GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$G(SRV)_"^DIV^SYS^PKG","ORQQPX NEW REMINDER PARAMS","Q",.ORERR)
I +ORTMP S ORY=$P($G(ORTMP(1)),U,2)
Q
ADDNAME(ORX) ; Add Reminder or Category Name as 3rd piece
N CAT,IEN
S CAT=$E($P(ORX,U,2),2)
S IEN=$E($P(ORX,U,2),3,99)
I +IEN D
.I CAT="R" S $P(ORX,U,3)=$P($G(^PXD(811.9,IEN,0)),U,3)
.I CAT="C" S $P(ORX,U,3)=$P($G(^PXRMD(811.7,IEN,0)),U)
Q ORX
REMACCUM(ORY,LVL,TYP,SORT,CLASS) ; Accumulates ORTMP into ORY
; Format of entries in ORQQPX COVER SHEET REMINDERS:
; L:Lock;R:Remove;N:Normal / C:Category;R:Reminder / Cat or Rem IEN
N IDX,I,J,K,M,FOUND,ORERR,ORTMP,FLAG,IEN
N FFLAG,FIEN,OUT,P2,ADD,DOADD,CODE
I LVL="CLASS" D I 1
.N ORLST,ORCLS,ORCLSPRM,ORWP
.S ORCLSPRM="ORQQPX COVER SHEET REM CLASSES"
.D GETLST^XPAR(.ORLST,"SYS",ORCLSPRM,"Q",.ORERR)
.S I=0,M=0,CLASS=$G(CLASS)
.F S I=$O(ORLST(I)) Q:'I D
..S ORCLS=$P(ORLST(I),U,1)
..I +CLASS S ADD=(ORCLS=+CLASS) I 1
..E S ADD=$$ISA^USRLM(DUZ,ORCLS,.ORERR)
..I +ADD D
...D GETWP^XPAR(.ORWP,"SYS",ORCLSPRM,ORCLS,.ORERR)
...S K=0
...F S K=$O(ORWP(K)) Q:'K D
....S M=M+1
....S J=$P(ORWP(K,0),";",1)
....S ORTMP(M)=J_U_$P(ORWP(K,0),";",2)
E D GETLST^XPAR(.ORTMP,LVL,"ORQQPX COVER SHEET REMINDERS",TYP,.ORERR)
S I=0,IDX=$O(ORY(999999),-1)+1,ADD=(SORT="")
F S I=$O(ORTMP(I)) Q:'I D
.S (FOUND,J)=0,P2=$P(ORTMP(I),U,2)
.S FLAG=$E(P2),IEN=$E(P2,2,999)
.I ADD S DOADD=1
.E D
..S DOADD=0
..F S J=$O(ORY(J)) Q:'J D Q:FOUND
...S P2=$P(ORY(J),U,2)
...S FIEN=$E(P2,2,999)
...I FIEN=IEN S FOUND=J,FFLAG=$E(P2)
..I FOUND D I 1
...I FLAG="R",FFLAG'="L" K ORY(FOUND)
...I FLAG'=FFLAG,(FLAG_FFLAG)["L" S $E(P2)="L",$P(ORY(FOUND),U,2)=P2
..E I (FLAG'="R") S DOADD=1
.I DOADD D
..S OUT(IDX)=ORTMP(I)
..S $P(OUT(IDX),U)=$P(OUT(IDX),U)_SORT
..I SORT="" S OUT(IDX)=$$ADDNAME(OUT(IDX))
..S IDX=IDX+1
M ORY=OUT
Q
ADDREM(ORY,IDX,IEN) ; Add Reminder to ORY list
I $D(ORY("B",IEN)) Q ; See if it's in the list
I '$D(^PXD(811.9,IEN)) Q ; Check if Exists
I $P($G(^PXD(811.9,IEN,0)),U,6)'="" Q ; Check if Active
;check to see if the reminder is assigned to CPRS
I $P($G(^PXD(811.9,IEN,100)),U,4)["L" Q
I $P($G(^PXD(811.9,IEN,100)),U,4)'["C",$P($G(^PXD(811.9,IEN,100)),U,4)'="*" Q
S ORY(IDX)=IDX_U_IEN
S ORY("B",IEN)=""
Q
ADDCAT(ORY,IDX,IEN) ; Add Category Reminders to ORY list
N ORREM,I,IDX2,NREM
D CATREM^PXRMAPI0(IEN,.ORREM)
S I=0
F S I=$O(ORREM(I)) Q:'I D
. S IDX2="00000"_I
. S IDX2=$E(IDX2,$L(IDX2)-5,99)
. D ADDREM(.ORY,+(IDX_"."_IDX2),$P(ORREM(I),U,1))
Q
REMLIST(ORY,LOC) ;Returns a list of all cover sheet reminders
N SRV,I,J,ORLST,CODE,IDX,IEN,NEWP
;S SRV=$P($G(^VA(200,DUZ,5)),U)
S SRV=$$GET1^DIQ(200,DUZ,29,"I")
D NEWCVOK(.NEWP)
I 'NEWP D GETLST^XPAR(.ORY,"USR^LOC.`"_$G(LOC)_"^SRV.`"_+$G(SRV)_"^DIV^SYS^PKG","ORQQPX SEARCH ITEMS","Q",.ORERR) Q
D REMACCUM(.ORLST,"PKG","Q",1000)
D REMACCUM(.ORLST,"SYS","Q",2000)
D REMACCUM(.ORLST,"DIV","Q",3000)
I +SRV D REMACCUM(.ORLST,"SRV.`"_+$G(SRV),"Q",4000)
I +LOC D REMACCUM(.ORLST,"LOC.`"_+$G(LOC),"Q",5000)
D REMACCUM(.ORLST,"CLASS","Q",6000)
D REMACCUM(.ORLST,"USR","Q",7000)
S I=0
F S I=$O(ORLST(I)) Q:'I D
.S IDX=$P(ORLST(I),U,1)
.F Q:'$D(ORY(IDX)) S IDX=IDX+1
.S CODE=$E($P(ORLST(I),U,2),2)
.S IEN=$E($P(ORLST(I),U,2),3,999)
.I CODE="R" D ADDREM(.ORY,IDX,IEN)
.I CODE="C" D ADDCAT(.ORY,IDX,IEN)
K ORY("B")
Q
LVREMLST(ORY,LVL,CLASS) ;Returns cover sheet reminders at a specified level
D REMACCUM(.ORY,LVL,"Q","",$G(CLASS))
Q
SAVELVL(ORY,LVL,CLASS,DATA) ;Save cover sheet reminders at a specified level
N ORERR,PARAM,I
I LVL="CLASS" D I 1
.S PARAM="ORQQPX COVER SHEET REM CLASSES"
.S LVL="SYS"
.D DEL^XPAR(LVL,PARAM,"`"_CLASS,.ORERR)
.D EN^XPAR(LVL,PARAM,"`"_CLASS,.DATA,.ORERR)
E D
.S PARAM="ORQQPX COVER SHEET REMINDERS"
.D NDEL^XPAR(LVL,PARAM,.ORERR)
.S I=0
.F S I=$O(DATA(I)) Q:'I D
..D EN^XPAR(LVL,PARAM,$P(DATA(I),U,1),$P(DATA(I),U,2),.ORERR)
S ORY=1
Q
GETLIST(ORY,ORLOC) ;Returns a list of all cover sheet reminders
N I
D REMLIST(.ORY,$G(ORLOC))
S I=0
F S I=$O(ORY(I)) Q:'I D
.S ORY(I)=$P(ORY(I),U,2)
Q
EVALCOVR(ORY,ORPT,ORLOC) ; Evaluate Cover Sheet Reminders
N ORTMP
D GETLIST(.ORTMP,$G(ORLOC))
D ALIST^ORQQPXRM(.ORY,ORPT,.ORTMP)
Q
ORQQPX ; SLC/JM - PCE and Reminder routines ;11/16/2004
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,184,187,190,226**;Dec 17, 1997
+2 QUIT
IMMLIST(ORY,ORPT) ;return pt's immunization list:
+1 ;id^name^date/time^reaction^inverse d/t
+2 IF $LENGTH($TEXT(IMMUN^PXRHS03))<1
SET ORY(1)="^Immunizations not available."
QUIT
+3 KILL ^TMP("PXI",$JOB)
+4 DO IMMUN^PXRHS03(ORPT)
+5 NEW ORI,IMM,IVDT,IEN,X
+6 SET ORI=0
SET IMM=""
SET IVDT=""
SET IEN=0
+7 FOR
SET IMM=$ORDER(^TMP("PXI",$JOB,IMM))
IF IMM=""
QUIT
Begin DoDot:1
+8 FOR
SET IVDT=$ORDER(^TMP("PXI",$JOB,IMM,IVDT))
IF IVDT=""
QUIT
Begin DoDot:2
+9 FOR
SET IEN=$ORDER(^TMP("PXI",$JOB,IMM,IVDT,IEN))
IF IEN<1
QUIT
Begin DoDot:3
+10 SET ORI=ORI+1
SET X=$GET(^TMP("PXI",$JOB,IMM,IVDT,IEN,0))
IF '$LENGTH(X)
QUIT
+11 SET ORY(ORI)=IEN_U_IMM_U_$PIECE(X,U,3)
+12 IF $PIECE(X,U,7)=1
SET ORY(ORI)=ORY(ORI)_U_$PIECE(X,U,6)_U_IVDT
+13 IF '$TEST
SET ORY(ORI)=ORY(ORI)_U_U_IVDT
End DoDot:3
End DoDot:2
End DoDot:1
+14 IF +$GET(ORY(1))<1
SET ORY(1)="^No immunizations found.^2900101^^9999999"
+15 KILL ^TMP("PXI",$JOB)
+16 QUIT
DETAIL(ORY,IMM) ; return detailed information for an immunization
+1 SET ORY(1)="Detailed information on immunizations is not available."
+2 QUIT
REMIND(ORY,ORPT) ;return pt's currently due PCE clinical reminders
+1 ; in the format file 811.9 ien^reminder print name^date due^last occur.
+2 NEW ORTMPLST,ORI,ORJ,ORIEN,ORTXT,ORX,ORLASTDT,ORDUEDT,ORLOC
+3 SET ORJ=0
+4 ;
+5 ;get patient's location flag (INPATIENT ONLY - outpt locations cannot be
+6 ;reliably determined, and many simultaneous outpt locations can occur):
+7 IF +$GET(ORPT)>0
Begin DoDot:1
+8 NEW DFN
SET DFN=ORPT
SET VA200=""
DO OERR^VADPT
+9 IF +$GET(VAIN(4))>0
SET ORLOC=+$GET(^DIC(42,+$GET(VAIN(4)),44))
+10 KILL VA200,VAIN
End DoDot:1
+11 ;
+12 DO REMLIST(.ORTMPLST,$GET(ORLOC))
+13 ;D GETLST^XPAR(.ORTMPLST,"USR^LOC.`"_$G(ORLOC)_"^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQPX SEARCH ITEMS","Q",.ORERR)
+14 ;I ORERR>0 S ORY(1)=U_"Error: "_$P(ORERR,U,2) Q
+15 SET ORI=0
FOR
SET ORI=$ORDER(ORTMPLST(ORI))
IF 'ORI
QUIT
Begin DoDot:1
+16 SET ORIEN=$PIECE(ORTMPLST(ORI),U,2)
+17 KILL ^TMP("PXRHM",$JOB)
+18 NEW ORPRI,ORDUE,ORSTA
+19 DO MAIN^PXRM(ORPT,ORIEN,0)
+20 SET ORTXT=""
SET ORTXT=$ORDER(^TMP("PXRHM",$JOB,ORIEN,ORTXT))
IF ORTXT=""
QUIT
Begin DoDot:2
+21 SET ORX=^TMP("PXRHM",$JOB,ORIEN,ORTXT)
+22 SET ORSTA=$PIECE(ORX,U)
+23 SET ORDUEDT=$PIECE(ORX,U,2)
SET ORLASTDT=$PIECE(ORX,U,3)
+24 ;null if not a date
SET ORLASTDT=$SELECT(+$GET(ORLASTDT)>0:ORLASTDT,1:"")
+25 SET ORJ=ORJ+1
+26 SET ORDUE=$SELECT(ORSTA["DUE":1,ORSTA["ERROR":3,ORSTA["CNBD":4,1:2)
+27 IF ORDUE'=2
Begin DoDot:3
+28 SET ORPRI=$PIECE($GET(^PXD(811.9,ORIEN,0)),U,10)
IF ORPRI=""
SET ORPRI=2
+29 SET ORY(ORJ)=ORIEN_U_ORTXT_U_ORDUEDT_U_ORLASTDT_U_ORPRI_U_ORDUE_U_$$DLG^PXRMRPCA(ORIEN)_U_U_U_U_$$DLGWIPE^PXRMRPCA(ORIEN)
End DoDot:3
+30 IF ORDUE=2
Begin DoDot:3
+31 SET ORY(ORJ)=ORIEN_U_ORTXT_U_U_U_U_ORDUE_U_$$DLG^PXRMRPCA(ORIEN)_U_U_U_U_$$DLGWIPE^PXRMRPCA(ORIEN)
End DoDot:3
End DoDot:2
+32 KILL ^TMP("PXRHM",$JOB)
End DoDot:1
+33 QUIT
REMDET(ORY,ORPT,ORIEN) ;return detail for a pt's clinical reminder
+1 ; ORY - return array
+2 ; ORPT - patient DFN
+3 ; ORIEN - clinical reminder (811.9 ien)
+4 KILL ^TMP("PXRHM",$JOB)
+5 ; 5 returns all reminder info
DO MAIN^PXRM(ORPT,ORIEN,5)
+6 NEW CR,I,J,ORTXT
SET I=1
+7 SET ORTXT=""
SET ORTXT=$ORDER(^TMP("PXRHM",$JOB,ORIEN,ORTXT))
IF ORTXT=""
QUIT
Begin DoDot:1
+8 SET J=0
FOR
SET J=$ORDER(^TMP("PXRHM",$JOB,ORIEN,ORTXT,"TXT",J))
IF J=""
QUIT
Begin DoDot:2
+9 SET ORY(I)=^TMP("PXRHM",$JOB,ORIEN,ORTXT,"TXT",J)
SET I=I+1
End DoDot:2
End DoDot:1
+10 KILL ^TMP("PXRHM",$JOB)
+11 QUIT
NEWACTIV(ORY) ;Return true if Interactive Reminders are active
+1 SET ORY=0
+2 IF $TEXT(APPL^PXRMRPCA)'=""
IF +$GET(DUZ)
Begin DoDot:1
+3 NEW SRV
+4 ;S SRV=$P($G(^VA(200,DUZ,5)),U)
+5 SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+6 SET ORY=$$GET^XPAR(DUZ_";VA(200,^SRV.`"_+$GET(SRV)_"^DIV^SYS","PXRM GUI REMINDERS ACTIVE",1,"Q")
+7 IF +ORY
SET ORY=1
+8 IF '$TEST
SET ORY=0
End DoDot:1
+9 QUIT
HISTLOC(LST) ;Returns a list of historical locations
+1 NEW IDX,PTR,LINE,NAME
+2 KILL ^TMP("OR",$JOB,"LOC")
+3 SET LST=$NAME(^TMP("OR",$JOB,"LOC"))
+4 SET (LINE,IDX)=0
+5 FOR
SET IDX=$ORDER(^AUTTLOC(IDX))
IF 'IDX
QUIT
Begin DoDot:1
+6 SET PTR=+$GET(^AUTTLOC(IDX,0))
+7 IF +PTR
Begin DoDot:2
+8 ;S NAME=$P($G(^DIC(4,PTR,0)),U)
+9 SET NAME=$$GET1^DIQ(4,PTR,.01,"I")
+10 IF NAME'=""
Begin DoDot:3
+11 SET LINE=LINE+1
+12 SET ^TMP("OR",$JOB,"LOC",LINE)=PTR_U_NAME
End DoDot:3
End DoDot:2
End DoDot:1
+13 QUIT
GETFLDRS(ORFLDRS) ;Return Visible Reminder Folders
+1 ; Codes: D=Due, A=Applicable, N=Not Applicable, E=Evaluated, O=Other
+2 NEW SRV,ORERR,ORTMP
+3 ;S SRV=$P($G(^VA(200,DUZ,5)),U)
+4 SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+5 DO GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$GET(SRV)_"^DIV^SYS^PKG","ORQQPX REMINDER FOLDERS","Q",.ORERR)
+6 IF +ORTMP
SET ORFLDRS=$PIECE($GET(ORTMP(1)),U,2)
+7 IF '$TEST
SET ORFLDRS="DAO"
+8 QUIT
SETFLDRS(ORY,ORFLDRS) ;Sets Visible Reminder Folders for the current user
+1 NEW ORERR
+2 DO EN^XPAR(DUZ_";VA(200,","ORQQPX REMINDER FOLDERS",1,ORFLDRS,.ORERR)
+3 SET ORY=1
+4 QUIT
GETDEFOL(ORDEFLOC) ;Return Default Outside Locations
+1 NEW SRV,ORERR
+2 ;S SRV=$P($G(^VA(200,DUZ,5)),U)
+3 SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+4 DO GETLST^XPAR(.ORDEFLOC,"USR^SRV.`"_+$GET(SRV)_"^DIV^SYS^PKG","ORQQPX DEFAULT LOCATIONS","Q",.ORERR)
+5 QUIT
INSCURS(ORY) ; Returns status of ORQQPX REMINDER TEXT AT CURSOR
+1 NEW SRV,ORERR,ORTMP
+2 ;S ORY=0,SRV=$P($G(^VA(200,DUZ,5)),U)
+3 SET ORY=0
SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+4 DO GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$GET(SRV)_"^DIV^SYS^PKG","ORQQPX REMINDER TEXT AT CURSOR","Q",.ORERR)
+5 IF +ORTMP
SET ORY=$PIECE($GET(ORTMP(1)),U,2)
+6 QUIT
NEWCVOK(ORY) ; Returns status of
+1 NEW SRV,ORERR,ORTMP
+2 ;S ORY=0,SRV=$P($G(^VA(200,DUZ,5)),U)
+3 SET ORY=0
SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+4 DO GETLST^XPAR(.ORTMP,"USR^SRV.`"_+$GET(SRV)_"^DIV^SYS^PKG","ORQQPX NEW REMINDER PARAMS","Q",.ORERR)
+5 IF +ORTMP
SET ORY=$PIECE($GET(ORTMP(1)),U,2)
+6 QUIT
ADDNAME(ORX) ; Add Reminder or Category Name as 3rd piece
+1 NEW CAT,IEN
+2 SET CAT=$EXTRACT($PIECE(ORX,U,2),2)
+3 SET IEN=$EXTRACT($PIECE(ORX,U,2),3,99)
+4 IF +IEN
Begin DoDot:1
+5 IF CAT="R"
SET $PIECE(ORX,U,3)=$PIECE($GET(^PXD(811.9,IEN,0)),U,3)
+6 IF CAT="C"
SET $PIECE(ORX,U,3)=$PIECE($GET(^PXRMD(811.7,IEN,0)),U)
End DoDot:1
+7 QUIT ORX
REMACCUM(ORY,LVL,TYP,SORT,CLASS) ; Accumulates ORTMP into ORY
+1 ; Format of entries in ORQQPX COVER SHEET REMINDERS:
+2 ; L:Lock;R:Remove;N:Normal / C:Category;R:Reminder / Cat or Rem IEN
+3 NEW IDX,I,J,K,M,FOUND,ORERR,ORTMP,FLAG,IEN
+4 NEW FFLAG,FIEN,OUT,P2,ADD,DOADD,CODE
+5 IF LVL="CLASS"
Begin DoDot:1
+6 NEW ORLST,ORCLS,ORCLSPRM,ORWP
+7 SET ORCLSPRM="ORQQPX COVER SHEET REM CLASSES"
+8 DO GETLST^XPAR(.ORLST,"SYS",ORCLSPRM,"Q",.ORERR)
+9 SET I=0
SET M=0
SET CLASS=$GET(CLASS)
+10 FOR
SET I=$ORDER(ORLST(I))
IF 'I
QUIT
Begin DoDot:2
+11 SET ORCLS=$PIECE(ORLST(I),U,1)
+12 IF +CLASS
SET ADD=(ORCLS=+CLASS)
IF 1
+13 IF '$TEST
SET ADD=$$ISA^USRLM(DUZ,ORCLS,.ORERR)
+14 IF +ADD
Begin DoDot:3
+15 DO GETWP^XPAR(.ORWP,"SYS",ORCLSPRM,ORCLS,.ORERR)
+16 SET K=0
+17 FOR
SET K=$ORDER(ORWP(K))
IF 'K
QUIT
Begin DoDot:4
+18 SET M=M+1
+19 SET J=$PIECE(ORWP(K,0),";",1)
+20 SET ORTMP(M)=J_U_$PIECE(ORWP(K,0),";",2)
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
IF 1
+21 IF '$TEST
DO GETLST^XPAR(.ORTMP,LVL,"ORQQPX COVER SHEET REMINDERS",TYP,.ORERR)
+22 SET I=0
SET IDX=$ORDER(ORY(999999),-1)+1
SET ADD=(SORT="")
+23 FOR
SET I=$ORDER(ORTMP(I))
IF 'I
QUIT
Begin DoDot:1
+24 SET (FOUND,J)=0
SET P2=$PIECE(ORTMP(I),U,2)
+25 SET FLAG=$EXTRACT(P2)
SET IEN=$EXTRACT(P2,2,999)
+26 IF ADD
SET DOADD=1
+27 IF '$TEST
Begin DoDot:2
+28 SET DOADD=0
+29 FOR
SET J=$ORDER(ORY(J))
IF 'J
QUIT
Begin DoDot:3
+30 SET P2=$PIECE(ORY(J),U,2)
+31 SET FIEN=$EXTRACT(P2,2,999)
+32 IF FIEN=IEN
SET FOUND=J
SET FFLAG=$EXTRACT(P2)
End DoDot:3
IF FOUND
QUIT
+33 IF FOUND
Begin DoDot:3
+34 IF FLAG="R"
IF FFLAG'="L"
KILL ORY(FOUND)
+35 IF FLAG'=FFLAG
IF (FLAG_FFLAG)["L"
SET $EXTRACT(P2)="L"
SET $PIECE(ORY(FOUND),U,2)=P2
End DoDot:3
IF 1
+36 IF '$TEST
IF (FLAG'="R")
SET DOADD=1
End DoDot:2
+37 IF DOADD
Begin DoDot:2
+38 SET OUT(IDX)=ORTMP(I)
+39 SET $PIECE(OUT(IDX),U)=$PIECE(OUT(IDX),U)_SORT
+40 IF SORT=""
SET OUT(IDX)=$$ADDNAME(OUT(IDX))
+41 SET IDX=IDX+1
End DoDot:2
End DoDot:1
+42 MERGE ORY=OUT
+43 QUIT
ADDREM(ORY,IDX,IEN) ; Add Reminder to ORY list
+1 ; See if it's in the list
IF $DATA(ORY("B",IEN))
QUIT
+2 ; Check if Exists
IF '$DATA(^PXD(811.9,IEN))
QUIT
+3 ; Check if Active
IF $PIECE($GET(^PXD(811.9,IEN,0)),U,6)'=""
QUIT
+4 ;check to see if the reminder is assigned to CPRS
+5 IF $PIECE($GET(^PXD(811.9,IEN,100)),U,4)["L"
QUIT
+6 IF $PIECE($GET(^PXD(811.9,IEN,100)),U,4)'["C"
IF $PIECE($GET(^PXD(811.9,IEN,100)),U,4)'="*"
QUIT
+7 SET ORY(IDX)=IDX_U_IEN
+8 SET ORY("B",IEN)=""
+9 QUIT
ADDCAT(ORY,IDX,IEN) ; Add Category Reminders to ORY list
+1 NEW ORREM,I,IDX2,NREM
+2 DO CATREM^PXRMAPI0(IEN,.ORREM)
+3 SET I=0
+4 FOR
SET I=$ORDER(ORREM(I))
IF 'I
QUIT
Begin DoDot:1
+5 SET IDX2="00000"_I
+6 SET IDX2=$EXTRACT(IDX2,$LENGTH(IDX2)-5,99)
+7 DO ADDREM(.ORY,+(IDX_"."_IDX2),$PIECE(ORREM(I),U,1))
End DoDot:1
+8 QUIT
REMLIST(ORY,LOC) ;Returns a list of all cover sheet reminders
+1 NEW SRV,I,J,ORLST,CODE,IDX,IEN,NEWP
+2 ;S SRV=$P($G(^VA(200,DUZ,5)),U)
+3 SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+4 DO NEWCVOK(.NEWP)
+5 IF 'NEWP
DO GETLST^XPAR(.ORY,"USR^LOC.`"_$GET(LOC)_"^SRV.`"_+$GET(SRV)_"^DIV^SYS^PKG","ORQQPX SEARCH ITEMS","Q",.ORERR)
QUIT
+6 DO REMACCUM(.ORLST,"PKG","Q",1000)
+7 DO REMACCUM(.ORLST,"SYS","Q",2000)
+8 DO REMACCUM(.ORLST,"DIV","Q",3000)
+9 IF +SRV
DO REMACCUM(.ORLST,"SRV.`"_+$GET(SRV),"Q",4000)
+10 IF +LOC
DO REMACCUM(.ORLST,"LOC.`"_+$GET(LOC),"Q",5000)
+11 DO REMACCUM(.ORLST,"CLASS","Q",6000)
+12 DO REMACCUM(.ORLST,"USR","Q",7000)
+13 SET I=0
+14 FOR
SET I=$ORDER(ORLST(I))
IF 'I
QUIT
Begin DoDot:1
+15 SET IDX=$PIECE(ORLST(I),U,1)
+16 FOR
IF '$DATA(ORY(IDX))
QUIT
SET IDX=IDX+1
+17 SET CODE=$EXTRACT($PIECE(ORLST(I),U,2),2)
+18 SET IEN=$EXTRACT($PIECE(ORLST(I),U,2),3,999)
+19 IF CODE="R"
DO ADDREM(.ORY,IDX,IEN)
+20 IF CODE="C"
DO ADDCAT(.ORY,IDX,IEN)
End DoDot:1
+21 KILL ORY("B")
+22 QUIT
LVREMLST(ORY,LVL,CLASS) ;Returns cover sheet reminders at a specified level
+1 DO REMACCUM(.ORY,LVL,"Q","",$GET(CLASS))
+2 QUIT
SAVELVL(ORY,LVL,CLASS,DATA) ;Save cover sheet reminders at a specified level
+1 NEW ORERR,PARAM,I
+2 IF LVL="CLASS"
Begin DoDot:1
+3 SET PARAM="ORQQPX COVER SHEET REM CLASSES"
+4 SET LVL="SYS"
+5 DO DEL^XPAR(LVL,PARAM,"`"_CLASS,.ORERR)
+6 DO EN^XPAR(LVL,PARAM,"`"_CLASS,.DATA,.ORERR)
End DoDot:1
IF 1
+7 IF '$TEST
Begin DoDot:1
+8 SET PARAM="ORQQPX COVER SHEET REMINDERS"
+9 DO NDEL^XPAR(LVL,PARAM,.ORERR)
+10 SET I=0
+11 FOR
SET I=$ORDER(DATA(I))
IF 'I
QUIT
Begin DoDot:2
+12 DO EN^XPAR(LVL,PARAM,$PIECE(DATA(I),U,1),$PIECE(DATA(I),U,2),.ORERR)
End DoDot:2
End DoDot:1
+13 SET ORY=1
+14 QUIT
GETLIST(ORY,ORLOC) ;Returns a list of all cover sheet reminders
+1 NEW I
+2 DO REMLIST(.ORY,$GET(ORLOC))
+3 SET I=0
+4 FOR
SET I=$ORDER(ORY(I))
IF 'I
QUIT
Begin DoDot:1
+5 SET ORY(I)=$PIECE(ORY(I),U,2)
End DoDot:1
+6 QUIT
EVALCOVR(ORY,ORPT,ORLOC) ; Evaluate Cover Sheet Reminders
+1 NEW ORTMP
+2 DO GETLIST(.ORTMP,$GET(ORLOC))
+3 DO ALIST^ORQQPXRM(.ORY,ORPT,.ORTMP)
+4 QUIT