VENPCCMF ; IHS/OIT/GIS - QUEUEING FILE VIEWER ;
;;2.6;PCC+;;NOV 12, 2007
;
;
;
QUEUE W:$D(IOF) @IOF G RUN ; EP-STARTUP
;
RANGE(LINE,END,MAX) ; EP-RETURN A RANGE OF LINES
I LINE=1,END'>MAX Q 1_U_END
I LINE=1 Q 1_U_MAX
I END<(LINE+MAX) Q (END-MAX+1)_U_END
Q (LINE+1)_U_(LINE+MAX)
;
LIST(HR,CIEN) ; EP-GIVEN HRS & SUPERBILL DEPT IEN, RETURN IN ^TMP ARRAY ALL LINES
I '$G(HR) Q ""
I '$D(^VEN(7.95,CIEN,0)) Q ""
N TMP,TOT,TIME,DFN,CLINIC,STATUS,QIEN,TTOT,%,%I,%H,X,PATIENT,ELAP
S TMP="^TMP(""VEN LINES"",$J)" K @TMP
S TIME=+$$AGO(HR)
S (TOT,TTOT)=0
ARR F S TIME=$O(^VEN(7.2,"B",TIME)) Q:'TIME S QIEN=0 F S QIEN=$O(^VEN(7.2,"B",TIME,QIEN)) Q:'QIEN D
. S X=$G(^VEN(7.2,QIEN,0))
. S STATUS=$P(X,U,5) I STATUS'=1 Q
. S CLINIC=$P(X,U,4) I CLINIC'=CIEN Q
. S DFN=+$G(^VEN(7.2,QIEN,1)) I '$D(^DPT(DFN,0)) Q
. D NOW^%DTC
. S %=$$TIME(TIME,%) S ELAP=$P(%,U),TTOT=TTOT+$P(%,U,2)
. S PATIENT=$P($G(^DPT(+$G(DFN),0)),U)
. S PATIENT=PATIENT_" ("_$$CHART^VENPCC1A(CIEN,DFN)_")"
. S TOT=TOT+1
. S @TMP@(TOT)=PATIENT_" "_ELAP_U_QIEN
. Q
S ATIME="0 min"
I $G(TTOT),$G(TOT) S ATIME=(TTOT\TOT)_" min"
Q
;
RUN ;
N TMP,DIC,CIEN,HR,CNT,CNAME,LINE,END,MAX,FIN,START,X,Y,%,CNT,ATIME,I,DIE,DA,DR,D,D0,DI,DQ
S TMP="^TMP(""VEN LINES"",$J)" K @TMP
S DIC("A")="Patient list: ",DIC(0)="AEQ",DIC="^VEN(7.95,"
D ^DIC I Y=-1 Q
S CIEN=+Y,HR=6,CNT=0,CNAME=$P(Y,U,2),ATIME=0
START D LIST(HR,CIEN)
S LINE=1,MAX=20
LOOP S END=$O(@TMP@(99999),-1)
S %=$$RANGE(LINE,END,MAX)
S START=+%,FIN=$P(%,U,2)
I 'FIN W !!,"There are currently no patients in the queue",!! Q
I $D(IOF) W @IOF
W !!,CNAME," patients. Average waiting time ",ATIME," =>",!
F I=START:1:FIN W !,?3,I,")",?7,$P(@TMP@(I),U)
W !!
ASK W "Select a patient (",START,"-",FIN,") "
I END>FIN W "or press <ENTER> to see more choices"
W ": "
R X:60
E S CNT=CNT+1 G:CNT>60 HALT W:$D(IOF) @IOF G START ; REFRESH 60 TIMES THEN QUIT
S CNT=0
I X="",FIN<END S LINE=FIN G LOOP
I X="" G START
I X,X=X\1,X'<1,X'>FIN D STAT($P(@TMP@(X),U,2)) G START
I X=U Q
W " ??" G ASK
;
STAT(DA) ;
S DR=".05////0;.02////"_$$NOW^VENPCCU
S DIE="^VEN(7.2,"
L +^VEN(7.2,DA):0 I $T D ^DIE L -^VEN(7.2,DA)
Q
;
HALT ;
I CNT>60 W !,"No activity in the past hour. Terminating session."
Q
;
TIME(T1,T2) ; TIME DIFF
N X,Y,D,H,M,DUR
S DUR=$$FMDIFF^XLFDT(T2,T1,2)\60
S X=$$FMDIFF^XLFDT(T2,T1,3)
S D=+X
S Y=$P(X," ",2)
S H=+Y
S M=$P(Y,":",2)
I DUR<60 Q DUR_"m"_U_DUR
I 'D,H Q (H_"h "_M_"m"_U_DUR)
Q D_"d "_H_"h "_M_"m"_U_DUR
;
AGO(HRS) ;
N X,Y,Z
S X=$$HADD^XLFDT($H,0,-HRS,0,0)
S Y=$$HTFM^XLFDT(X)
S Z=$E($P(Y,".",2),1,4)
Q Y\1_"."_Z
;
RPT ; EP-PRINT A REPORT
N DIC,X,Y,%,BY,FR,TO,DHD,L,IOP
S %=$O(^VEN(7.95,"B","MEDICAL RECORDS","")) S DIS(0)="I $P($G(^VEN(7.2,D0,0)),U,4)'="_+%
S DIC="^VEN(7.2,",L=0,BY="+QUEUE DESTINATION,TIME IN",FLDS="[VEN CHECKIN LIST 2.5]",DHD="PCC+ CHECKIN LIST"
S (FR,TO)=",?"
D EN1^DIP
Q
;
DATES(PATIENT) ; EP-GET DATES FOR LAST DEMOG UPDATE AND REVIEW
N TXT,X,Y,%,STOP,SP,RDT,UDT,RD,UD
S (TXT,SP)=" ",(RDT,UDT)="NONE",(RD,UD)=""
S %=99999999999
F S %=$O(^VEN(7.2,"AP",PATIENT,%),-1) Q:'% S (Y,RD)=$P($G(^VEN(7.2,%,1)),U,4) I Y X ^DD("DD") I $L(Y) S RDT=Y Q
S (Y,UD)=$P($G(^AUPNPAT(PATIENT,0)),U,3) I Y X ^DD("DD") I $L(Y) S UDT=Y
I UD>RD S RDT=UDT
S TXT=TXT_"Last demographics review: "_RDT_SP
S TXT=TXT_"Last demographics update: "_UDT
Q TXT
;
SPEC ; EP-SPECIAL LIST
N DIC,X,Y,%,BY,FR,TO,DHD,L,IOP
S %=$O(^VEN(7.95,"B","MEDICAL RECORDS","")) S DIS(0)="I $P($G(^VEN(7.2,D0,0)),U,4)'="_+%
S DIC="^VEN(7.2,",L=0,BY="[TEST CLINIC GRP],+QUEUE DESTINATION,TIME IN",FLDS="[VEN CHECKIN LIST]",DHD="PCC+ CHECKIN LIST"
S (FR,TO)=",,?"
D EN1^DIP
Q
;
VENPCCMF ; IHS/OIT/GIS - QUEUEING FILE VIEWER ;
+1 ;;2.6;PCC+;;NOV 12, 2007
+2 ;
+3 ;
+4 ;
QUEUE ; EP-STARTUP
IF $DATA(IOF)
WRITE @IOF
GOTO RUN
+1 ;
RANGE(LINE,END,MAX) ; EP-RETURN A RANGE OF LINES
+1 IF LINE=1
IF END'>MAX
QUIT 1_U_END
+2 IF LINE=1
QUIT 1_U_MAX
+3 IF END<(LINE+MAX)
QUIT (END-MAX+1)_U_END
+4 QUIT (LINE+1)_U_(LINE+MAX)
+5 ;
LIST(HR,CIEN) ; EP-GIVEN HRS & SUPERBILL DEPT IEN, RETURN IN ^TMP ARRAY ALL LINES
+1 IF '$GET(HR)
QUIT ""
+2 IF '$DATA(^VEN(7.95,CIEN,0))
QUIT ""
+3 NEW TMP,TOT,TIME,DFN,CLINIC,STATUS,QIEN,TTOT,%,%I,%H,X,PATIENT,ELAP
+4 SET TMP="^TMP(""VEN LINES"",$J)"
KILL @TMP
+5 SET TIME=+$$AGO(HR)
+6 SET (TOT,TTOT)=0
ARR FOR
SET TIME=$ORDER(^VEN(7.2,"B",TIME))
IF 'TIME
QUIT
SET QIEN=0
FOR
SET QIEN=$ORDER(^VEN(7.2,"B",TIME,QIEN))
IF 'QIEN
QUIT
Begin DoDot:1
+1 SET X=$GET(^VEN(7.2,QIEN,0))
+2 SET STATUS=$PIECE(X,U,5)
IF STATUS'=1
QUIT
+3 SET CLINIC=$PIECE(X,U,4)
IF CLINIC'=CIEN
QUIT
+4 SET DFN=+$GET(^VEN(7.2,QIEN,1))
IF '$DATA(^DPT(DFN,0))
QUIT
+5 DO NOW^%DTC
+6 SET %=$$TIME(TIME,%)
SET ELAP=$PIECE(%,U)
SET TTOT=TTOT+$PIECE(%,U,2)
+7 SET PATIENT=$PIECE($GET(^DPT(+$GET(DFN),0)),U)
+8 SET PATIENT=PATIENT_" ("_$$CHART^VENPCC1A(CIEN,DFN)_")"
+9 SET TOT=TOT+1
+10 SET @TMP@(TOT)=PATIENT_" "_ELAP_U_QIEN
+11 QUIT
End DoDot:1
+12 SET ATIME="0 min"
+13 IF $GET(TTOT)
IF $GET(TOT)
SET ATIME=(TTOT\TOT)_" min"
+14 QUIT
+15 ;
RUN ;
+1 NEW TMP,DIC,CIEN,HR,CNT,CNAME,LINE,END,MAX,FIN,START,X,Y,%,CNT,ATIME,I,DIE,DA,DR,D,D0,DI,DQ
+2 SET TMP="^TMP(""VEN LINES"",$J)"
KILL @TMP
+3 SET DIC("A")="Patient list: "
SET DIC(0)="AEQ"
SET DIC="^VEN(7.95,"
+4 DO ^DIC
IF Y=-1
QUIT
+5 SET CIEN=+Y
SET HR=6
SET CNT=0
SET CNAME=$PIECE(Y,U,2)
SET ATIME=0
START DO LIST(HR,CIEN)
+1 SET LINE=1
SET MAX=20
LOOP SET END=$ORDER(@TMP@(99999),-1)
+1 SET %=$$RANGE(LINE,END,MAX)
+2 SET START=+%
SET FIN=$PIECE(%,U,2)
+3 IF 'FIN
WRITE !!,"There are currently no patients in the queue",!!
QUIT
+4 IF $DATA(IOF)
WRITE @IOF
+5 WRITE !!,CNAME," patients. Average waiting time ",ATIME," =>",!
+6 FOR I=START:1:FIN
WRITE !,?3,I,")",?7,$PIECE(@TMP@(I),U)
+7 WRITE !!
ASK WRITE "Select a patient (",START,"-",FIN,") "
+1 IF END>FIN
WRITE "or press <ENTER> to see more choices"
+2 WRITE ": "
+3 READ X:60
+4 ; REFRESH 60 TIMES THEN QUIT
IF '$TEST
SET CNT=CNT+1
IF CNT>60
GOTO HALT
IF $DATA(IOF)
WRITE @IOF
GOTO START
+5 SET CNT=0
+6 IF X=""
IF FIN<END
SET LINE=FIN
GOTO LOOP
+7 IF X=""
GOTO START
+8 IF X
IF X=X\1
IF X'<1
IF X'>FIN
DO STAT($PIECE(@TMP@(X),U,2))
GOTO START
+9 IF X=U
QUIT
+10 WRITE " ??"
GOTO ASK
+11 ;
STAT(DA) ;
+1 SET DR=".05////0;.02////"_$$NOW^VENPCCU
+2 SET DIE="^VEN(7.2,"
+3 LOCK +^VEN(7.2,DA):0
IF $TEST
DO ^DIE
LOCK -^VEN(7.2,DA)
+4 QUIT
+5 ;
HALT ;
+1 IF CNT>60
WRITE !,"No activity in the past hour. Terminating session."
+2 QUIT
+3 ;
TIME(T1,T2) ; TIME DIFF
+1 NEW X,Y,D,H,M,DUR
+2 SET DUR=$$FMDIFF^XLFDT(T2,T1,2)\60
+3 SET X=$$FMDIFF^XLFDT(T2,T1,3)
+4 SET D=+X
+5 SET Y=$PIECE(X," ",2)
+6 SET H=+Y
+7 SET M=$PIECE(Y,":",2)
+8 IF DUR<60
QUIT DUR_"m"_U_DUR
+9 IF 'D
IF H
QUIT (H_"h "_M_"m"_U_DUR)
+10 QUIT D_"d "_H_"h "_M_"m"_U_DUR
+11 ;
AGO(HRS) ;
+1 NEW X,Y,Z
+2 SET X=$$HADD^XLFDT($HOROLOG,0,-HRS,0,0)
+3 SET Y=$$HTFM^XLFDT(X)
+4 SET Z=$EXTRACT($PIECE(Y,".",2),1,4)
+5 QUIT Y\1_"."_Z
+6 ;
RPT ; EP-PRINT A REPORT
+1 NEW DIC,X,Y,%,BY,FR,TO,DHD,L,IOP
+2 SET %=$ORDER(^VEN(7.95,"B","MEDICAL RECORDS",""))
SET DIS(0)="I $P($G(^VEN(7.2,D0,0)),U,4)'="_+%
+3 SET DIC="^VEN(7.2,"
SET L=0
SET BY="+QUEUE DESTINATION,TIME IN"
SET FLDS="[VEN CHECKIN LIST 2.5]"
SET DHD="PCC+ CHECKIN LIST"
+4 SET (FR,TO)=",?"
+5 DO EN1^DIP
+6 QUIT
+7 ;
DATES(PATIENT) ; EP-GET DATES FOR LAST DEMOG UPDATE AND REVIEW
+1 NEW TXT,X,Y,%,STOP,SP,RDT,UDT,RD,UD
+2 SET (TXT,SP)=" "
SET (RDT,UDT)="NONE"
SET (RD,UD)=""
+3 SET %=99999999999
+4 FOR
SET %=$ORDER(^VEN(7.2,"AP",PATIENT,%),-1)
IF '%
QUIT
SET (Y,RD)=$PIECE($GET(^VEN(7.2,%,1)),U,4)
IF Y
XECUTE ^DD("DD")
IF $LENGTH(Y)
SET RDT=Y
QUIT
+5 SET (Y,UD)=$PIECE($GET(^AUPNPAT(PATIENT,0)),U,3)
IF Y
XECUTE ^DD("DD")
IF $LENGTH(Y)
SET UDT=Y
+6 IF UD>RD
SET RDT=UDT
+7 SET TXT=TXT_"Last demographics review: "_RDT_SP
+8 SET TXT=TXT_"Last demographics update: "_UDT
+9 QUIT TXT
+10 ;
SPEC ; EP-SPECIAL LIST
+1 NEW DIC,X,Y,%,BY,FR,TO,DHD,L,IOP
+2 SET %=$ORDER(^VEN(7.95,"B","MEDICAL RECORDS",""))
SET DIS(0)="I $P($G(^VEN(7.2,D0,0)),U,4)'="_+%
+3 SET DIC="^VEN(7.2,"
SET L=0
SET BY="[TEST CLINIC GRP],+QUEUE DESTINATION,TIME IN"
SET FLDS="[VEN CHECKIN LIST]"
SET DHD="PCC+ CHECKIN LIST"
+4 SET (FR,TO)=",,?"
+5 DO EN1^DIP
+6 QUIT
+7 ;