source: WorldVistAEHR/trunk/r/PHARMACY_BENEFITS_MANAGEMENT-PSU/PSUPR3.m@ 1076

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

initial load of WorldVistAEHR

File size: 3.3 KB
RevLine 
[613]1PSUPR3 ;BIR/PDW - EXTRACTION FROM FILE 58.81 ;12 AUG 1999
2 ;;4.0;PHARMACY BENEFITS MANAGEMENT;;MARCH, 2005
3 ;DBIAs
4 ; Reference to file #58.81 supported by DBIA 2520
5 ; Reference to file #50 supported by DBIA 221
6 ; Reference to file #51.5 supported by DBIA 1931
7 ; Reference to file #58.8 supported by DBIA 2519
8 ; Reference to file #59 supported by DBIA 2510
9 ; Reference to file #42 supported by DBIA 2440
10 ; Reference to file #40.8 supported by DBIA 2438
11 ; Reference to file #59.5 supported by DBIA 2499
12 ;
13EN ;EP from PSUPR0
14 S PSUEDT=PSUEDT\1+.24
15 ; setup ^XTMP node
16 S:'$D(PSUPRJOB) PSUPRJOB=$J
17 S:'$D(PSUPRSUB) PSUPRSUB="PSUPR_"_PSUPRJOB
18 I '$D(^XTMP(PSUPRSUB)) D
19 . S ^XTMP(PSUPRSUB,0)=""
20 . S X1=DT,X2=6 D C^%DTC
21 . S ^XTMP(PSUPRSUB,0)=X_"^"_DT_"^"_" PBMS Procurement Extraction3"
22SCANDT ; 3.2.6.31 scan Transaction date time
23 S PSUDT=PSUSDT
24 ; going after ^PSD(58.81,"AF",PSUDT,PSULOC,PSUTYP,PSUTRDA)
25 ;
26 F S PSUDT=$O(^PSD(58.81,"AF",PSUDT)) Q:PSUDT'>0 Q:PSUDT>PSUEDT D LOC
27 Q
28 ;
29LOC ;EP scan thru locations
30 ;
31 S PSULOC="" F S PSULOC=$O(^PSD(58.81,"AF",PSUDT,PSULOC)) Q:PSULOC="" D TYPE
32 Q
33 ;
34TYPE ;EP Scan Thru Types
35 ;
36 S PSUTYP="" F S PSUTYP=$O(^PSD(58.81,"AF",PSUDT,PSULOC,PSUTYP)) Q:PSUTYP="" D TRAN
37 Q
38 ;
39TRAN ;EP Scan Thru Transactions
40 ;
41 S PSUTRDA=0 F S PSUTRDA=$O(^PSD(58.81,"AF",PSUDT,PSULOC,PSUTYP,PSUTRDA)) Q:PSUTRDA'>0 D TRANDA
42 Q
43 ;
44TRANDA ;EP work a transaction
45 ;
46 N PSUTR
47 D GETS^PSUTL(58.81,PSUTRDA,".01;1;2;3;4;5;8;12;71;106;107","PSUTR","I")
48 D MOVEI^PSUTL("PSUTR")
49 S PSUDTDA=PSUTR(3)
50 ; 3.2.6.3.2-3.4
51 Q:(PSUTR(1)'=1)
52 I '$D(PSUFLSFG) D
53 .I $L(PSUTR(8)),'$L($G(PSUTR(71))) Q
54 I $D(PSUFLSFG) D
55 .I PSUTR(107)'="" Q
56 Q:$L(PSUTR(106))
57 ;
58 ; setup file 50 fields
59 S PSUDRDA=PSUTR(4)
60 N PSUDRUG
61 D GETS^PSUTL(50,PSUDRDA,".01;2;12;13;14.5;15;20;21;22;25;31","PSUDRUG","I")
62 D MOVEI^PSUTL("PSUDRUG")
63 ;
64 ; further process file 50 fields
65 S:'$L(PSUDRUG(.01)) PSUDRUG(.01)="Unknown Generic Name" ; Generic Name
66 S:'$L(PSUDRUG(21)) PSUDRUG(21)="Unknown VA Product Name" ; VA Product Name
67 S:'$L(PSUDRUG(31)) PSUDRUG(31)="No NDC" ; NDC
68 S PSUDRUG(12)=$$VALI^PSUTL(51.5,PSUDRUG(12),.01) ; Order Unit
69 ;
70 ; setup division 3.2.3.6.3.5
71 N PSULOC
72 S PSULOC=PSUTR(2)
73 ; Get division from file 58.8, file 59.7 fileds 90.02,90.03
74 S PSUDIV="",PSUDIVI="H"
75 S PSUINV="",PSUINV(4)=PSULOC
76 D DIV^PSUPR2
77CONT ;
78 I $L(PSUDIV) S PSUDIVI=""
79 E S PSUDIV=PSUSNDR
80 ;
81 ; Assemble Record
82 S PSUREC=$$RECORD()
83 ; Store Record
84 S PSULC=+$O(^XTMP(PSUPRSUB,"RECORDS",PSUDIV,""),-1)
85 S PSULC=PSULC+1
86 S ^XTMP(PSUPRSUB,"RECORDS",PSUDIV,PSULC)=PSUREC
87 Q
88 ;
89 ; assemble record
90RECORD() ;EP Assemble record for storage
91 ; 3.2.11.38
92 N PSUR
93 S PSUR(2)=PSUDIV
94 S PSUR(3)=PSUDIVI
95 S PSUR(4)=PSUDTDA\1
96 S PSUR(5)=PSUDRUG(21)
97 S PSUR(6)=PSUDRUG(2)
98 S PSUR(7)=PSUDRUG(.01)
99 S PSUR(9)=PSUDRUG(31)
100 S PSUR(12)=PSUDRUG(14.5)
101 S PSUR(13)=$$VAL^PSUTL(50,PSUDRDA,12)
102 S PSUR(16)=PSUDRUG(15)
103 S PSUR(17)=PSUTR(5)
104 S PSUR(18)=PSUDRUG(13)
105 I PSUDRUG(15) S PSUR(360)=PSUDRUG(13)*(PSUTR(5)/PSUDRUG(15))
106 E S PSUR(360)=""
107 S PSUR(19)=$J(PSUR(360),12,2)
108 K PSUR(360)
109 S PSUR(20)=PSUTR(12)
110 S PSUR(21)=PSUTR(71)
111 S PSUR(22)=""
112 S I=0 F S I=$O(PSUR(I)) Q:I'>0 S PSUR(I)=$TR(PSUR(I),"^","'")
113 S I=0 F S I=$O(PSUR(I)) Q:I'>0 S $P(PSUR,"^",I)=PSUR(I)
114 S PSUR=PSUR_"^"
115 Q PSUR
Note: See TracBrowser for help on using the repository browser.