ORQQVI1 ;SLC/STAFF- Vitals rpc grid ;2/4/99 21:11
;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,285**;Dec 17, 1997;Build 5
;
;DBIA for PXRMINDX(120.5 is 4290
;DBIA for ^GMVPXRM is 3647
TEST ; test use only
N CNT,I K ^TMP("ORQQVX",$J)
S ^TMP("ORQQVX",$J,"INPUT",1)="16^2970902^2920202^3"
S CNT=1
F I="WEIGHT","RESPIRATION","PULSE","HEIGHT" S CNT=CNT+1,^TMP("ORQQVX",$J,"INPUT",CNT)=I
D GRIDDATA
S I=0 F S I=$O(^TMP("ORQQVX",$J,"OUTPUT",I)) Q:I<1 W !,^(I)
K ^TMP("ORQQVX",$J)
Q
;
DETAIL(ROOT,DFN,DATE1,DATE2,RTIMES,TESTS) ; from Remote Procedure file
N CNT,NUM,TEMPDATE
I DATE1<DATE2 S TEMPDATE=DATE1,DATE1=DATE2,DATE2=TEMPDATE
K ^TMP("ORQQVX",$J,"INPUT"),^("OUTPUT")
S ROOT=$NA(^TMP("ORQQVX",$J,"OUTPUT"))
S ^TMP("ORQQVX",$J,"INPUT",1)=DFN_U_DATE1_U_DATE2_U_RTIMES
S CNT=1,NUM=0 F S NUM=$O(TESTS(NUM)) Q:NUM<1 D
.S CNT=CNT+1
.S ^TMP("ORQQVX",$J,"INPUT",CNT)=TESTS(NUM)
D MEMODATA
Q
;
MEMODATA ;
; input format
; ^TMP("ORQQVX",$J,"INPUT",1)=dfn^start date^end date^restrict # time values
; ^TMP("ORQQVX",$J,"INPUT",#)=test# (tests displayed in this order)
;
S ^TMP("ORQQVX",$J,"OUTPUT",1)=""
N CHECKOK,DATANUM,DATESEQ,DATETIME,DFN,EDATE,EDT,ENTERBY,IDT,LINE,LINE1,LOC,MAIN,NUM,OUTCNT,RCNT,RQUIT,RESULT,RTIMES,SDATE,TESTNAME,TESTNUM,TESTSEQ,VCNT,ZERO
K ^TMP("ORQQV",$J)
S DFN=+^TMP("ORQQVX",$J,"INPUT",1),SDATE=+$P(^(1),U,2),EDATE=+$P(^(1),U,3),RTIMES=+$P(^(1),U,4)
Q:'DFN I 'SDATE,'EDATE,'RTIMES Q
I RTIMES,'SDATE,'EDATE S SDATE=DT,EDATE=2750101
I SDATE,'EDATE Q
I EDATE,'SDATE Q
S OUTCNT=1,TESTSEQ=0
S NUM=1 F S NUM=$O(^TMP("ORQQVX",$J,"INPUT",NUM)) Q:NUM<1 S TESTNAME=^(NUM) D
.S TESTNAME=$$UP^XLFSTR(TESTNAME)
.S TESTNUM=$$FIND1^DIC(120.51,"","BX",TESTNAME,"","","ERR")
.I 'TESTNUM Q
.S TESTSEQ=TESTSEQ+1
.S LINE=TESTSEQ_U_TESTNUM_U_$$MIXED^ORU(TESTNAME)
.S ^TMP("ORQQV",$J,"TEST",TESTSEQ)=LINE
.S OUTCNT=OUTCNT+1
S EDATE=EDATE\1
S TESTSEQ=0 F S TESTSEQ=$O(^TMP("ORQQV",$J,"TEST",TESTSEQ)) Q:TESTSEQ<1 S TESTNUM=$P(^(TESTSEQ),U,2) D
.S IDT=SDATE,(RCNT,RQUIT)=0
.F S IDT=$O(^PXRMINDX(120.5,"PI",DFN,TESTNUM,SDATE)) Q:IDT<1 Q:IDT>EDATE D Q:RQUIT
..S DATANUM="" F S DATANUM=$O(^PXRMINDX(120.5,"PI",DFN,TESTNUM,SDATE,DATANUM)) Q:$L(DATANUM)'>0 D Q:RQUIT
...D EN^GMVPXRM(.ZERO,DATANUM,"I")
...Q:$P(ZERO(1),U)=-1
...Q:$P(ZERO(2),U)'=DFN Q:$P(ZERO(3),U)'=TESTNUM
...S RESULT=$$STRIP^ORCMEDIT($P(ZERO(7),U)),DATETIME=$P(ZERO(1),U),LOC=+$P(ZERO(5),U),ENTERBY=+$P(ZERO(6),U)
...S ^TMP("ORQQV",$J,"RESULTS",IDT)=DATETIME_U_LOC_U_ENTERBY ;$$FMTE^XLFDT(DATETIME)_" Location: "_$P($G(^SC(+LOC,0)),U)_" Entered by: "_$P($G(^VA(200,+ENTERBY,0)),U)
...S LINE=" "_$P(^TMP("ORQQV",$J,"TEST",TESTSEQ),U,3)
...S LINE=$$SETSTR^VALM1(RESULT,LINE,22,1+$L(RESULT))_U_LOC_U_ENTERBY
...S ^TMP("ORQQV",$J,"RESULTS",IDT,TESTSEQ)=LINE
...I RTIMES S RCNT=RCNT+1 I RCNT=RTIMES S RQUIT=1
S (DATESEQ,RCNT,RQUIT,VCNT)=0
S IDT=0 F S IDT=$O(^TMP("ORQQV",$J,"RESULTS",IDT)) Q:IDT<1 S LINE=^(IDT) D Q:RQUIT
.S CHECKOK=1 D
..S MAIN=$P(LINE,U,2,3)
..S TESTSEQ=0 F S TESTSEQ=$O(^TMP("ORQQV",$J,"RESULTS",IDT,TESTSEQ)) Q:TESTSEQ<1 S RESULT=$P(^(TESTSEQ),U,2,3) I RESULT'=MAIN S CHECKOK=0 Q
.I CHECKOK D
..S DATETIME=$$FMTE^XLFDT($P(LINE,U)),DATETIME=$P(DATETIME,":",1,2)
..S DATETIME=DATETIME_" Location: "_$P($G(^SC($P(LINE,U,2),0)),U)
..S DATETIME=$$SETSTR^VALM1(" Entered by: "_$P($G(^VA(200,$P(LINE,U,3),0)),U),DATETIME,50,30)
.E S DATETIME=$$FMTE^XLFDT($P(LINE,U)),DATETIME=$P(DATETIME,":",1,2)
.S DATESEQ=DATESEQ+1
.S OUTCNT=OUTCNT+1
.S ^TMP("ORQQVX",$J,"OUTPUT",OUTCNT)=DATETIME
.S TESTSEQ=0 F S TESTSEQ=$O(^TMP("ORQQV",$J,"RESULTS",IDT,TESTSEQ)) Q:TESTSEQ<1 S LINE1=^(TESTSEQ) D
..I CHECKOK S RESULT=$P(LINE1,U)
..E D
...S RESULT=$$SETSTR^VALM1(" Location: "_$P($G(^SC($P(LINE1,U,2),0)),U),$P(LINE1,U),30,25)
...S RESULT=$$SETSTR^VALM1(" Entered by; "_$P($G(^VA(200,$P(LINE1,U,3),0)),U),RESULT,50,30)
..S OUTCNT=OUTCNT+1
..S ^TMP("ORQQVX",$J,"OUTPUT",OUTCNT)=RESULT
.I RTIMES S RCNT=RCNT+1 I RCNT=RTIMES S RQUIT=1
K ^TMP("ORQQV",$J)
Q
;
GRID(ROOT,DFN,DATE1,DATE2,RTIMES,TESTS) ; from Remote Procedure file
N CNT,NUM,TEMPDATE
I DATE1<DATE2 S TEMPDATE=DATE1,DATE1=DATE2,DATE2=TEMPDATE
K ^TMP("ORQQVX",$J,"INPUT"),^("OUTPUT")
S ROOT=$NA(^TMP("ORQQVX",$J,"OUTPUT"))
S ^TMP("ORQQVX",$J,"INPUT",1)=DFN_U_DATE1_U_DATE2_U_RTIMES
S CNT=1,NUM=0 F S NUM=$O(TESTS(NUM)) Q:NUM<1 D
.S CNT=CNT+1
.S ^TMP("ORQQVX",$J,"INPUT",CNT)=TESTS(NUM)
D GRIDDATA
Q
;
GRIDDATA ;
; input format
; ^TMP("ORQQVX",$J,"INPUT",1)=dfn^start date^end date^restrict # time values
; ^TMP("ORQQVX",$J,"INPUT",#)=test# (tests displayed in this order)
;
S ^TMP("ORQQVX",$J,"OUTPUT",1)="0^0^0"
N DATANUM,DATESEQ,DATETIME,DFN,EDATE,EDT,IDT,LINE,NUM,OUTCNT,RCNT,RQUIT,RESULT,RTIMES,SDATE,TESTNAME,TESTNUM,TESTSEQ,VALUES,VCNT,ZERO
K ^TMP("ORQQV",$J)
S DFN=+^TMP("ORQQVX",$J,"INPUT",1),SDATE=+$P(^(1),U,2),EDATE=+$P(^(1),U,3),RTIMES=+$P(^(1),U,4)
Q:'DFN I 'SDATE,'EDATE,'RTIMES Q
I RTIMES,'SDATE,'EDATE S SDATE=DT,EDATE=2750101
I SDATE,'EDATE Q
I EDATE,'SDATE Q
S OUTCNT=1,TESTSEQ=0
S NUM=1 F S NUM=$O(^TMP("ORQQVX",$J,"INPUT",NUM)) Q:NUM<1 S TESTNAME=^(NUM) D
.S TESTNAME=$$UP^XLFSTR(TESTNAME)
.S TESTNUM=$$FIND1^DIC(120.51,"","BX",TESTNAME,"","","ERR")
.I 'TESTNUM Q
.S TESTSEQ=TESTSEQ+1
.S LINE=TESTSEQ_U_TESTNUM_U_TESTNAME
.S ^TMP("ORQQV",$J,"TEST",TESTSEQ)=LINE
.S OUTCNT=OUTCNT+1
.S ^TMP("ORQQVX",$J,"OUTPUT",OUTCNT)=LINE
S ^TMP("ORQQVX",$J,"OUTPUT",1)=TESTSEQ
S EDATE=EDATE\1
S EDT=EDATE
S TESTSEQ=0 F S TESTSEQ=$O(^TMP("ORQQV",$J,"TEST",TESTSEQ)) Q:TESTSEQ<1 S TESTNUM=$P(^(TESTSEQ),U,2) D
.S IDT=SDATE,(RCNT,RQUIT)=0
.F S IDT=$O(^PXRMINDX(120.5,"PI",DFN,TESTNUM,IDT)) Q:IDT<1 Q:IDT>EDT D Q:RQUIT
..S DATANUM=0 F S DATANUM=$O(^PXRMINDX(120.5,"PI",DFN,TESTNUM,IDT,DATANUM)) Q:DATANUM<1 D Q:RQUIT
...D EN^GMVPXRM(.ZERO,DATANUM,"I")
...Q:$P(ZERO(1),U)=-1
...Q:$P(ZERO(2),U)'=DFN Q:$P(ZERO(3),U)'=TESTNUM
...S RESULT=$$STRIP^ORCMEDIT($P(ZERO(7),U)),DATETIME=$P(ZERO(1),U)
...S ^TMP("ORQQV",$J,"RESULTS",IDT)=DATETIME
...S ^TMP("ORQQV",$J,"RESULTS",IDT,TESTSEQ)=RESULT
...I RTIMES S RCNT=RCNT+1 I RCNT=RTIMES S RQUIT=1
S (DATESEQ,RCNT,RQUIT,VCNT)=0
S IDT="A" F S IDT=$O(^TMP("ORQQV",$J,"RESULTS",IDT),-1) Q:IDT="" S DATETIME=^(IDT) D Q:RQUIT
.S DATESEQ=DATESEQ+1
.S OUTCNT=OUTCNT+1
.S ^TMP("ORQQVX",$J,"OUTPUT",OUTCNT)=DATESEQ_U_DATETIME
.S TESTSEQ=0 F S TESTSEQ=$O(^TMP("ORQQV",$J,"RESULTS",IDT,TESTSEQ)) Q:TESTSEQ<1 S RESULT=^(TESTSEQ) D
..S VCNT=VCNT+1
..S ^TMP("ORQQV",$J,"VALUES",VCNT)=DATESEQ_U_TESTSEQ_U_RESULT
.I RTIMES S RCNT=RCNT+1 I RCNT=RTIMES S RQUIT=1
S $P(^TMP("ORQQVX",$J,"OUTPUT",1),U,2,3)=DATESEQ_U_VCNT
S VCNT=0 F S VCNT=$O(^TMP("ORQQV",$J,"VALUES",VCNT)) Q:VCNT<1 S VALUES=^(VCNT) D
.S OUTCNT=OUTCNT+1
.S ^TMP("ORQQVX",$J,"OUTPUT",OUTCNT)=VALUES
K ^TMP("ORQQV",$J)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORQQVI1 6963 printed Oct 16, 2024@18:34:24 Page 2
ORQQVI1 ;SLC/STAFF- Vitals rpc grid ;2/4/99 21:11
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,285**;Dec 17, 1997;Build 5
+2 ;
+3 ;DBIA for PXRMINDX(120.5 is 4290
+4 ;DBIA for ^GMVPXRM is 3647
TEST ; test use only
+1 NEW CNT,I
KILL ^TMP("ORQQVX",$JOB)
+2 SET ^TMP("ORQQVX",$JOB,"INPUT",1)="16^2970902^2920202^3"
+3 SET CNT=1
+4 FOR I="WEIGHT","RESPIRATION","PULSE","HEIGHT"
SET CNT=CNT+1
SET ^TMP("ORQQVX",$JOB,"INPUT",CNT)=I
+5 DO GRIDDATA
+6 SET I=0
FOR
SET I=$ORDER(^TMP("ORQQVX",$JOB,"OUTPUT",I))
if I<1
QUIT
WRITE !,^(I)
+7 KILL ^TMP("ORQQVX",$JOB)
+8 QUIT
+9 ;
DETAIL(ROOT,DFN,DATE1,DATE2,RTIMES,TESTS) ; from Remote Procedure file
+1 NEW CNT,NUM,TEMPDATE
+2 IF DATE1<DATE2
SET TEMPDATE=DATE1
SET DATE1=DATE2
SET DATE2=TEMPDATE
+3 KILL ^TMP("ORQQVX",$JOB,"INPUT"),^("OUTPUT")
+4 SET ROOT=$NAME(^TMP("ORQQVX",$JOB,"OUTPUT"))
+5 SET ^TMP("ORQQVX",$JOB,"INPUT",1)=DFN_U_DATE1_U_DATE2_U_RTIMES
+6 SET CNT=1
SET NUM=0
FOR
SET NUM=$ORDER(TESTS(NUM))
if NUM<1
QUIT
Begin DoDot:1
+7 SET CNT=CNT+1
+8 SET ^TMP("ORQQVX",$JOB,"INPUT",CNT)=TESTS(NUM)
End DoDot:1
+9 DO MEMODATA
+10 QUIT
+11 ;
MEMODATA ;
+1 ; input format
+2 ; ^TMP("ORQQVX",$J,"INPUT",1)=dfn^start date^end date^restrict # time values
+3 ; ^TMP("ORQQVX",$J,"INPUT",#)=test# (tests displayed in this order)
+4 ;
+5 SET ^TMP("ORQQVX",$JOB,"OUTPUT",1)=""
+6 NEW CHECKOK,DATANUM,DATESEQ,DATETIME,DFN,EDATE,EDT,ENTERBY,IDT,LINE,LINE1,LOC,MAIN,NUM,OUTCNT,RCNT,RQUIT,RESULT,RTIMES,SDATE,TESTNAME,TESTNUM,TESTSEQ,VCNT,ZERO
+7 KILL ^TMP("ORQQV",$JOB)
+8 SET DFN=+^TMP("ORQQVX",$JOB,"INPUT",1)
SET SDATE=+$PIECE(^(1),U,2)
SET EDATE=+$PIECE(^(1),U,3)
SET RTIMES=+$PIECE(^(1),U,4)
+9 if 'DFN
QUIT
IF 'SDATE
IF 'EDATE
IF 'RTIMES
QUIT
+10 IF RTIMES
IF 'SDATE
IF 'EDATE
SET SDATE=DT
SET EDATE=2750101
+11 IF SDATE
IF 'EDATE
QUIT
+12 IF EDATE
IF 'SDATE
QUIT
+13 SET OUTCNT=1
SET TESTSEQ=0
+14 SET NUM=1
FOR
SET NUM=$ORDER(^TMP("ORQQVX",$JOB,"INPUT",NUM))
if NUM<1
QUIT
SET TESTNAME=^(NUM)
Begin DoDot:1
+15 SET TESTNAME=$$UP^XLFSTR(TESTNAME)
+16 SET TESTNUM=$$FIND1^DIC(120.51,"","BX",TESTNAME,"","","ERR")
+17 IF 'TESTNUM
QUIT
+18 SET TESTSEQ=TESTSEQ+1
+19 SET LINE=TESTSEQ_U_TESTNUM_U_$$MIXED^ORU(TESTNAME)
+20 SET ^TMP("ORQQV",$JOB,"TEST",TESTSEQ)=LINE
+21 SET OUTCNT=OUTCNT+1
End DoDot:1
+22 SET EDATE=EDATE\1
+23 SET TESTSEQ=0
FOR
SET TESTSEQ=$ORDER(^TMP("ORQQV",$JOB,"TEST",TESTSEQ))
if TESTSEQ<1
QUIT
SET TESTNUM=$PIECE(^(TESTSEQ),U,2)
Begin DoDot:1
+24 SET IDT=SDATE
SET (RCNT,RQUIT)=0
+25 FOR
SET IDT=$ORDER(^PXRMINDX(120.5,"PI",DFN,TESTNUM,SDATE))
if IDT<1
QUIT
if IDT>EDATE
QUIT
Begin DoDot:2
+26 SET DATANUM=""
FOR
SET DATANUM=$ORDER(^PXRMINDX(120.5,"PI",DFN,TESTNUM,SDATE,DATANUM))
if $LENGTH(DATANUM)'>0
QUIT
Begin DoDot:3
+27 DO EN^GMVPXRM(.ZERO,DATANUM,"I")
+28 if $PIECE(ZERO(1),U)=-1
QUIT
+29 if $PIECE(ZERO(2),U)'=DFN
QUIT
if $PIECE(ZERO(3),U)'=TESTNUM
QUIT
+30 SET RESULT=$$STRIP^ORCMEDIT($PIECE(ZERO(7),U))
SET DATETIME=$PIECE(ZERO(1),U)
SET LOC=+$PIECE(ZERO(5),U)
SET ENTERBY=+$PIECE(ZERO(6),U)
+31 ;$$FMTE^XLFDT(DATETIME)_" Location: "_$P($G(^SC(+LOC,0)),U)_" Entered by: "_$P($G(^VA(200,+ENTERBY,0)),U)
SET ^TMP("ORQQV",$JOB,"RESULTS",IDT)=DATETIME_U_LOC_U_ENTERBY
+32 SET LINE=" "_$PIECE(^TMP("ORQQV",$JOB,"TEST",TESTSEQ),U,3)
+33 SET LINE=$$SETSTR^VALM1(RESULT,LINE,22,1+$LENGTH(RESULT))_U_LOC_U_ENTERBY
+34 SET ^TMP("ORQQV",$JOB,"RESULTS",IDT,TESTSEQ)=LINE
+35 IF RTIMES
SET RCNT=RCNT+1
IF RCNT=RTIMES
SET RQUIT=1
End DoDot:3
if RQUIT
QUIT
End DoDot:2
if RQUIT
QUIT
End DoDot:1
+36 SET (DATESEQ,RCNT,RQUIT,VCNT)=0
+37 SET IDT=0
FOR
SET IDT=$ORDER(^TMP("ORQQV",$JOB,"RESULTS",IDT))
if IDT<1
QUIT
SET LINE=^(IDT)
Begin DoDot:1
+38 SET CHECKOK=1
Begin DoDot:2
+39 SET MAIN=$PIECE(LINE,U,2,3)
+40 SET TESTSEQ=0
FOR
SET TESTSEQ=$ORDER(^TMP("ORQQV",$JOB,"RESULTS",IDT,TESTSEQ))
if TESTSEQ<1
QUIT
SET RESULT=$PIECE(^(TESTSEQ),U,2,3)
IF RESULT'=MAIN
SET CHECKOK=0
QUIT
End DoDot:2
+41 IF CHECKOK
Begin DoDot:2
+42 SET DATETIME=$$FMTE^XLFDT($PIECE(LINE,U))
SET DATETIME=$PIECE(DATETIME,":",1,2)
+43 SET DATETIME=DATETIME_" Location: "_$PIECE($GET(^SC($PIECE(LINE,U,2),0)),U)
+44 SET DATETIME=$$SETSTR^VALM1(" Entered by: "_$PIECE($GET(^VA(200,$PIECE(LINE,U,3),0)),U),DATETIME,50,30)
End DoDot:2
+45 IF '$TEST
SET DATETIME=$$FMTE^XLFDT($PIECE(LINE,U))
SET DATETIME=$PIECE(DATETIME,":",1,2)
+46 SET DATESEQ=DATESEQ+1
+47 SET OUTCNT=OUTCNT+1
+48 SET ^TMP("ORQQVX",$JOB,"OUTPUT",OUTCNT)=DATETIME
+49 SET TESTSEQ=0
FOR
SET TESTSEQ=$ORDER(^TMP("ORQQV",$JOB,"RESULTS",IDT,TESTSEQ))
if TESTSEQ<1
QUIT
SET LINE1=^(TESTSEQ)
Begin DoDot:2
+50 IF CHECKOK
SET RESULT=$PIECE(LINE1,U)
+51 IF '$TEST
Begin DoDot:3
+52 SET RESULT=$$SETSTR^VALM1(" Location: "_$PIECE($GET(^SC($PIECE(LINE1,U,2),0)),U),$PIECE(LINE1,U),30,25)
+53 SET RESULT=$$SETSTR^VALM1(" Entered by; "_$PIECE($GET(^VA(200,$PIECE(LINE1,U,3),0)),U),RESULT,50,30)
End DoDot:3
+54 SET OUTCNT=OUTCNT+1
+55 SET ^TMP("ORQQVX",$JOB,"OUTPUT",OUTCNT)=RESULT
End DoDot:2
+56 IF RTIMES
SET RCNT=RCNT+1
IF RCNT=RTIMES
SET RQUIT=1
End DoDot:1
if RQUIT
QUIT
+57 KILL ^TMP("ORQQV",$JOB)
+58 QUIT
+59 ;
GRID(ROOT,DFN,DATE1,DATE2,RTIMES,TESTS) ; from Remote Procedure file
+1 NEW CNT,NUM,TEMPDATE
+2 IF DATE1<DATE2
SET TEMPDATE=DATE1
SET DATE1=DATE2
SET DATE2=TEMPDATE
+3 KILL ^TMP("ORQQVX",$JOB,"INPUT"),^("OUTPUT")
+4 SET ROOT=$NAME(^TMP("ORQQVX",$JOB,"OUTPUT"))
+5 SET ^TMP("ORQQVX",$JOB,"INPUT",1)=DFN_U_DATE1_U_DATE2_U_RTIMES
+6 SET CNT=1
SET NUM=0
FOR
SET NUM=$ORDER(TESTS(NUM))
if NUM<1
QUIT
Begin DoDot:1
+7 SET CNT=CNT+1
+8 SET ^TMP("ORQQVX",$JOB,"INPUT",CNT)=TESTS(NUM)
End DoDot:1
+9 DO GRIDDATA
+10 QUIT
+11 ;
GRIDDATA ;
+1 ; input format
+2 ; ^TMP("ORQQVX",$J,"INPUT",1)=dfn^start date^end date^restrict # time values
+3 ; ^TMP("ORQQVX",$J,"INPUT",#)=test# (tests displayed in this order)
+4 ;
+5 SET ^TMP("ORQQVX",$JOB,"OUTPUT",1)="0^0^0"
+6 NEW DATANUM,DATESEQ,DATETIME,DFN,EDATE,EDT,IDT,LINE,NUM,OUTCNT,RCNT,RQUIT,RESULT,RTIMES,SDATE,TESTNAME,TESTNUM,TESTSEQ,VALUES,VCNT,ZERO
+7 KILL ^TMP("ORQQV",$JOB)
+8 SET DFN=+^TMP("ORQQVX",$JOB,"INPUT",1)
SET SDATE=+$PIECE(^(1),U,2)
SET EDATE=+$PIECE(^(1),U,3)
SET RTIMES=+$PIECE(^(1),U,4)
+9 if 'DFN
QUIT
IF 'SDATE
IF 'EDATE
IF 'RTIMES
QUIT
+10 IF RTIMES
IF 'SDATE
IF 'EDATE
SET SDATE=DT
SET EDATE=2750101
+11 IF SDATE
IF 'EDATE
QUIT
+12 IF EDATE
IF 'SDATE
QUIT
+13 SET OUTCNT=1
SET TESTSEQ=0
+14 SET NUM=1
FOR
SET NUM=$ORDER(^TMP("ORQQVX",$JOB,"INPUT",NUM))
if NUM<1
QUIT
SET TESTNAME=^(NUM)
Begin DoDot:1
+15 SET TESTNAME=$$UP^XLFSTR(TESTNAME)
+16 SET TESTNUM=$$FIND1^DIC(120.51,"","BX",TESTNAME,"","","ERR")
+17 IF 'TESTNUM
QUIT
+18 SET TESTSEQ=TESTSEQ+1
+19 SET LINE=TESTSEQ_U_TESTNUM_U_TESTNAME
+20 SET ^TMP("ORQQV",$JOB,"TEST",TESTSEQ)=LINE
+21 SET OUTCNT=OUTCNT+1
+22 SET ^TMP("ORQQVX",$JOB,"OUTPUT",OUTCNT)=LINE
End DoDot:1
+23 SET ^TMP("ORQQVX",$JOB,"OUTPUT",1)=TESTSEQ
+24 SET EDATE=EDATE\1
+25 SET EDT=EDATE
+26 SET TESTSEQ=0
FOR
SET TESTSEQ=$ORDER(^TMP("ORQQV",$JOB,"TEST",TESTSEQ))
if TESTSEQ<1
QUIT
SET TESTNUM=$PIECE(^(TESTSEQ),U,2)
Begin DoDot:1
+27 SET IDT=SDATE
SET (RCNT,RQUIT)=0
+28 FOR
SET IDT=$ORDER(^PXRMINDX(120.5,"PI",DFN,TESTNUM,IDT))
if IDT<1
QUIT
if IDT>EDT
QUIT
Begin DoDot:2
+29 SET DATANUM=0
FOR
SET DATANUM=$ORDER(^PXRMINDX(120.5,"PI",DFN,TESTNUM,IDT,DATANUM))
if DATANUM<1
QUIT
Begin DoDot:3
+30 DO EN^GMVPXRM(.ZERO,DATANUM,"I")
+31 if $PIECE(ZERO(1),U)=-1
QUIT
+32 if $PIECE(ZERO(2),U)'=DFN
QUIT
if $PIECE(ZERO(3),U)'=TESTNUM
QUIT
+33 SET RESULT=$$STRIP^ORCMEDIT($PIECE(ZERO(7),U))
SET DATETIME=$PIECE(ZERO(1),U)
+34 SET ^TMP("ORQQV",$JOB,"RESULTS",IDT)=DATETIME
+35 SET ^TMP("ORQQV",$JOB,"RESULTS",IDT,TESTSEQ)=RESULT
+36 IF RTIMES
SET RCNT=RCNT+1
IF RCNT=RTIMES
SET RQUIT=1
End DoDot:3
if RQUIT
QUIT
End DoDot:2
if RQUIT
QUIT
End DoDot:1
+37 SET (DATESEQ,RCNT,RQUIT,VCNT)=0
+38 SET IDT="A"
FOR
SET IDT=$ORDER(^TMP("ORQQV",$JOB,"RESULTS",IDT),-1)
if IDT=""
QUIT
SET DATETIME=^(IDT)
Begin DoDot:1
+39 SET DATESEQ=DATESEQ+1
+40 SET OUTCNT=OUTCNT+1
+41 SET ^TMP("ORQQVX",$JOB,"OUTPUT",OUTCNT)=DATESEQ_U_DATETIME
+42 SET TESTSEQ=0
FOR
SET TESTSEQ=$ORDER(^TMP("ORQQV",$JOB,"RESULTS",IDT,TESTSEQ))
if TESTSEQ<1
QUIT
SET RESULT=^(TESTSEQ)
Begin DoDot:2
+43 SET VCNT=VCNT+1
+44 SET ^TMP("ORQQV",$JOB,"VALUES",VCNT)=DATESEQ_U_TESTSEQ_U_RESULT
End DoDot:2
+45 IF RTIMES
SET RCNT=RCNT+1
IF RCNT=RTIMES
SET RQUIT=1
End DoDot:1
if RQUIT
QUIT
+46 SET $PIECE(^TMP("ORQQVX",$JOB,"OUTPUT",1),U,2,3)=DATESEQ_U_VCNT
+47 SET VCNT=0
FOR
SET VCNT=$ORDER(^TMP("ORQQV",$JOB,"VALUES",VCNT))
if VCNT<1
QUIT
SET VALUES=^(VCNT)
Begin DoDot:1
+48 SET OUTCNT=OUTCNT+1
+49 SET ^TMP("ORQQVX",$JOB,"OUTPUT",OUTCNT)=VALUES
End DoDot:1
+50 KILL ^TMP("ORQQV",$JOB)
+51 QUIT