source: WorldVistAEHR/trunk/r/DRUG_ACCOUNTABILITY-PSA/PSAUP2.m@ 1154

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

initial load of WorldVistAEHR

File size: 3.6 KB
Line 
1PSAUP2 ;BIR/JMB-Upload and Process Prime Vendor Invoice Data - CONT'D ;8/13/97
2 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**19,37**; 10/24/97
3 ;Checking the X12 invoice data.
4 K ^TMP("PSAPV SET",$J),PSAERR
5 S (PSASTCNT,PSAITCNT)=0
6 S PSALAST=""
7 S PSALINE=0 F S PSALINE=$O(^TMP("PSAPVS",$J,PSALINE)) Q:PSALINE="" S PSADATA=^(PSALINE) D
8 .;check segment order
9 .D ^PSAUP3 S PSALAST=$P(PSADATA,"^")
10ISA .;control header
11 .I PSALAST="ISA" D Q
12 ..S PSAISA=PSADATA,PSACTRL="" W "." I $L($P(PSADATA,"^",14))'=9 S PSASEG="ISA" D MSG^PSAUTL2
13 .;
14IEA .;control trailer
15 .I PSALAST="IEA" D Q
16 ..I $P(PSADATA,"^",3)'=$P(PSAISA,"^",14) S PSASEG="IEA" D MSG^PSAUTL2
17 .;
18GS .;group header
19 .I PSALAST="GS" S PSAGS=PSADATA D Q
20 ..F %=3,4 S PSAPC=$S(%=3:7,1:9) I $P(PSADATA,"^",%)'=$TR($P(PSAISA,"^",PSAPC)," ") S PSASEG="GS" D MSG^PSAUTL2
21 .;
22GE .;group trailer
23 .I PSALAST="GE" D Q
24 ..I $P(PSADATA,"^",3)'=$P($G(PSAGS),"^",7) S PSASEG="GE" D MSG^PSAUTL2
25 .;
26ST .;set header
27 .I PSALAST="ST" D Q
28 ..S PSAST=PSADATA,PSACTRL=$P(PSADATA,"^",3),PSASTCNT=1,PSAITCNT=0,PSANTYPE=""
29 ..I $L(PSACTRL)>3,$L(PSACTRL)<10 Q
30 ..S PSASEG="ST" D MSG^PSAUTL2 Q
31 .;
32SE .;set trailer
33 .I PSALAST="SE" S PSASTCNT=PSASTCNT+1 D Q
34 ..I $P(PSADATA,"^",3)'=PSACTRL S PSASEG="SE1" D MSG^PSAUTL2 Q
35 ..I PSASTCNT'=$P(PSADATA,"^",2) S PSASEG="SE2" D MSG^PSAUTL2
36 .;
37BIG .;beginning segment for invoice
38 .I PSALAST="BIG" S PSASTCNT=PSASTCNT+1 D Q
39 ..I $P(PSADATA,"^",4)="" S $P(PSADATA,"^",4)=$P(PSADATA,"^",2)
40 ..S $P(PSADATA,"^",5)=$TR($P(PSADATA,"^",5)," ")
41 ..S ^TMP("PSAPV SET",$J,PSACTRL,"IN")=$P(PSADATA,"^",2,5)
42 .;
43REF .;(not used)
44 .I PSALAST="REF" S PSASTCNT=PSASTCNT+1 Q
45 .;
46 .;buyer, seller, shipping addresses
47N1 .I PSALAST="N1" S PSASTCNT=PSASTCNT+1,PSANTYPE=$P(PSADATA,"^",2) D Q
48 ..I PSANTYPE'="BY",PSANTYPE'="DS",PSANTYPE'="ST" S PSASEG="N1" D MSG^PSAUTL2 Q
49 ..S ^TMP("PSAPV SET",$J,PSACTRL,PSANTYPE)=$P(PSADATA,"^",3)
50 .;
51N2 .I PSALAST="N2" D Q
52 ..D:PSANTYPE="" NTYPE
53 ..S $P(^TMP("PSAPV SET",$J,PSACTRL,PSANTYPE),"^",2)=$P(PSADATA,"^",2) S PSASTCNT=PSASTCNT+1
54 .;
55N3 .I PSALAST="N3" D Q
56 ..D:PSANTYPE="" NTYPE
57 ..S $P(^TMP("PSAPV SET",$J,PSACTRL,PSANTYPE),"^",3)=$P(PSADATA,"^",2) S PSASTCNT=PSASTCNT+1
58 .;
59N4 .I PSALAST="N4" D Q
60 ..D:PSANTYPE="" NTYPE
61 ..S $P(^TMP("PSAPV SET",$J,PSACTRL,PSANTYPE),"^",4,6)=$P(PSADATA,"^",2,4) S PSASTCNT=PSASTCNT+1,PSANTYPE=""
62 .;
63DTM .;date time reference
64 .I PSALAST="DTM" S PSASTCNT=PSASTCNT+1 D Q
65 ..S %=$S($P(PSADATA,"^",2)="002":5,$P(PSADATA,"^",2)="035":6,1:0) I '% Q
66 ..S $P(^TMP("PSAPV SET",$J,PSACTRL,"IN"),"^",%)=$P(PSADATA,"^",3)
67 .;
68IT1 .;invoice line item
69 .I PSALAST="IT1" S PSASTCNT=PSASTCNT+1,PSAITCNT=PSAITCNT+1 D ITEM Q
70CTT .;item count
71 .I PSALAST="CTT" S PSASTCNT=PSASTCNT+1 D Q
72 ..I PSAITCNT'=$P(PSADATA,"^",2) S PSASEG="CTT" D MSG^PSAUTL2
73 .;
74UNKNOWN .;Segment we don't use
75 .S PSASTCNT=PSASTCNT+1
76 ;
77ERROR S PSASEG=$O(PSAERR("")) D:PSASEG'="" ERROR^PSAUTL2
78 Q
79 ;
80NTYPE S PSASEG="NONTYPE" D MSG^PSAUTL2
81 Q
82 ;
83ITEM ;check line item
84 I '$P(PSADATA,"^",2) S PSASEG="IT1-1" D MSG^PSAUTL2 Q
85 I $P(PSADATA,"^",6)'="DS" S PSASEG="IT1-2" D MSG^PSAUTL2 Q
86 ;DAVE B (PSA*3*19) check for piece 10 (VSN) added
87 I $P(PSADATA,"^",8)="",$P(PSADATA,"^",10)="",$P(PSADATA,"^",12)="" S PSASEG="IT1-3" D MSG^PSAUTL2 Q
88 ;"IT1" Seg=Qty Invoiced ^ Unit of Measure ^ Unit Price ^ Basic Unit Code "DS" ^ NDC ^ VSN
89 S PSAITEM=+$P(PSADATA,"^",2),^TMP("PSAPV SET",$J,PSACTRL,"IT",PSAITEM)=+$P(PSADATA,"^",3)_"^"_$P(PSADATA,"^",4)_"^"_$P(PSADATA,"^",5)_"^"_$P(PSADATA,"^",8)_"^"_$P(PSADATA,"^",10)
90 I $P(PSADATA,"^",12)'="",$P(PSADATA,"^",11)="UP" S $P(^TMP("PSAPV SET",$J,PSACTRL,"IT",PSAITEM),"^",26)=$P(PSADATA,"^",12)
91 Q
Note: See TracBrowser for help on using the repository browser.