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

ORQQVI1.m

Go to the documentation of this file.
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