source: WorldVistAEHR/trunk/r/INTEGRATED_BILLING-IB-PRQ--IBD--IBQ--PRQS/IBAUTL.m@ 1006

Last change on this file since 1006 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.4 KB
Line 
1IBAUTL ;ALB/AAS - INTEGRATED BILLING APPLICATION UTILITIES ; 14-FEB-91
2V ;;2.0;INTEGRATED BILLING;**93,156,347**;21-MAR-94;Build 24
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;
6COST ; - find charges for transaction type, when only one
7 N IBD,IBN,IB K X1
8 S IBD=-(DT+.9) F S IBD=$O(^IBE(350.2,"AIVDT",DA,IBD)) Q:'IBD S IBN=0 F S IBN=$O(^IBE(350.2,"AIVDT",DA,IBD,IBN)) Q:'IBN S IB=$G(^IBE(350.2,IBN,0)) I IB]"",'$P(IB,"^",5)!($P(IB,"^",5)>DT) S X1=$P(IB,"^",4) G COSTQ
9COSTQ S X1=+$G(X1)
10 Q
11 ;
12FY I $D(X) S IBAFY=$$FY^IBOUTL(X)
13 Q
14 ;
15PTL ; - parent trace logic
16 ; - input in x resulting from field from file 350
17 ; - output in y=1 if found, -1^error message if not found
18 ; - y(0) = zeroth node of top level
19 ; - y(1) = zeroth node of second level
20 ; - y(n) = zeroth node of nth level
21 ;
22 K Y
23 S Y=1 I '+X!'($D(^DIC(+X,0,"GL"))) S Y="-1^IB004" G PTLQ
24 I +X=52 G PHAPI
25 S IBAGL=^DIC(+X,0,"GL")
26 I '$D(@(IBAGL_$P($P(X,";",1),":",2)_",0)")) S Y="-1^IB005" G PTLQ
27 ;
28 ; This naked reference should be set to the original data source that
29 ; is causing this charge to be created. The data source will be one of
30 ; many different data sources that will generate patient charges.
31 S Y(0)=^(0)
32 ;
33 F IBJJ=2:1 S IBII=$P(X,";",IBJJ) Q:IBII="" D PTL1
34PTLQ K IBAGL,IBII,IBJJ,IBMIN
35 Q
36 ;
37PTL1 ; - find y(n) of sublevels
38 ; Call in here with a FOR loop to go each level deeper. This will
39 ; setup the subsripts in Y for all the data elements that go into
40 ; causing this charge to be created. It looks in the original data
41 ; source file as approprite to obtain the information. The naked
42 ; reference should be the last data level in the data source appropriate
43 ; data source file last looked up.
44 ;
45 S IBMIN=$P(IBII,":") I IBMIN="" S Y="-1^IB006" Q
46 I '$D(^(IBMIN,$P(IBII,":",2),0)) S Y="-1^IB006" Q
47 ;I '$D(^(+IBII,$P(IBII,":",2),0)) S Y="-1^IB006" Q
48 S Y(IBJJ-1)=^(0)
49 Q
50 ;
51CHKX ; - check input x
52 ; - piece 1 = service and exists
53 ; - peice 2 = patient and exists
54 ; - piece 3 = action type
55 ; - piece 4 = user duz
56 S DFN=$P(X,"^",2),IBSERV=+IBSAVX
57 I $S('DFN:1,'$D(^DPT(DFN,0)):1,1:0) S Y="-1^IB002" G CHKXQ ;patient pointer bad
58 I $S('IBSERV:1,'$D(^DIC(49,IBSERV,0)):1,1:0) S Y="-1^IB003" G CHKXQ ;service pointer bad
59 I IBTAG=1 G CHKXQ
60 S IBDUZ=$P(IBSAVX,"^",4) I $S('IBDUZ:1,'$D(^VA(200,IBDUZ,0)):1,1:0) S Y="-1^IB007" G CHKXQ
61 I IBTAG=3 G CHKXQ
62 S IBATYP=$P(IBSAVX,"^",3) I $S('IBATYP:1,'$D(^IBE(350.1,IBATYP,0)):1,1:0) S Y="-1^IB008"
63CHKXQ Q
64 ;
65SITE ; - calculate site from site parameters
66 ; - output ibsite = station number
67 ; = ibfac = pointer to institution file
68 I '$D(^IBE(350.9,1,0)) S Y="-1^IB016" Q
69 S IBFAC=$P(^IBE(350.9,1,0),"^",2),IBSITE=$S('$D(^DIC(4,IBFAC,99)):"",1:+^(99)) I IBSITE<1 S Y="-1^IB009"
70 Q
71 ;
72ADD ; - add new entry to ^ib
73 ;
74 N %DT,IBYCHK
75 L +^IB(0):10 I '$T S Y="-1^IB014" G ADDQ
76 S X=$P($S($D(^IB(0)):^(0),1:"^^-1"),"^",3)+1 L -^IB(0) I 'X S Y="-1^IB015" G ADDQ
77 K DD,DO,DIC,DR S DIC="^IB(",DIC(0)="L",DLAYGO=350
78 F X=X:1 L:$D(IBN1) -^IB(IBN1) I X>0,'$D(^IB(X)) S IBN1=X L +^IB(IBN1):1 I $T,'$D(^IB(X)) S DINUM=X,X=+IBSITE_X D FILE^DICN I +Y>0 Q
79 S IBN=+Y,DIE="^IB(",DA=IBN,DR=".02////"_$S($D(DFN):DFN,1:"")_";.03////"_$S($D(IBATYP):IBATYP,1:"")_";.05////1;12///NOW" D
80 . N Y D ^DIE K DA,DR,DIE I $D(Y) S IBYCHK=Y
81 L -^IB(IBN1)
82 S Y=$S('$D(IBYCHK):1,1:"-1^IB028")
83 ;
84ADDQ K DO,DD,DINUM,DIC,IBN1 Q
85 ;
86ARPARM N X S X=DT
87 D SITE,FY,NOW^%DTC S IBNOW=%
88 Q
89BILLNO ; -get open bill number
90 I '$G(IBTOTL) S (IBIL,IBTRAN)="" G BILLQ
91 S IBARTYP=$S($D(^IBE(350.1,+IBATYP,0)):$P(^(0),"^",3),1:"")
92 S X=IBSITE_"^"_IBSERV_"^"_IBARTYP_"^"_DFN_";DPT("_"^"_IBAFY_"^"_$S($D(IBTOTL):IBTOTL,1:0)_"^"_$S($D(IBDUZ):IBDUZ,$D(DUZ):DUZ,1:0)_"^"_$P(IBNOW,".",1) D ^PRCASER I +Y<1 G BILLQ
93 S IBIL=$P(Y,"^",2),IBTRAN=$P(Y,"^",3) I IBIL="" S Y="-1^IB011" G BILLQ
94 S IBTRAN=$S(IBTRAN>0:IBTRAN,1:"")
95BILLQ Q
96 ;
97PHAPI ;
98 ;This is alternate code for Parent Trace Logic
99 ; to deal with the Pharmacy Encapsulation of Prescription File (#52)
100 ;
101 N IBRFL,IBXX,IBPT,IBRX,IBY
102 S IBXX=X,IBY=1
103 S IBRX=$P($P(IBXX,";"),":",2)
104 S IBPT=$$FILE^IBRXUTL(IBRX,2),IBY(0)=$$RXZERO^IBRXUTL(IBPT,IBRX) I IBY(0)="" S IBY="-1^IB005" G PHAPIQ
105 I $P(IBXX,";",2)="" G PHAPIQ ; original fill being billed
106 S IBRFL=$P($P(IBXX,";",2),":",2),IBY(1)=$$ZEROSUB^IBRXUTL(IBPT,IBRX,IBRFL)
107 I IBY(1)="" S IBY="-1^IB006" G PHAPIQ
108 ;
109PHAPIQ ;
110 S:$G(IBY)]"" Y=IBY
111 S:$G(IBY(0))]"" Y(0)=IBY(0)
112 S:$G(IBY(1))]"" Y(1)=IBY(1)
113 Q
114 ;
Note: See TracBrowser for help on using the repository browser.