IBOUNP6 ;ALB/CJM - INPATIENT INSURANCE REPORT ;JAN 25,1991
;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
REPORT ;
N QUIT,DIV,TIME,DFN,CTG,HDR,HDR2,HDR1,PAGE,NOW,LINE1,LINE2,B,E,NAME,CRT,BOT,SUBTOT,TOTAL,FIRST,WRDN,WARD
S CRT=0,BOT=6,QUIT=0 I $E(IOST,1,2)="C-" S CRT=1,BOT=2
S FIRST=1
W:CRT @IOF
S HDR="VETERANS"
S LINE1="",$P(LINE1,"-",126)=""
S LINE2="",$P(LINE2,"=",126)=""
D NOW^%DTC S Y=X X ^DD("DD") S NOW=Y
I IBOPICK="D" S Y=IBOBEG X ^DD("DD") S B=Y,Y=IBOEND X ^DD("DD") S E=Y,HDR2="THAT WERE ADMITTED " S:E'=B HDR2=HDR2_"BETWEEN "_B_" AND "_E S:E=B HDR2=HDR2_"ON "_B
I IBOPICK="C" S HDR2="THAT ARE CURRENTLY ADMITTED"
I CRT W @IOF
I IBOUI S CTG="NO",HDR1=HDR_" WITH NO INSURANCE " D LOOP G:QUIT Q
I IBOEXP S CTG="EXPIRED",HDR1=HDR_" WHOSE INSURANCE IS EXPIRED OR WILL EXPIRE WITHIN 30 DAYS " D LOOP G:QUIT Q
I IBOUK S CTG="UNKNOWN",HDR1=HDR_" WHOSE INSURANCE IS UNKNOWN " D LOOP
I CRT,'QUIT D PAUSE
Q D KVAR^VADPT K VA
Q
LOOP ;
N NODE
S PAGE=1,(SUBTOT,TOTAL)=0 D HEADER Q:QUIT
S DIV="" F S DIV=$O(^TMP($J,CTG,DIV)) S TOTAL=TOTAL+SUBTOT,SUBTOT=0 Q:DIV=""!QUIT D:$Y>(IOSL-(BOT+4)) HEADER Q:QUIT W !!,?6,"Division: ",?31,DIV,!,LINE2,! D
.S WRDN="" F S WRDN=$O(^TMP($J,CTG,DIV,WRDN)) Q:QUIT D:WRDN=""&(SUBTOT>0) SUBTOT Q:WRDN="" D Q:QUIT
..I WRDN'="ALL WARDS" D Q:QUIT
...I $Y>(IOSL-(BOT+8)) D HEADER Q:QUIT
...W !,?6,"Ward: ",?31,WRDN,!
..S NAME="" F S NAME=$O(^TMP($J,CTG,DIV,WRDN,NAME)) Q:NAME="" D
...F DFN=0:0 S DFN=$O(^TMP($J,CTG,DIV,WRDN,NAME,DFN)) Q:QUIT!(DFN'>0) S NODE=^TMP($J,CTG,DIV,WRDN,NAME,DFN),TIME=$P(NODE,"^"),WARD=$P(NODE,"^",2) D ITEM
..I WRDN'="ALL WARDS" W !,LINE1
D:'QUIT TOTAL
Q
SUBTOT ; prints subtotal for division
I $Y+BOT>(IOSL-3) D HEADER
W !?3,"_________________"
W !,?3,"Subtotal: ",SUBTOT
Q
TOTAL ; prints total for all divisions
I $Y+BOT>(IOSL-3) D HEADER Q:QUIT
W !?3,"_________________"
W !?3,"Total: ",TOTAL
F Q:($Y>(IOSL-2)) W !
Q
ITEM ; prints patient data for a single appt
N CNT,TM,E1,E2,PID,MS,ES,SC,AGE,INS,I,VAPA S (E1,E2,PID,MS,ES,SC,AGE)="",CNT=2,SUBTOT=SUBTOT+1
DATA S Y=TIME X ^DD("DD") S TM=$P(Y,"@",1)_"@"_$E($P(Y,"@",2),1,5)
D DEM^VADPT I 'VAERR S MS=$P(VADM(10),"^",2),PID=VA("PID"),AGE=VADM(4)
D OPD^VADPT I 'VAERR S ES=$P(VAPD(7),"^",2)
D ELIG^VADPT I 'VAERR,+VAEL(3) S SC=$P(VAEL(3),"^",2)
CKSPACE ; tries to keep vet's data on same page
S VAPA("P")="" D ADD^VADPT I 'VAERR D
. F I=2,3,4 S:VAPA(I)]"" CNT=CNT+1
S VAOA("A")=5 D OAD^VADPT I 'VAERR S E1=VAOA(9) I E1]"" D
. S CNT=CNT+1
. F I=1,2,3,4,5,6,8 S E1(I)=VAOA(I)
. F I=1,2,3 S:VAOA(I)]"" CNT=CNT+1
S VAOA("A")=6 D OAD^VADPT I 'VAERR S E2=VAOA(9) I E2]"" D
. S CNT=CNT+1
. F I=1,2,3,4,5,6,8 S E2(I)=VAOA(I)
. F I=1,2,3 S:VAOA(I)]"" CNT=CNT+1
S CNT=$P($G(^DPT(DFN,.312,0)),"^",4)+CNT
I CNT>(IOSL-($Y+BOT)) D HEADER Q:QUIT
PRINT W !?3,$E(NAME,1,25),?31,PID,?51,TM,?74,AGE,?81,SC,?87,$E(MS,1,15),?104,$E(ES,1,20)
W !?5,WARD,?34,"Address:",?51,VAPA(1),?87,"Tele: ",?104,VAPA(8) W:VAPA(2)]"" !?51,VAPA(2) W:VAPA(3)]"" !?51,VAPA(3) W:VAPA(4)]"" !?51,VAPA(4)_","_$P($G(^DIC(5,+VAPA(5),0)),"^",2)_" "_VAPA(6)
I E1]"" W !?34,"Employer:",?51,E1,?87,"Tele: ",?104,E1(8) W:E1(1)]"" !?51,E1(1) W:E1(2)]"" !?51,E1(2) W:E1(3)]"" !?51,E1(3) W:E1(4)]"" !?51,E1(4)_","_$P($G(^DIC(5,+E1(5),0)),"^",2)_" "_E1(6)
I E2]"" W !?34,"Sps's Emplr:",?51,E2,?87,"Tele: ",?104,E2(8) W:E2(1)]"" !?51,E2(1) W:E2(2)]"" !?51,E2(2) W:E2(3)]"" !?51,E2(3) W:E2(4)]"" !?51,E2(4)_","_$P($G(^DIC(5,+E2(5),0)),"^",2)_" "_E2(6)
INS ; writes insurance data
N I,J S J=1 F I=0:0 S I=$O(^DPT(DFN,.312,I)) Q:I'>0 S INS=$G(^(I,0)) D:$Y>(IOSL-BOT) HEADER Q:QUIT W ! W:J ?34,"Insurance:" W ?51,$P($G(^DIC(36,$P(INS,"^",1),0)),"^",1),?87 W:J "Expiration:" S Y=$P(INS,"^",4),J=0 I Y>0 X ^DD("DD") W ?104,Y
W !
Q
I CRT,$Y>1,'FIRST D Q:QUIT
. F Q:$Y>(IOSL-1) W !
.D PAUSE
I 'FIRST W @IOF
I FIRST S FIRST=0
W ?104,NOW," PAGE ",PAGE,!?1,HDR1,HDR2,!!
W ?3,"PATIENT/WARD",?32,"PT ID",?51,"ADMISSION DATE",?74,"AGE",?81,"%SC",?87,"MARITAL STATUS",?104,"EMPLOYMENT STATUS",!
W LINE1
S PAGE=PAGE+1
Q
PAUSE ;
N T R " Press RETURN to continue",T:DTIME I '$T!(T["^") S QUIT=1 Q
Q
IBOUNP6 ;ALB/CJM - INPATIENT INSURANCE REPORT ;JAN 25,1991
+1 ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
REPORT ;
+1 NEW QUIT,DIV,TIME,DFN,CTG,HDR,HDR2,HDR1,PAGE,NOW,LINE1,LINE2,B,E,NAME,CRT,BOT,SUBTOT,TOTAL,FIRST,WRDN,WARD
+2 SET CRT=0
SET BOT=6
SET QUIT=0
IF $EXTRACT(IOST,1,2)="C-"
SET CRT=1
SET BOT=2
+3 SET FIRST=1
+4 IF CRT
WRITE @IOF
+5 SET HDR="VETERANS"
+6 SET LINE1=""
SET $PIECE(LINE1,"-",126)=""
+7 SET LINE2=""
SET $PIECE(LINE2,"=",126)=""
+8 DO NOW^%DTC
SET Y=X
XECUTE ^DD("DD")
SET NOW=Y
+9 IF IBOPICK="D"
SET Y=IBOBEG
XECUTE ^DD("DD")
SET B=Y
SET Y=IBOEND
XECUTE ^DD("DD")
SET E=Y
SET HDR2="THAT WERE ADMITTED "
IF E'=B
SET HDR2=HDR2_"BETWEEN "_B_" AND "_E
IF E=B
SET HDR2=HDR2_"ON "_B
+10 IF IBOPICK="C"
SET HDR2="THAT ARE CURRENTLY ADMITTED"
+11 IF CRT
WRITE @IOF
+12 IF IBOUI
SET CTG="NO"
SET HDR1=HDR_" WITH NO INSURANCE "
DO LOOP
IF QUIT
GOTO Q
+13 IF IBOEXP
SET CTG="EXPIRED"
SET HDR1=HDR_" WHOSE INSURANCE IS EXPIRED OR WILL EXPIRE WITHIN 30 DAYS "
DO LOOP
IF QUIT
GOTO Q
+14 IF IBOUK
SET CTG="UNKNOWN"
SET HDR1=HDR_" WHOSE INSURANCE IS UNKNOWN "
DO LOOP
+15 IF CRT
IF 'QUIT
DO PAUSE
Q DO KVAR^VADPT
KILL VA
+1 QUIT
LOOP ;
+1 NEW NODE
+2 SET PAGE=1
SET (SUBTOT,TOTAL)=0
DO HEADER
IF QUIT
QUIT
+3 SET DIV=""
FOR
SET DIV=$ORDER(^TMP($JOB,CTG,DIV))
SET TOTAL=TOTAL+SUBTOT
SET SUBTOT=0
IF DIV=""!QUIT
QUIT
IF $Y>(IOSL-(BOT+4))
DO HEADER
IF QUIT
QUIT
WRITE !!,?6,"Division: ",?31,DIV,!,LINE2,!
Begin DoDot:1
+4 SET WRDN=""
FOR
SET WRDN=$ORDER(^TMP($JOB,CTG,DIV,WRDN))
IF QUIT
QUIT
IF WRDN=""&(SUBTOT>0)
DO SUBTOT
IF WRDN=""
QUIT
Begin DoDot:2
+5 IF WRDN'="ALL WARDS"
Begin DoDot:3
+6 IF $Y>(IOSL-(BOT+8))
DO HEADER
IF QUIT
QUIT
+7 WRITE !,?6,"Ward: ",?31,WRDN,!
End DoDot:3
IF QUIT
QUIT
+8 SET NAME=""
FOR
SET NAME=$ORDER(^TMP($JOB,CTG,DIV,WRDN,NAME))
IF NAME=""
QUIT
Begin DoDot:3
+9 FOR DFN=0:0
SET DFN=$ORDER(^TMP($JOB,CTG,DIV,WRDN,NAME,DFN))
IF QUIT!(DFN'>0)
QUIT
SET NODE=^TMP($JOB,CTG,DIV,WRDN,NAME,DFN)
SET TIME=$PIECE(NODE,"^")
SET WARD=$PIECE(NODE,"^",2)
DO ITEM
End DoDot:3
+10 IF WRDN'="ALL WARDS"
WRITE !,LINE1
End DoDot:2
IF QUIT
QUIT
End DoDot:1
+11 IF 'QUIT
DO TOTAL
+12 QUIT
SUBTOT ; prints subtotal for division
+1 IF $Y+BOT>(IOSL-3)
DO HEADER
+2 WRITE !?3,"_________________"
+3 WRITE !,?3,"Subtotal: ",SUBTOT
+4 QUIT
TOTAL ; prints total for all divisions
+1 IF $Y+BOT>(IOSL-3)
DO HEADER
IF QUIT
QUIT
+2 WRITE !?3,"_________________"
+3 WRITE !?3,"Total: ",TOTAL
+4 FOR
IF ($Y>(IOSL-2))
QUIT
WRITE !
+5 QUIT
ITEM ; prints patient data for a single appt
+1 NEW CNT,TM,E1,E2,PID,MS,ES,SC,AGE,INS,I,VAPA
SET (E1,E2,PID,MS,ES,SC,AGE)=""
SET CNT=2
SET SUBTOT=SUBTOT+1
DATA SET Y=TIME
XECUTE ^DD("DD")
SET TM=$PIECE(Y,"@",1)_"@"_$EXTRACT($PIECE(Y,"@",2),1,5)
+1 DO DEM^VADPT
IF 'VAERR
SET MS=$PIECE(VADM(10),"^",2)
SET PID=VA("PID")
SET AGE=VADM(4)
+2 DO OPD^VADPT
IF 'VAERR
SET ES=$PIECE(VAPD(7),"^",2)
+3 DO ELIG^VADPT
IF 'VAERR
IF +VAEL(3)
SET SC=$PIECE(VAEL(3),"^",2)
CKSPACE ; tries to keep vet's data on same page
+1 SET VAPA("P")=""
DO ADD^VADPT
IF 'VAERR
Begin DoDot:1
+2 FOR I=2,3,4
IF VAPA(I)]""
SET CNT=CNT+1
End DoDot:1
+3 SET VAOA("A")=5
DO OAD^VADPT
IF 'VAERR
SET E1=VAOA(9)
IF E1]""
Begin DoDot:1
+4 SET CNT=CNT+1
+5 FOR I=1,2,3,4,5,6,8
SET E1(I)=VAOA(I)
+6 FOR I=1,2,3
IF VAOA(I)]""
SET CNT=CNT+1
End DoDot:1
+7 SET VAOA("A")=6
DO OAD^VADPT
IF 'VAERR
SET E2=VAOA(9)
IF E2]""
Begin DoDot:1
+8 SET CNT=CNT+1
+9 FOR I=1,2,3,4,5,6,8
SET E2(I)=VAOA(I)
+10 FOR I=1,2,3
IF VAOA(I)]""
SET CNT=CNT+1
End DoDot:1
+11 SET CNT=$PIECE($GET(^DPT(DFN,.312,0)),"^",4)+CNT
+12 IF CNT>(IOSL-($Y+BOT))
DO HEADER
IF QUIT
QUIT
PRINT WRITE !?3,$EXTRACT(NAME,1,25),?31,PID,?51,TM,?74,AGE,?81,SC,?87,$EXTRACT(MS,1,15),?104,$EXTRACT(ES,1,20)
+1 WRITE !?5,WARD,?34,"Address:",?51,VAPA(1),?87,"Tele: ",?104,VAPA(8)
IF VAPA(2)]""
WRITE !?51,VAPA(2)
IF VAPA(3)]""
WRITE !?51,VAPA(3)
IF VAPA(4)]""
WRITE !?51,VAPA(4)_","_$PIECE($GET(^DIC(5,+VAPA(5),0)),"^",2)_" "_VAPA(6)
+2 IF E1]""
WRITE !?34,"Employer:",?51,E1,?87,"Tele: ",?104,E1(8)
IF E1(1)]""
WRITE !?51,E1(1)
IF E1(2)]""
WRITE !?51,E1(2)
IF E1(3)]""
WRITE !?51,E1(3)
IF E1(4)]""
WRITE !?51,E1(4)_","_$PIECE($GET(^DIC(5,+E1(5),0)),"^",2)_" "_E1(6)
+3 IF E2]""
WRITE !?34,"Sps's Emplr:",?51,E2,?87,"Tele: ",?104,E2(8)
IF E2(1)]""
WRITE !?51,E2(1)
IF E2(2)]""
WRITE !?51,E2(2)
IF E2(3)]""
WRITE !?51,E2(3)
IF E2(4)]""
WRITE !?51,E2(4)_","_$PIECE($GET(^DIC(5,+E2(5),0)),"^",2)_" "_E2(6)
INS ; writes insurance data
+1 NEW I,J
SET J=1
FOR I=0:0
SET I=$ORDER(^DPT(DFN,.312,I))
IF I'>0
QUIT
SET INS=$GET(^(I,0))
IF $Y>(IOSL-BOT)
DO HEADER
IF QUIT
QUIT
WRITE !
IF J
WRITE ?34,"Insurance:"
WRITE ?51,$PIECE($GET(^DIC(36,$PIECE(INS,"^",1),0)),"^",1),?87
IF J
WRITE "Expiration:"
SET Y=$PIECE(INS,"^",4)
SET J=0
IF Y>0
XECUTE ^DD("DD")
WRITE ?104,Y
+2 WRITE !
+3 QUIT
+1 IF CRT
IF $Y>1
IF 'FIRST
Begin DoDot:1
+2 FOR
IF $Y>(IOSL-1)
QUIT
WRITE !
+3 DO PAUSE
End DoDot:1
IF QUIT
QUIT
+4 IF 'FIRST
WRITE @IOF
+5 IF FIRST
SET FIRST=0
+6 WRITE ?104,NOW," PAGE ",PAGE,!?1,HDR1,HDR2,!!
+7 WRITE ?3,"PATIENT/WARD",?32,"PT ID",?51,"ADMISSION DATE",?74,"AGE",?81,"%SC",?87,"MARITAL STATUS",?104,"EMPLOYMENT STATUS",!
+8 WRITE LINE1
+9 SET PAGE=PAGE+1
+10 QUIT
PAUSE ;
+1 NEW T
READ " Press RETURN to continue",T:DTIME
IF '$TEST!(T["^")
SET QUIT=1
QUIT
+2 QUIT