DG3PR2 ;ALB/MIR - CONTINUATION OF THE THIRD PARTY REIMBURSEMENT ; NOV 21 90@8
;;5.3;Registration;**26,606,617,570,1015**;Aug 13, 1993;Build 21
S DGINS=0 W !!,"INSURANCE TYPE",?24,"INSURANCE #",?45,"GROUP #",?63,"EXPIRES HOLDER",!,"--------- ----",?24,"--------- -",?45,"----- -",?63,"------- ------"
;570
;D ALL^IBCNS1(DFN,"DGIBINS") F I=0:0 S I=$O(DGIBINS(I)) Q:'I S J=DGIBINS(I,0) S X=$G(^DIC(36,+J,0)) W !,$S($P(X,"^",2)="N":"*",1:""),$E($P(X,"^",1),1,22),?24,$P(J,"^",2),?45,$P(J,"^",3) S DGINS=$S($P(X,"^",2)="N":1,1:0) D INS2
N DGX,DGDATA
;ihs/cmi/maw 2/7/2012 patch 1015 no IB in IHS
;I $$INSUR^IBBAPI(DFN,,"R",.DGDATA,"1,8,9,11,12,14,18")
;S DGX="DGDATA(""IBBAPI"",""INSUR"")" M DGIBINS=@DGX
;F I=0:0 S I=$O(DGIBINS(I)) Q:'I D
;. W !,$S('+DGIBINS(I,9):"*",1:" "),$E($P(DGIBINS(I,1),"^",2),1,22),?24,DGIBINS(I,14),?45
;. I $D(DGIBINS(I,18)) W $G(DGIBINS(I,18)) ; Group Policy number
;. S DGINS=$S($P(DGIBINS(I,9),U,2)="NO":1,1:0) D INS2
;
;I DGINS W !?22,"* - Insurer may not reimburse!"
;K DGINS,DGIBINS
S Y=+DGAD X ^DD("DD") W !!,"Admitted: ",Y,?40,"Discharged: " S Y=+DGDC I Y X ^DD("DD") W Y
I $P(DGAD,"^",18)=9 W !,"Transferred in From ",$S($D(^DIC(4,+$P(DGAD,"^",5),0)):$P(^(0),"^",1),1:"")
S DGPTF=$P(DGAD,"^",16) I 'DGPTF!('$D(^DGPT(+DGPTF,0))) W !,"No PTF Record Exists" Q
I '$D(^DGP(45.84,DGPTF)) W !,"PTF Record not closed",!
K ^UTILITY("DG") F I=0:0 S I=$O(^DGPT(DGPTF,"M",I)) Q:'I S J=^(I,0) S:$P(J,"^",2) ^UTILITY("DG",$J,"M",+$P(J,"^",10))=J
F I=0:0 S I=$O(^DGPT(DGPTF,"S",I)) Q:'I D HEAD:$Y>(IOSL-5) Q:'DGFL S J=^DGPT(DGPTF,"S",I,0),^UTILITY("DG",$J,"S",+J)=J
Q:'DGFL I $O(^UTILITY("DG",$J,"M",0)) W !!,"DATE",?22,"LOS BEDSECTION",?39,"LOS",?45,"DIAGNOSES",!,"----",?22,"---------------",?39,"---- ---------"
N DGDAT,DXD
S DGDAT=$P(^DGPT(DGPTF,0),"^",2)
S DGPR=DGAD F I=0:0 S I=$O(^UTILITY("DG",$J,"M",I)) Q:'I S J=^(I) D HEAD:$Y>(IOSL-5) Q:'DGFL S (DGDAT,Y)=I X ^DD("DD") D LOL W !,Y,?22,$E($S($D(^DIC(42.4,+$P(J,"^",2),0)):$P(^(0),"^",1),1:""),1,16),?39,$J(DGLOL,4) D DIAG S DGPR=I
;Q:'DGFL S DGPMIFN=DGCA D ^DGPMLOS W !?39,"---- ----------",!?26,"TOTAL LOS:",?39,$J(+$P(X,"^",5),4),?45,$S($D(^ICD9(+$S($D(^DGPT(DGPTF,70)):$P(^(70),"^",10),1:""),0)):"DXLS: "_$P(^(0),"^",1)_" ("_$P(^(0),"^",3)_")",1:"")
Q:'DGFL S DGPMIFN=DGCA
D ^DGPMLOS W !?39,"---- ----------",!?26,"TOTAL LOS:",?39,$J(+$P(X,"^",5),4) S DXD=+$S($D(^DGPT(DGPTF,70)):$P(^(70),"^",10),1:0),DXD=$S(+DXD:$$ICDDX^ICDCODE(DXD,DGDAT),1:"") W ?45,$S(+DXD>0:"DXLS: "_$P(DXD,"^",2)_" ("_$P(DXD,"^",4)_")",1:"")
Q:'$O(^UTILITY("DG",$J,"S",0)) D HEAD:$Y>(IOSL-10) Q:'DGFL W !!,"SURGERY DATE",?22,"SPECIALTY",?45,"OP CODES",!,"------------",?22,"----------",?44,"--------"
F I=0:0 S I=$O(^UTILITY("DG",$J,"S",I)) Q:'I S J=^(I),(DGDAT,Y)=I X ^DD("DD") W !,Y,?22,$E($S($D(^DIC(45.3,+$P(J,"^",3),0)):$P(^(0),"^",2),1:""),1,16) D OP
Q
DIAG S M=0 F K=5:1:15 I K'=10 S L=$P(J,"^",K) I L S DXD=$$ICDDX^ICDCODE(+L,$G(DGDAT)) W:M ! W ?45,$S(+DXD>0:$P(DXD,"^",2)_" ("_$P(DXD,"^",4)_")",1:"") S M=1
Q
OP S M=0 F K=8:1:12 S L=$P(J,"^",K) I L S DXD=$$ICDOP^ICDCODE(+L,$G(DGDAT)) W:M ! W ?45,$S(+DXD>0:$P(DXD,"^",2)_" ("_$P(DXD,"^",5)_")",1:"") S M=1
Q
LOL S X1=I,X2=DGPR D DTC S DGLOL=X
F K=DGPR+.0000005:0 S K=$O(^DGPM("APCA",DFN,DGCA,K)) Q:'K!(K>I) S C=$O(^(+K,0)) I $D(^DGPM(+C,0)),"^2^3^13^43^44^45^"[("^"_$P(^(0),"^",18)_"^") S X1=$O(^DGPM("APCA",DFN,DGCA,K)),X1=$S('X1:I,X1>I:I,1:X1),X2=K D DTC S DGLOL=DGLOL-X
Q
HEAD N I,J,K,L,M,Y I $E(IOST,1)="C" S DIR(0)="E" D ^DIR S DGFL=Y I 'DGFL Q
W @IOF,!,"THIRD PARTY REIMBURSEMENT",?49,"PRINTED: ",DGNOW
W !,"("_$P(^DPT(DFN,0),"^",1)_")",!
Q
INS2 ;insurance data continued
;570
N X
;I $P(X,"^",2)="N" S DGINS=1
;S X=$P(J,"^",4) W:X]"" ?63,$E(X,4,5),"/",$E(X,6,7),"/",$E(X,2,3) S X=$P(J,"^",6) W ?73,$S(X="v":"VETERAN",X="s":"SPOUSE",X="o":"OTHER",1:"UNKNOWN")
I $P(DGIBINS(I,9),U,2)="NO" S DGINS=1
S X=DGIBINS(I,11) W:X]"" ?63,$$FMTE^XLFDT(X,"2D")
S X=$P(DGIBINS(I,12),U) W ?73,$S(X="P":"VETERAN",X="S":"SPOUSE",X="O":"OTHER",1:"UNKNOWN")
Q
DTC N I,J,K,L,M,Y D ^%DTC Q
DG3PR2 ;ALB/MIR - CONTINUATION OF THE THIRD PARTY REIMBURSEMENT ; NOV 21 90@8
+1 ;;5.3;Registration;**26,606,617,570,1015**;Aug 13, 1993;Build 21
+2 SET DGINS=0
WRITE !!,"INSURANCE TYPE",?24,"INSURANCE #",?45,"GROUP #",?63,"EXPIRES HOLDER",!,"--------- ----",?24,"--------- -",?45,"----- -",?63,"------- ------"
+3 ;570
+4 ;D ALL^IBCNS1(DFN,"DGIBINS") F I=0:0 S I=$O(DGIBINS(I)) Q:'I S J=DGIBINS(I,0) S X=$G(^DIC(36,+J,0)) W !,$S($P(X,"^",2)="N":"*",1:""),$E($P(X,"^",1),1,22),?24,$P(J,"^",2),?45,$P(J,"^",3) S DGINS=$S($P(X,"^",2)="N":1,1:0) D INS2
+5 NEW DGX,DGDATA
+6 ;ihs/cmi/maw 2/7/2012 patch 1015 no IB in IHS
+7 ;I $$INSUR^IBBAPI(DFN,,"R",.DGDATA,"1,8,9,11,12,14,18")
+8 ;S DGX="DGDATA(""IBBAPI"",""INSUR"")" M DGIBINS=@DGX
+9 ;F I=0:0 S I=$O(DGIBINS(I)) Q:'I D
+10 ;. W !,$S('+DGIBINS(I,9):"*",1:" "),$E($P(DGIBINS(I,1),"^",2),1,22),?24,DGIBINS(I,14),?45
+11 ;. I $D(DGIBINS(I,18)) W $G(DGIBINS(I,18)) ; Group Policy number
+12 ;. S DGINS=$S($P(DGIBINS(I,9),U,2)="NO":1,1:0) D INS2
+13 ;
+14 ;I DGINS W !?22,"* - Insurer may not reimburse!"
+15 ;K DGINS,DGIBINS
+16 SET Y=+DGAD
XECUTE ^DD("DD")
WRITE !!,"Admitted: ",Y,?40,"Discharged: "
SET Y=+DGDC
IF Y
XECUTE ^DD("DD")
WRITE Y
+17 IF $PIECE(DGAD,"^",18)=9
WRITE !,"Transferred in From ",$SELECT($DATA(^DIC(4,+$PIECE(DGAD,"^",5),0)):$PIECE(^(0),"^",1),1:"")
+18 SET DGPTF=$PIECE(DGAD,"^",16)
IF 'DGPTF!('$DATA(^DGPT(+DGPTF,0)))
WRITE !,"No PTF Record Exists"
QUIT
+19 IF '$DATA(^DGP(45.84,DGPTF))
WRITE !,"PTF Record not closed",!
+20 KILL ^UTILITY("DG")
FOR I=0:0
SET I=$ORDER(^DGPT(DGPTF,"M",I))
IF 'I
QUIT
SET J=^(I,0)
IF $PIECE(J,"^",2)
SET ^UTILITY("DG",$JOB,"M",+$PIECE(J,"^",10))=J
+21 FOR I=0:0
SET I=$ORDER(^DGPT(DGPTF,"S",I))
IF 'I
QUIT
IF $Y>(IOSL-5)
DO HEAD
IF 'DGFL
QUIT
SET J=^DGPT(DGPTF,"S",I,0)
SET ^UTILITY("DG",$JOB,"S",+J)=J
+22 IF 'DGFL
QUIT
IF $ORDER(^UTILITY("DG",$JOB,"M",0))
WRITE !!,"DATE",?22,"LOS BEDSECTION",?39,"LOS",?45,"DIAGNOSES",!,"----",?22,"---------------",?39,"---- ---------"
+23 NEW DGDAT,DXD
+24 SET DGDAT=$PIECE(^DGPT(DGPTF,0),"^",2)
+25 SET DGPR=DGAD
FOR I=0:0
SET I=$ORDER(^UTILITY("DG",$JOB,"M",I))
IF 'I
QUIT
SET J=^(I)
IF $Y>(IOSL-5)
DO HEAD
IF 'DGFL
QUIT
SET (DGDAT,Y)=I
XECUTE ^DD("DD")
DO LOL
WRITE !,Y,?22,$EXTRACT($SELECT($DATA(^DIC(42.4,+$PIECE(J,"^",2),0)):$PIECE(^(0),"^",1),1:""),1,16),?39,$JUSTIFY(DGLOL,4)
DO DIAG
SET DGPR=I
+26 ;Q:'DGFL S DGPMIFN=DGCA D ^DGPMLOS W !?39,"---- ----------",!?26,"TOTAL LOS:",?39,$J(+$P(X,"^",5),4),?45,$S($D(^ICD9(+$S($D(^DGPT(DGPTF,70)):$P(^(70),"^",10),1:""),0)):"DXLS: "_$P(^(0),"^",1)_" ("_$P(^(0),"^",3)_")",1:"")
+27 IF 'DGFL
QUIT
SET DGPMIFN=DGCA
+28 DO ^DGPMLOS
WRITE !?39,"---- ----------",!?26,"TOTAL LOS:",?39,$JUSTIFY(+$PIECE(X,"^",5),4)
SET DXD=+$SELECT($DATA(^DGPT(DGPTF,70)):$PIECE(^(70),"^",10),1:0)
SET DXD=$SELECT(+DXD:$$ICDDX^ICDCODE(DXD,DGDAT),1:"")
WRITE ?45,$SELECT(+DXD>0:"DXLS: "_$PIECE(DXD,"^",2)_" ("_$PIECE(DXD,"^",4)_")",1:"")
+29 IF '$ORDER(^UTILITY("DG",$JOB,"S",0))
QUIT
IF $Y>(IOSL-10)
DO HEAD
IF 'DGFL
QUIT
WRITE !!,"SURGERY DATE",?22,"SPECIALTY",?45,"OP CODES",!,"------------",?22,"----------",?44,"--------"
+30 FOR I=0:0
SET I=$ORDER(^UTILITY("DG",$JOB,"S",I))
IF 'I
QUIT
SET J=^(I)
SET (DGDAT,Y)=I
XECUTE ^DD("DD")
WRITE !,Y,?22,$EXTRACT($SELECT($DATA(^DIC(45.3,+$PIECE(J,"^",3),0)):$PIECE(^(0),"^",2),1:""),1,16)
DO OP
+31 QUIT
DIAG SET M=0
FOR K=5:1:15
IF K'=10
SET L=$PIECE(J,"^",K)
IF L
SET DXD=$$ICDDX^ICDCODE(+L,$GET(DGDAT))
IF M
WRITE !
WRITE ?45,$SELECT(+DXD>0:$PIECE(DXD,"^",2)_" ("_$PIECE(DXD,"^",4)_")",1:"")
SET M=1
+1 QUIT
OP SET M=0
FOR K=8:1:12
SET L=$PIECE(J,"^",K)
IF L
SET DXD=$$ICDOP^ICDCODE(+L,$GET(DGDAT))
IF M
WRITE !
WRITE ?45,$SELECT(+DXD>0:$PIECE(DXD,"^",2)_" ("_$PIECE(DXD,"^",5)_")",1:"")
SET M=1
+1 QUIT
LOL SET X1=I
SET X2=DGPR
DO DTC
SET DGLOL=X
+1 FOR K=DGPR+.0000005:0
SET K=$ORDER(^DGPM("APCA",DFN,DGCA,K))
IF 'K!(K>I)
QUIT
SET C=$ORDER(^(+K,0))
IF $DATA(^DGPM(+C,0))
IF "^2^3^13^43^44^45^"[("^"_$PIECE(^(0),"^",18)_"^")
SET X1=$ORDER(^DGPM("APCA",DFN,DGCA,K))
SET X1=$SELECT('X1:I,X1>I:I,1:X1)
SET X2=K
DO DTC
SET DGLOL=DGLOL-X
+2 QUIT
HEAD NEW I,J,K,L,M,Y
IF $EXTRACT(IOST,1)="C"
SET DIR(0)="E"
DO ^DIR
SET DGFL=Y
IF 'DGFL
QUIT
+1 WRITE @IOF,!,"THIRD PARTY REIMBURSEMENT",?49,"PRINTED: ",DGNOW
+2 WRITE !,"("_$PIECE(^DPT(DFN,0),"^",1)_")",!
+3 QUIT
INS2 ;insurance data continued
+1 ;570
+2 NEW X
+3 ;I $P(X,"^",2)="N" S DGINS=1
+4 ;S X=$P(J,"^",4) W:X]"" ?63,$E(X,4,5),"/",$E(X,6,7),"/",$E(X,2,3) S X=$P(J,"^",6) W ?73,$S(X="v":"VETERAN",X="s":"SPOUSE",X="o":"OTHER",1:"UNKNOWN")
+5 IF $PIECE(DGIBINS(I,9),U,2)="NO"
SET DGINS=1
+6 SET X=DGIBINS(I,11)
IF X]""
WRITE ?63,$$FMTE^XLFDT(X,"2D")
+7 SET X=$PIECE(DGIBINS(I,12),U)
WRITE ?73,$SELECT(X="P":"VETERAN",X="S":"SPOUSE",X="O":"OTHER",1:"UNKNOWN")
+8 QUIT
DTC NEW I,J,K,L,M,Y
DO ^%DTC
QUIT