1 | C0CRXNRD ; WV/SMH - CCR/CCD PROJECT: Routine to Read RxNorm files;11/15/08
|
---|
2 | ;;0.1;CCDCCR;nopatch;noreleasedate
|
---|
3 | W "No entry from top" Q
|
---|
4 | ;
|
---|
5 | READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
|
---|
6 | I PATH="" QUIT
|
---|
7 | N FILENAME S FILENAME="RXNCONSO.RRF"
|
---|
8 | D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
---|
9 | IF POP W "Error reading file..., Please check...",! BREAK
|
---|
10 | F I=1:1 Q:$$STATUS^%ZISH D
|
---|
11 | . U IO
|
---|
12 | . N LINE R LINE
|
---|
13 | . IF $$STATUS^%ZISH QUIT
|
---|
14 | . U $P W I,! U IO ; Write I to the screen, then go back to reading the file
|
---|
15 | . N RXCUI,RXAUI,SAB,TTY,CODE,STR ; Fileman fields numbers below
|
---|
16 | . S RXCUI=$P(LINE,"|",1) ; .01
|
---|
17 | . S RXAUI=$P(LINE,"|",8) ; 1
|
---|
18 | . S SAB=$P(LINE,"|",12) ; 2
|
---|
19 | . S TTY=$P(LINE,"|",13) ; 3
|
---|
20 | . S CODE=$P(LINE,"|",14) ; 4
|
---|
21 | . S STR=$P(LINE,"|",15) ; 5
|
---|
22 | . ; Remove embedded "^"
|
---|
23 | . S STR=$TR(STR,"^")
|
---|
24 | . ; Convert STR into an array of 80 characters on each line
|
---|
25 | . N STRLINE S STRLINE=$L(STR)\80+1
|
---|
26 | . ; In each line, chop 80 characters off, reset STR to be the rest
|
---|
27 | . F J=1:1:STRLINE S STR(J)=$E(STR,1,80) S STR=$E(STR,81,$L(STR))
|
---|
28 | . ; Now, construct the FDA array
|
---|
29 | . N RXNFDA
|
---|
30 | . S RXNFDA(176.001,"+"_I_",",.01)=RXCUI
|
---|
31 | . S RXNFDA(176.001,"+"_I_",",1)=RXAUI
|
---|
32 | . S RXNFDA(176.001,"+"_I_",",2)=SAB
|
---|
33 | . S RXNFDA(176.001,"+"_I_",",3)=TTY
|
---|
34 | . S RXNFDA(176.001,"+"_I_",",4)=CODE
|
---|
35 | . D UPDATE^DIE("","RXNFDA")
|
---|
36 | . I $D(^TMP("DIERR",$J)) U $P BREAK
|
---|
37 | . ; Now, file WP field STR
|
---|
38 | . D WP^DIE(176.001,I_",",5,,$NA(STR))
|
---|
39 | D CLOSE^%ZISH("FILE")
|
---|
40 | Q
|
---|
41 | ;
|
---|
42 | READNDC(PATH) ; Open and read NDC/RxNorm/VANDF relationship file: RXNSAT.RRF
|
---|
43 | I PATH="" QUIT
|
---|
44 | N FILENAME S FILENAME="RXNSAT.RRF"
|
---|
45 | D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
---|
46 | IF POP W "Error reading file..., Please check...",! BREAK
|
---|
47 | F I=1:1 Q:$$STATUS^%ZISH D
|
---|
48 | . U IO
|
---|
49 | . N LINE R LINE
|
---|
50 | . IF $$STATUS^%ZISH QUIT
|
---|
51 | . U $P W I U IO
|
---|
52 | . IF LINE'["NDC|VANDF" U $P W ?20,"No NDC Here :-)",! U IO QUIT
|
---|
53 | . ; Otherwise, we are good to go
|
---|
54 | . U $P W ?20,"Found VUID/NDC Set",! U IO
|
---|
55 | . N RXCUI,VUID,NDC ; Fileman fields below
|
---|
56 | . S RXCUI=$P(LINE,"|",1) ; .01
|
---|
57 | . S VUID=$P(LINE,"|",6) ; 1
|
---|
58 | . S NDC=$P(LINE,"|",11) ; 2
|
---|
59 | . ; Using classic call to update.
|
---|
60 | . N DIC,X,DA,DR
|
---|
61 | . K DO
|
---|
62 | . S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI
|
---|
63 | . D FILE^DICN
|
---|
64 | . I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! BREAK
|
---|
65 | . S DIE=DIC,DA=$P(Y,"^")
|
---|
66 | . S DR="1////^S X=VUID;2////^S X=NDC"
|
---|
67 | . D ^DIE
|
---|
68 | D CLOSE^%ZISH("FILE")
|
---|
69 | U $P ; reset back to principle device
|
---|
70 | Q
|
---|
71 | ;
|
---|
72 | READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
---|
73 | I PATH="" QUIT
|
---|
74 | N FILENAME S FILENAME="RXNSAB.RRF"
|
---|
75 | D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
---|
76 | IF POP W "Error reading file..., Please check...",! BREAK
|
---|
77 | F I=1:1 Q:$$STATUS^%ZISH D
|
---|
78 | . U IO
|
---|
79 | . N LINE R LINE
|
---|
80 | . IF $$STATUS^%ZISH QUIT
|
---|
81 | . U $P W I,! U IO ; Write I to the screen, then go back to reading the file
|
---|
82 | . N VCUI,RCUI,VSAB,RSAB,SON,SF,SVER,SCIT ; Fileman fields numbers below
|
---|
83 | . S VCUI=$P(LINE,"|",1) ; .01
|
---|
84 | . S RCUI=$P(LINE,"|",2) ; 2
|
---|
85 | . S VSAB=$P(LINE,"|",3) ; 3
|
---|
86 | . S RSAB=$P(LINE,"|",4) ; 4
|
---|
87 | . S SON=$P(LINE,"|",5) ; 5
|
---|
88 | . S SF=$P(LINE,"|",6) ; 6
|
---|
89 | . S SVER=$P(LINE,"|",7) ; 7
|
---|
90 | . S SCIT=$P(LINE,"|",25) ; 25
|
---|
91 | . ; Remove embedded "^"
|
---|
92 | . S SCIT=$TR(SCIT,"^")
|
---|
93 | . ; Convert SCIT into an array of 80 characters on each line
|
---|
94 | . ; In each line, chop 80 characters off, reset SCIT to be the rest
|
---|
95 | . N SCITLINE S SCITLINE=$L(SCIT)\80+1
|
---|
96 | . F J=1:1:SCITLINE S SCIT(J)=$E(SCIT,1,80) S SCIT=$E(SCIT,81,$L(SCIT))
|
---|
97 | . ; Now, construct the FDA array
|
---|
98 | . N RXNFDA
|
---|
99 | . S RXNFDA(176.003,"+"_I_",",.01)=VCUI
|
---|
100 | . S RXNFDA(176.003,"+"_I_",",2)=RCUI
|
---|
101 | . S RXNFDA(176.003,"+"_I_",",3)=VSAB
|
---|
102 | . S RXNFDA(176.003,"+"_I_",",4)=RSAB
|
---|
103 | . S RXNFDA(176.003,"+"_I_",",5)=SON
|
---|
104 | . S RXNFDA(176.003,"+"_I_",",6)=SF
|
---|
105 | . S RXNFDA(176.003,"+"_I_",",7)=SVER
|
---|
106 | . D UPDATE^DIE("","RXNFDA")
|
---|
107 | . I $D(^TMP("DIERR",$J)) U $P BREAK
|
---|
108 | . ; Now, file WP field SCIT
|
---|
109 | . D WP^DIE(176.003,I_",",25,,$NA(SCIT))
|
---|
110 | D CLOSE^%ZISH("FILE")
|
---|
111 | Q
|
---|
112 |
|
---|