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 |
|
---|
71 |
|
---|