72 lines
2.3 KiB
Mathematica
72 lines
2.3 KiB
Mathematica
C0CRXNRD ; WV/SMH - CCR/CCD PROJECT: Routine to Read RxNorm files;11/15/08
|
|
;;0.1;CCDCCR;nopatch;noreleasedate
|
|
W "No entry from top" Q
|
|
;
|
|
READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
|
|
I PATH="" QUIT
|
|
N FILENAME S FILENAME="RXNCONSO.RRF"
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
|
IF POP W "Error reading file..., Please check...",! BREAK
|
|
F I=1:1 Q:$$STATUS^%ZISH D
|
|
. U IO
|
|
. N LINE R LINE
|
|
. IF $$STATUS^%ZISH QUIT
|
|
. U $P W I,! U IO ; Write I to the screen, then go back to reading the file
|
|
. N RXCUI,RXAUI,SAB,TTY,CODE,STR ; Fileman fields numbers below
|
|
. S RXCUI=$P(LINE,"|",1) ; .01
|
|
. S RXAUI=$P(LINE,"|",8) ; 1
|
|
. S SAB=$P(LINE,"|",12) ; 2
|
|
. S TTY=$P(LINE,"|",13) ; 3
|
|
. S CODE=$P(LINE,"|",14) ; 4
|
|
. S STR=$P(LINE,"|",15) ; 5
|
|
. ; Remove embedded "^"
|
|
. S STR=$TR(STR,"^")
|
|
. ; Convert STR into an array of 80 characters on each line
|
|
. N STRLINE S STRLINE=$L(STR)\80+1
|
|
. ; In each line, chop 80 characters off, reset STR to be the rest
|
|
. F J=1:1:STRLINE S STR(J)=$E(STR,1,80) S STR=$E(STR,81,$L(STR))
|
|
. ; Now, construct the FDA array
|
|
. N RXNFDA
|
|
. S RXNFDA(176.001,"+"_I_",",.01)=RXCUI
|
|
. S RXNFDA(176.001,"+"_I_",",1)=RXAUI
|
|
. S RXNFDA(176.001,"+"_I_",",2)=SAB
|
|
. S RXNFDA(176.001,"+"_I_",",3)=TTY
|
|
. S RXNFDA(176.001,"+"_I_",",4)=CODE
|
|
. D UPDATE^DIE("","RXNFDA")
|
|
. I $D(^TMP("DIERR",$J)) U $P BREAK
|
|
. ; Now, file WP field STR
|
|
. D WP^DIE(176.001,I_",",5,,$NA(STR))
|
|
D CLOSE^%ZISH("FILE")
|
|
Q
|
|
;
|
|
READNDC(PATH) ; Open and read NDC/RxNorm/VANDF relationship file: RXNSAT.RRF
|
|
I PATH="" QUIT
|
|
N FILENAME S FILENAME="RXNSAT.RRF"
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
|
IF POP W "Error reading file..., Please check...",! BREAK
|
|
F I=1:1 Q:$$STATUS^%ZISH D
|
|
. U IO
|
|
. N LINE R LINE
|
|
. IF $$STATUS^%ZISH QUIT
|
|
. U $P W I U IO
|
|
. IF LINE'["NDC|VANDF" U $P W ?20,"No NDC Here :-)",! U IO QUIT
|
|
. ; Otherwise, we are good to go
|
|
. U $P W ?20,"Found VUID/NDC Set",! U IO
|
|
. N RXCUI,VUID,NDC ; Fileman fields below
|
|
. S RXCUI=$P(LINE,"|",1) ; .01
|
|
. S VUID=$P(LINE,"|",6) ; 1
|
|
. S NDC=$P(LINE,"|",11) ; 2
|
|
. ; Using classic call to update.
|
|
. N DIC,X,DA,DR
|
|
. K DO
|
|
. S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI
|
|
. D FILE^DICN
|
|
. I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! BREAK
|
|
. S DIE=DIC,DA=$P(Y,"^")
|
|
. S DR="1////^S X=VUID;2////^S X=NDC"
|
|
. D ^DIE
|
|
D CLOSE^%ZISH("FILE")
|
|
U $P ; reset back to principle device
|
|
|
|
|