source: FOIAVistA/trunk/r/IFCAP-PRC-PRX--PRCA--PRCN/PRCVRC2.m@ 1306

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

initial load of FOIAVistA 6/30/08 version

File size: 7.0 KB
Line 
1PRCVRC2 ;WOIFO/BMM - silently build RIL for DynaMed ; 12/16/04
2V ;;5.1;IFCAP;**81**;Oct 20, 2000
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5 ;validation, error code for PRCVRC1
6 ;
7 Q
8 ;
9GETFY(PRCVDT) ;return the fiscal year, PRCVDT is date/time the DM
10 ;message was created (thus the date/time for RIL)
11 ;
12 Q $E(100+$E(PRCVDT,2,3)+$E(PRCVDT,4),2,3)
13 ;
14GETQTR(PRCVDT) ;return the fiscal quarter, PRCVDT is date/time the DM
15 ;message was created (thus the date/time for RIL)
16 ;
17 N QTR S QTR=+$E(PRCVDT,4,5)
18 Q $P("2^2^2^3^3^3^4^4^4^1^1^1","^",+QTR)
19 ;
20GETTXN(PRCVSTR) ;obtain current transaction number (if exists) from
21 ;Transaction Number file (#410.1)
22 ;increment transaction for current use, update 410.1 entry
23 ;return new transaction number for this RIL
24 ;PRCVSTR is Entry Number, comes in as "station-fy-qtr-fcp-cc"
25 ;TXN is transaction #, PRCVRN is IEN for 410.1 entry
26 ;NOTE: CHECK 410 too, look in EN1^PRCSUT3, lines 8-10 etc.
27 ;
28 Q:$G(PRCVSTR)="" 0
29 N TXN,PRCVE,PRCVRN S TXN="",(PRCVRN,PRCVE)=0
30 ;check if Entry Number def in 410.1
31 K ATXN
32 D FIND^DIC(410.1,,"1","BX",PRCVSTR,,,,,"ATXN")
33 ;
34 S TXN=+$G(ATXN("DILIST","ID",1,1))
35 S PRCVRN=$G(ATXN("DILIST",2,1))
36 I TXN<1 D Q:PRCVE=1 0
37 . ;TXN=0 so Entry Number not def, create new
38 . K PRCVAT S PRCVAT(410.1,"+1,",.01)=PRCVSTR
39 . S PRCVAT(410.1,"+1,",2)=DT
40 . S PRCVAT(410.1,"+1,",1)=1
41 . D UPDATE^DIE("","PRCVAT","PRCVRN")
42 . ;don't send msg here
43 . ;I $D(^TMP("DIERR",$J)) D SENDMSG(7,PRCVGL,0,1) S PRCVE=1 Q
44 . I $D(^TMP("DIERR",$J)) S PRCVE=1 Q
45 . S PRCVRN=PRCVRN(1)
46 S TXN=TXN+1
47 K PRCVSA S PRCVSA(410.1,PRCVRN_",",1)=TXN
48 D FILE^DIE("","PRCVSA")
49 ;don't send msg here
50 ;I $D(^TMP("DILIST",$J)) D SENDMSG(7,PRCVGL,0,1) Q 0
51 I $D(^TMP("DILIST",$J)) Q 0
52 S TXN="000"_TXN,TXN=$E(TXN,$L(TXN)-3,$L(TXN))
53 Q TXN
54 ;
55CHKDT(INDT) ;check the incoming date (date/time message created) against
56 ;the present date. date/time message created must be today or in
57 ;the past. if INDT is today or before today then return 1, else
58 ;return 0
59 ;both dates are in Fileman format ex. 3050503.12446
60 ;
61 Q:$G(INDT)="" 0
62 N %,PRESENT,PRCVDIFF
63 D NOW^%DTC S PRESENT=%
64 S PRCVDIFF=$$FMDIFF^XLFDT(PRESENT,INDT,1)
65 I PRCVDIFF'<0 Q 1
66 Q 0
67 ;
68CHKDTN(INDT) ;check the incoming date (Date Needed By from DynaMed)
69 ;against the present date. Date Needed By must be today or in the
70 ;future. if INDT is today or after today then return 1, else return 0
71 ;both dates are in FileMan format ex. 3050503.12446
72 ;
73 Q:$G(INDT)="" 0
74 N %,PRESENT,PRCVDIFF
75 D NOW^%DTC S PRESENT=%
76 S PRCVDIFF=$$FMDIFF^XLFDT(PRESENT,INDT,1)
77 I PRCVDIFF'>0 Q 1
78 Q 0
79 ;
80CHKBOC(ITEM,BOC) ;test BOC from passed-in detail record
81 ;
82 Q:$G(ITEM)="" 0
83 N PRCVIBOC
84 S PRCVIBOC=$$GET1^DIQ(441,ITEM_",",12,"I")
85 I PRCVIBOC'=BOC Q 0
86 Q 1
87 ;
88CHKFCP(PRCVFCP,PRCVST) ;validate that FCP is in 420
89 ;
90 Q:$G(PRCVFCP)=""!($G(PRCVST)="") 0
91 N PRCVE,PRCVN,PRCVVAL
92 S PRCVVAL=1,PRCVN=0
93 S PRCVN=$$FIND1^DIC(420.01,","_PRCVST_",","",PRCVFCP_" ","B","","PRCVE")
94 I +PRCVN'>0 S PRCVVAL=0
95 Q PRCVVAL
96 ;
97CHKITM(PRCVITM) ;check extracted item number:
98 ;1. must be greater than 100000
99 ;2. must be defined in Item Master (#441) file
100 ;3. must not be inactive (441 field 16 '=1)
101 ;
102 Q:$G(PRCVITM)="" 0
103 N CITM S CITM=0
104 ;N NITM
105 ;S NITM=$$FIND1^DIC(441,"","X",PRCVITM,"","","ATXN")
106 ;I '$D(ATXN) Q 1
107 I PRCVITM'<100000,$D(^PRC(441,"B",PRCVITM)) D
108 . I +$$GET1^DIQ(441,PRCVITM_",",16,"I")=0 S CITM=1
109 Q CITM
110 ;
111CHKVEND(VENDN) ;check that vendor in Vendor file is active.
112 ;VENDN is Vendor number
113 ;
114 Q:+VENDN=0 0
115 N NVNDP,CHKFLG
116 S CHKFLG=0
117 I $D(^PRC(440,VENDN,0)),$$GET1^DIQ(440,VENDN_",",32,"I")="" S CHKFLG=1
118 Q CHKFLG
119 ;
120CHKVI(VENDN,ITMN) ;check that vendor VENDN sells item ITMN
121 ;can't use $$FIND1^DIC since could be >1 cross-ref and >1 node
122 ;
123 N ITMNN,VENDP,CHKFLG
124 S (VENDP,ITMNN,CHKFLG)=0
125 Q:+VENDN=0!(+ITMN=0) CHKFLG
126 ;get item ien, quit if undef
127 S ITMNN=$O(^PRC(441,"B",ITMN,0))
128 Q:ITMNN="" CHKFLG
129 ;get pointer to vendor ien
130 S VENDP=$O(^PRC(441,ITMNN,2,"B",VENDN,0))
131 ;check that vendor is defined
132 I VENDP>0,$D(^PRC(440,VENDP,0)) S CHKFLG=1
133 ;if item file defined and vendor for item defined, good
134 Q CHKFLG
135 ;
136CHKDUZ(INDUZ) ;validate that DUZ against New Person (#200)
137 ;
138 N DUZFLG S DUZFLG=0
139 Q:$G(INDUZ)="" DUZFLG
140 I $D(^VA(200,INDUZ,0)) S DUZFLG=1
141 Q DUZFLG
142 ;
143CHKNIF(ITEM,NIF) ;use the passed-in item to check that the passed-in
144 ;NIF# is correct. return 1 if valid, 0 if not valid
145 ;
146 N PRCVINIF
147 S PRCVINIF=$$GET1^DIQ(441,ITEM_",",51)
148 I PRCVINIF=NIF Q 1
149 Q 0
150 ;
151MAKECAP(INSTR) ;take INSTR and return an all-caps version of it
152 ;
153 Q:$G(INSTR)="" ""
154 N X,Y
155 S X=INSTR X ^%ZOSF("UPPERCASE")
156 Q Y
157 ;
158SENDMSG(EC,PRCVGL,CTR,ERPC) ;send an alert or error message back to
159 ;DynaMed via VIE by posting "ERR" node to appropriate ^XTMP node
160 ;
161 ;the error text is currently stored in the routine PRCVRC3
162 ;
163 ;EC is the error code
164 ;use EC to get the description and severity
165 ;the message is built in ECSTR and the "ERR" node in ^XTMP is
166 ; created using passed-in message id in MID. the error message
167 ; is appended to "ERR" and is separated by other error messages
168 ; already there with a carat ("^")
169 ;PRCVGL is the ^XTMP subscript and CTR is the detail counter #
170 ;ERPC is the data piece in the line item node or header node to
171 ; which the error pertains
172 ;
173 N X S X="PRCVRC3"
174 X ^%ZOSF("TEST") I '$T Q
175 N ECSTR,OVERSTR,ERRCTR
176 S ERPC=$G(ERPC)
177 S ECSTR=ERPC_"^"_$P($T(ET+EC^PRCVRC3),";;",2),CTR=+CTR
178 I CTR'=0 D
179 . S ERRCTR=+$O(^XTMP(PRCVGL,2,CTR,"ERR",""),-1)
180 . S ERRCTR=ERRCTR+1,^XTMP(PRCVGL,2,CTR,"ERR",ERRCTR)=ECSTR
181 I CTR=0 D
182 . S ERRCTR=+$O(^XTMP(PRCVGL,1,"ERR",""),-1)
183 . S ERRCTR=ERRCTR+1,^XTMP(PRCVGL,1,"ERR",ERRCTR)=ECSTR
184 Q
185 ;
186ADDAUD(ADDSTR) ;add "^"-pieces from ADDSTR as fields to a new record in
187 ;the Audit file #410.02
188 ;
189 ;ADDSTR pieces: DynaMed Doc ID ^ Item # ^ Vendor ^ User DUZ ^
190 ; Last name,First name ^ RIL# ^ date/time RIL created ^
191 ; date/time message created (DynaMed requisition) ^ date needed
192 ;
193 Q:$G(ADDSTR)=""
194 ;
195 ;set up entry
196 N PRCVA,PRCVI,PRCVP,PRCVRIL,PRCVTMP S PRCVA="",PRCVP=0
197 F PRCVI=.01,1,2,3,13,4,5,6,12 S PRCVP=PRCVP+1 D
198 . S PRCVA(414.02,"+1,",PRCVI)=$P(ADDSTR,U,PRCVP)
199 ;add record to Audit File
200 D UPDATE^DIE("","PRCVA")
201 ;if error, send bulletin
202 I $D(^TMP("DIERR",$J)) D Q
203 . S PRCVTMP="PRCVRC2",PRCVRIL=$P(ADDSTR,U,5)
204 . S XMB(1)="creating an entry in the DynaMed Audit File (#414.02)"
205 . S XMB(2)=$P(ADDSTR,U)
206 . S XMB(3)="unable to create Audit File entry"
207 . S ^TMP($J,"PRCVRC2",1,0)="",PRCVP=1
208 . S ^TMP($J,"PRCVRC2",2,0)="DynaMed Doc ID: "_$P(ADDSTR,U)
209 . S ^TMP($J,"PRCVRC2",3,0)="Item #: "_$P(ADDSTR,U,2)
210 . S ^TMP($J,"PRCVRC2",4,0)="Vendor #: "_$P(ADDSTR,U,3)
211 . S ^TMP($J,"PRCVRC2",5,0)="User DUZ: "_$P(ADDSTR,U,4)
212 . S ^TMP($J,"PRCVRC2",6,0)="RIL #: "_$P(ADDSTR,U,5)
213 . S ^TMP($J,"PRCVRC2",7,0)="Message date/time: "_$P(ADDSTR,U,6)
214 . S ^TMP($J,"PRCVRC2",8,0)="RIL create date: "_PRCVRIL
215 . S ^TMP($J,"PRCVRC2",9,0)="Date Needed: "_$P(ADDSTR,U,8)
216 . S ^TMP($J,"PRCVRC2",10,0)="Error: "_$G(^TMP("DIERR",$J,1,"TEXT",1))
217 . S PRCVST=$P(PRCVRIL,"-"),PRCVFCP=$P(PRCVRIL,"-",4)
218 . D DMERXMB^PRCVLIC(PRCVTMP,PRCVST,PRCVFCP)
219 Q
220 ;
Note: See TracBrowser for help on using the repository browser.