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

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

initial load of WorldVistAEHR

File size: 6.4 KB
RevLine 
[613]1IBACV ;WOIFO/SS-COMBAT VET UTILITIES ;7-AUG-03
2 ;;2.0;INTEGRATED BILLING;**234,247,275,339,347** ;21-MAR-94;Build 24
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;To replace CL^SDCO21 with CL^IBACV that wraps out both CL^SDCO21 and $$CVEDT^DGCV
6CL(IBDFN,IBSDDT,IBSDOE,IBSDCLY) ;Build Classification Array
7 ; Input -- DFN Patient file IEN
8 ; SDDT Date/Time [Optional]
9 ; SDOE Outpatient Encounter file IEN [Optional]
10 ; Output -- SDCLY Classification Array
11 ; Subscripted by Class. Type file (#409.41) IEN
12 ;
13 D CL^SDCO21(IBDFN,$G(IBSDDT),$G(IBSDOE),.IBSDCLY)
14 Q
15 ;
16 ;returns CV status as:
17 ; current_CV_status^end_date^if_ever_had_CV_status
18CVEDT(IBDFN,IBDT) ;
19 N IBRET S IBRET=$$CVEDT^DGCV($G(IBDFN),$G(IBDT))
20 Q (+$P(IBRET,"^",3))_"^"_(+$P(IBRET,"^",2))_"^"_(+$P(IBRET,"^",1)) ;swop
21 ;
22 ;/**
23 ;Return the classification description of code sets for #.03 in #351.2.
24 ; Input:
25 ; X -- Patient class [1-ao|2-ir|3-swa|4-sc|5-mst|6-hnc|7-cv|8-SHAD]
26 ; IBCASE -- "M" - mixed case (the first letter is uppercase and others-lowercase)
27PATTYPE(X,IBCASE) ; */
28 N IBZ
29 S IBZ=$S(X=1:"AGENT ORANGE",X=2:"IONIZING RADIATION",X=3:"SOUTHWEST ASIA",X=4:"SERVICE CONNECTED",X=5:"MILITARY SEXUAL TRAUMA",X=6:"HEAD/NECK CANCER",X=7:"COMBAT VETERAN",X=8:"PROJECT 112/SHAD",1:"SPECIAL")
30 Q:$G(IBCASE)="M" $$LOWER^VALM1(IBZ)
31 Q IBZ
32 ;
33PATTYAB(X) ; Return External Abbreviation of Special Inpatient Billing Case Patient Type (#351.2,.03)
34 ; Input: 351.2, .03 internal value
35 N IBZ S X=$G(X)
36 S IBZ=$S(X=1:"AO",X=2:"IR",X=3:"SWA",X=4:"SC",X=5:"MST",X=6:"HNC",X=7:"CV",X=8:"SHAD",1:"UNK")
37 Q IBZ
38 ;
39 ;if Combat Vet sends e-mail to mailgroup "IB COMBAT VET RX COPAY"
40 ;IBDFN-patient IEN, IBDT - date, IBRXPTR - pointer to #52 file to get prescription #
41RXALRT(IBDFN,IBDT,IBRXPTR) ;
42 N IB1
43 S IB1=$$CVEDT(IBDFN,$G(IBDT))
44 I +IB1 D EMAIL(IBDFN,$G(IBDT),$P(IB1,"^",2),$G(IBRXPTR))
45 Q
46 ;sends e-mail to mail group IB COMBAT VET RX COPAY
47EMAIL(DFN,IBEFDT,IBEXPDT,IBRX) ;
48 N IBTODAY,IBPAT,IBT,IBSSN
49 N XMSUB,XMY,XMTEXT,XMDUZ
50 N Y D NOW^%DTC S Y=%\1 X ^DD("DD") S IBTODAY=Y
51 I +$G(DFN)>0 D
52 . N VADM,VA,VAERR
53 . D DEM^VADPT
54 . S IBPAT=$G(VADM(1))
55 . S IBSSN=$P($G(VADM(2)),"^",2)
56 I $G(IBRX) S IBRX=$$FILE^IBRXUTL(IBRX,.01) ;get RX number
57 S:IBPAT="" IBPAT="Unknown"
58 S XMSUB="COMBAT VET RX COPAY REVIEW NEEDED"
59 S XMY("G.IB COMBAT VET RX COPAY")=""
60 S XMTEXT="IBT(",XMDUZ="INTEGRATED BILLING PACKAGE"
61 S IBT(1,0)="PATIENT: "_IBPAT
62 I $G(IBEXPDT)>0 S Y=IBEXPDT X ^DD("DD") S IBT(1,0)=IBT(1,0)_" COMBAT VET until: "_Y
63 S IBT(2,0)="SSN: "_IBSSN
64 S IBT(3,0)=""
65 S IBT(4,0)=$S($G(IBRX)'="":"RX#: "_$G(IBRX),1:"")
66 S IBT(5,0)="RX RELEASE DATE: "_IBTODAY
67 S IBT(6,0)=""
68 S IBT(7,0)="The above patient has a Combat Veteran status. Please review this"
69 S IBT(8,0)="prescription to determine if the RX Copay charge should be cancelled."
70 S IBT(9,0)=""
71 D ^XMD
72 Q
73 ;
74 ;--------------------------------------------------------------------
75 ;is called from PROC^IBAMTC for each active inpatient
76IFCVEXP(IBDFN,IBNJDT,IB405) ;
77 ;Input:IBDFN1 - patient's ien in PATIENT file
78 ; IBNJDT - Nightly Job date
79 ; IB405 - ptr to #405
80 N IBTSTDT,IBPAT,IBZ,IBEXPIR,IBADM
81 S IBPAT=$$PT^IBEFUNC(IBDFN)
82 S (IBZ,IBEXPIR)=0
83 S IBZ=$$CVEDT^IBACV(IBDFN,IBNJDT)
84 I $P(IBZ,"^",3)=0 Q ;patient has never been CV
85 S IBEXPIR=+$P(IBZ,"^",2)\1
86 I IBEXPIR>IBNJDT Q ;expires in the future
87 ;get last date when Nightly job checked CV status for inpatients
88 S IBTSTDT=$$XTMPLST()
89 ;if ^XTMP is not there then make the last CV check date as TODAY-7
90 I IBTSTDT=0 S IBTSTDT=$$CHNGDATE^IBAHVE3(IBNJDT,-7) D SETXTMP0(IBTSTDT)
91 S IBADM=+$G(^DGPM(IB405,0))\1 ;admission/movement date
92 I IBTSTDT'<IBNJDT Q
93 ;check for all the days since the last check date thru today
94 F D Q:(IBTSTDT'<IBNJDT)!(IBTSTDT=IBEXPIR)
95 . S IBTSTDT=$$CHNGDATE^IBAHVE3(IBTSTDT,+1) ;next date
96 . ;quit if the date is before the admission
97 . I IBTSTDT<IBADM Q
98 . ;send alert if CV expires this day
99 . I IBEXPIR=IBTSTDT D SETXTPM(IBDFN,IBTSTDT,IBEXPIR,IBADM,IBPAT)
100 Q
101 ;
102XTMPLST() ;get the last CV check date in ^XTMP
103 Q +$P($G(^XTMP("IBCVEXPDT",0)),"^",2)
104 ;
105SETXTPM(IBDFN,IBCHKDT,IBEXP,IBADMIS,IBPT) ;save info in ^XTMP
106 ;Input:IBDFN - patient's ien in PATIENT file
107 ; IBEXP - CV expiration date
108 ; IBADMIS - admission/movement date
109 ; IBPT - patient's info
110 S ^XTMP("IBCVEXPDT",IBDFN)=IBDFN_"^"_IBCHKDT_"^"_IBEXP_"^"_IBADMIS_"^"_$P(IBPT,"^",1,2)
111 Q
112 ;
113 ;is called from IBAMTC after PROC^IBAMTC and sends e-mail alert
114 ;with the list of inpatient's with CV expired
115CVEXMAIL(IBDT) ;send all e-mails
116 N Y,IBT,IBZ1,IBZ2,IBC,IBT,IBTOTAL
117 S IBC=0,IBTOTAL=0
118 ;loop thru ^XTMP
119 S IBZ1=0 F S IBZ1=$O(^XTMP("IBCVEXPDT",IBZ1)) Q:+IBZ1=0 D
120 . D HEADER
121 . S IBZ2=$G(^XTMP("IBCVEXPDT",IBZ1))
122 . I IBZ2'="" S IBTOTAL=IBTOTAL+1 D MKEMAIL($P(IBZ2,U,3),$P(IBZ2,U,4),$P(IBZ2,U,5),$P(IBZ2,U,6))
123 I IBC>0 D
124 . D FOOTER(IBTOTAL)
125 . D SEND^IBACVA2
126 D SETXTMP0(IBDT)
127 Q
128 ;
129HEADER ;prints a header for the e-mail
130 I IBC>0 Q
131 S XMSUB="INPATIENTS' COMBAT VET STATUS EXPIRED"
132 N IBX S IBX="",$P(IBX,"=",70)=""
133 S IBC=IBC+1,IBT(IBC)="The following patients whose records indicate that they had CV status, were"
134 S IBC=IBC+1,IBT(IBC)="admitted for inpatient care with CV status, and their CV status has expired"
135 S IBC=IBC+1,IBT(IBC)="during their stays. Please check their CV exp date again before adjusting"
136 S IBC=IBC+1,IBT(IBC)="their billings accordingly."
137 S IBC=IBC+1,IBT(IBC)=""
138 S IBC=IBC+1,IBT(IBC)=$$LRJ("Patient NAME",23)_$$LRJ("SSN",14)_$$LRJ("CV exp. date",20)_$$LRJ("Date of admission",20)
139 S IBC=IBC+1,IBT(IBC)=IBX
140 Q
141FOOTER(IBTOTAL) ;
142 S IBC=IBC+1,IBT(IBC)=""
143 S IBC=IBC+1,IBT(IBC)="Total: "_IBTOTAL_" patient(s)"
144 Q
145 ;
146MKEMAIL(IBEXP,IBADM,IBNAME,IBSSN) ;
147 ;send e-mail alert if CV does expire today
148 N Y
149 S Y=IBEXP D DD^%DT S IBEXP=Y
150 S Y=IBADM D DD^%DT S IBADM=Y
151 S IBC=IBC+1,IBT(IBC)=$$LRJ($E(IBNAME,1,21),23)_$$LRJ(IBSSN,14)_$$LRJ(IBEXP,20)_$$LRJ(IBADM,20)
152 Q
153 ;
154SETXTMP0(IBDT) ;set the new "last CV check date" in ^XTMP
155 N IBPURGDT S IBPURGDT=+$$CHNGDATE^IBAHVE3(IBDT,+7)
156 K ^XTMP("IBCVEXPDT")
157 S ^XTMP("IBCVEXPDT",0)=IBPURGDT_"^"_IBDT_"^LAST DATE NIGHTLY JOB CHECKED COMBAT VET EXPIRATION FOR INPATIENTS"
158 Q
159 ;
160 ;---
161 ;adds spaces on right/left or truncates to make return string IBLEN characters long
162 ;IBST- original string
163 ;IBLEN - desired length
164 ;IBCHR -character (default = SPACE)
165 ;IBSIDE - on which side to add characters (default = RIGHT)
166LRJ(IBST,IBLEN,IBCHR,IBSIDE) ;
167 N Y S $P(Y,$S($L($G(IBCHR)):IBCHR,1:" "),$S(IBLEN-$L(IBST)<0:1,1:IBLEN-$L(IBST)+1))=""
168 Q $E($S($G(IBSIDE)="L":Y_IBST,1:IBST_Y),1,IBLEN)
169 ;---
170 ;
Note: See TracBrowser for help on using the repository browser.