VistA-ccr/p/C0CRXNRD.m

113 lines
3.7 KiB
Mathematica
Raw Normal View History

2008-11-16 21:29:09 -05:00
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
;
2008-12-26 17:58:42 -05:00
READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
I PATH="" QUIT
2008-11-16 21:29:09 -05:00
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 "^"
2008-11-17 20:55:40 -05:00
. S STR=$TR(STR,"^")
2008-11-16 21:29:09 -05:00
. ; 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
2008-12-26 17:58:42 -05:00
. 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
2008-11-16 21:29:09 -05:00
. D UPDATE^DIE("","RXNFDA")
. I $D(^TMP("DIERR",$J)) U $P BREAK
. ; Now, file WP field STR
2008-12-26 17:58:42 -05:00
. D WP^DIE(176.001,I_",",5,,$NA(STR))
2008-11-16 21:29:09 -05:00
D CLOSE^%ZISH("FILE")
Q
;
2008-12-26 19:35:54 -05:00
READNDC(PATH) ; Open and read NDC/RxNorm/VANDF relationship file: RXNSAT.RRF
I PATH="" QUIT
N FILENAME S FILENAME="RXNSAT.RRF"
2008-11-16 21:29:09 -05:00
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
IF POP W "Error reading file..., Please check...",! BREAK
F I=1:1 Q:$$STATUS^%ZISH D
2008-12-26 19:35:54 -05:00
. U IO
2008-11-16 21:29:09 -05:00
. 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
2008-12-26 19:35:54 -05:00
. S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI
2008-11-16 21:29:09 -05:00
. 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")
2008-12-26 19:35:54 -05:00
U $P ; reset back to principle device
Q
;
READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
I PATH="" QUIT
N FILENAME S FILENAME="RXNSAB.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 VCUI,RCUI,VSAB,RSAB,SON,SF,SVER,SCIT ; Fileman fields numbers below
. S VCUI=$P(LINE,"|",1) ; .01
. S RCUI=$P(LINE,"|",2) ; 2
. S VSAB=$P(LINE,"|",3) ; 3
. S RSAB=$P(LINE,"|",4) ; 4
. S SON=$P(LINE,"|",5) ; 5
. S SF=$P(LINE,"|",6) ; 6
. S SVER=$P(LINE,"|",7) ; 7
. S SCIT=$P(LINE,"|",25) ; 25
. ; Remove embedded "^"
. S SCIT=$TR(SCIT,"^")
. ; Convert SCIT into an array of 80 characters on each line
. ; In each line, chop 80 characters off, reset SCIT to be the rest
. N SCITLINE S SCITLINE=$L(SCIT)\80+1
. F J=1:1:SCITLINE S SCIT(J)=$E(SCIT,1,80) S SCIT=$E(SCIT,81,$L(SCIT))
. ; Now, construct the FDA array
. N RXNFDA
. S RXNFDA(176.003,"+"_I_",",.01)=VCUI
. S RXNFDA(176.003,"+"_I_",",2)=RCUI
. S RXNFDA(176.003,"+"_I_",",3)=VSAB
. S RXNFDA(176.003,"+"_I_",",4)=RSAB
. S RXNFDA(176.003,"+"_I_",",5)=SON
. S RXNFDA(176.003,"+"_I_",",6)=SF
. S RXNFDA(176.003,"+"_I_",",7)=SVER
. D UPDATE^DIE("","RXNFDA")
. I $D(^TMP("DIERR",$J)) U $P BREAK
. ; Now, file WP field SCIT
. D WP^DIE(176.003,I_",",25,,$NA(SCIT))
D CLOSE^%ZISH("FILE")
Q
2008-11-16 21:29:09 -05:00