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

IBCOPV.m

Go to the documentation of this file.
IBCOPV	;ALB/LDB - ROUTINE TO LIST PATIENT VISITS ;30 APR 90
	;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
	;
	;MAP TO DGCROPV
	;
	S IBCOPV=^DGCR(399,IBIFN,"U"),IBCOPV1=$P(IBCOPV,"^"),IBCOPV2=$P(IBCOPV,"^",2) Q:'(IBCOPV1+IBCOPV2)
	S (DGCNT,DGU)=0 K DGCPT,^UTILITY($J),DGNOD F DGFIL=2,409.5 D CHK
	K ^UTILITY($J,"CPT",0),DGCOD F I1=9999999-(IBCOPV2+1):0 S I1=$O(^DPT(DFN,"DIS",I1)) Q:'I1!(I1>(9999999-(IBCOPV1)))  I $D(^(I1,0)),$P(^(0),"^",2)<2 S DGFIL=2.101,DGNOD=^(0),I=9999999-I1 D SET
	D CNT,CNT399 K DIR
	I 'DGCNT D NOVT^IBCOPV1 Q
	D PRT^IBCOPV1 Q
CHK	;Entry point for ^IBCCPT
	F I=IBCOPV1:0 S I=$S(DGFIL=2:$O(^DPT(DFN,"S",I)),1:$O(^SDV("C",DFN,I))) Q:'I!(I>(IBCOPV2+.9999))  I $S($D(^DPT(DFN,"S",I,0))&(DGFIL=2):1,DGFIL=409.5:1,1:0) D:DGFIL=2 PAT D:DGFIL=409.5 ADD D:$D(DGNOD) SET K DGNOD
	Q
ADD	K ^UTILITY($J,"CPT",0),DGNOD
	F I1=0:0 S I1=$O(^SDV(I,"CS",I1)) Q:'I1  I $D(^(I1,0)) S DGNOD=^(0) I $D(^("PR")) S DGCPT=^("PR"),I7=$P(I,".") S:DGCPT]"" ^UTILITY($J,"CPT",0)="Y" S:'$D(^UTILITY($J,"CPT",I7)) ^(I7)="" S ^(I7)=^(I7)_"^"_DGCPT
	I $O(^UTILITY($J,"CPT",0)) S ^UTILITY($J,"CPT1",I7)=^UTILITY($J,"CPT",I7) D PROD^IBCOPV2 Q
TYP	Q:'$D(DGNOD)  K DGNO I DGFIL'=2.101,"749"'[$P(DGNOD,"^",$S(DGFIL=2:16,1:5)) S DGNO=1 Q
	S:DGFIL=409.5&($P(DGNOD,"^",4)) DGTYP=$P(DGNOD,"^",4)
	K DGTYP I DGFIL=2 F Z=0:0 S Z=$O(^SC(+DGNOD,"S",I,1,Z)) Q:'Z  I $D(^(Z,0)),+^(0)=DFN,$P(DGNOD,"^",16)=9 S DGTYP=$P(^(0),"^",10)
	I $D(DGTYP),DGTYP,$D(^DIC(8,DGTYP,0)),"^6^7^9^12^"[("^"_$P(^(0),"^",9)_"^") S DGNO=1 Q
	S:'$D(DGTYP) DGTYP=""
	I DGTYP S DGTYP=$E($P($G(^DIC(8,DGTYP,0)),"^"),1,3)
	S:DGTYP="" DGTYP=$P(DGNOD,"^",$S(DGFIL=2:16,DGFIL=409.5:5,1:"")) S:DGTYP&(DGTYP<9) DGTYP=$P(^SD(409.1,DGTYP,0),"^") S DGTYP=$E(DGTYP,1,3)
	Q
SET	S DGDT=$P(I,"."),DGDT1=$P(I,".",2) D TYP,ELIG^IBCOPV2 Q:$D(DGNO)!('$D(DGNOD))  S:'$D(DGNO) ^UTILITY($J,"OPV",DGDT,DGDT1,DGFIL)=DGTYP_"^"_DGMT_"^"_$S($D(^UTILITY($J,"CPT",0))&(DGFIL=409.5):^UTILITY($J,"CPT",0),1:"")
	S $P(^UTILITY($J,"OPV",DGDT,DGDT1,DGFIL),"^",6)=$S(DGCOD]"":DGCOD,1:"")
	Q:'$D(^DGCR(399,"AOPV",DFN,DGDT))
BIL	S DGBIL=0 F DGBIL1=1:1 S DGBIL=$O(^DGCR(399,"AOPV",DFN,I,DGBIL)) Q:'DGBIL  I $D(^DGCR(399,DGBIL,0)) D BIL1
	Q
BIL1	F B=1,7 S DGBIL(B)=$P(^DGCR(399,DGBIL,0),"^",B) I DGBIL(B)]"" S:B=7&$D(^DGCR(399.3,DGBIL(B),0)) DGBIL(B)=$P(^(0),"^",4) D BIL2
	Q
BIL2	S $P(^UTILITY($J,"OPV","AP",DGCNT),"^",$S((DGBIL1+B)=2:4,(DGBIL1+B)=8:5,(DGBIL1+B)<8:(DGBIL1+DGBIL1+2),1:(DGBIL1+DGBIL1+3)))=DGBIL(B)
	Q
CNT	F I=0:0 S I=$O(^UTILITY($J,"OPV",I)) Q:'I  S DGCNT=DGCNT+1,^UTILITY($J,"OPV","AP",DGCNT)=I D CHG^IBCOPV2,BIL
	Q
CNT399	S DGCNT1=0 F I=0:0 S I=$O(^DGCR(399,IBIFN,"OP",I)) Q:'I  S DGCNT1=DGCNT1+1
	Q
PAT	I $P(^DPT(DFN,"S",I,0),"^",2)']"" S DGNOD=^(0)
	Q