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
|
|
|
|
;
|
2009-11-03 14:29:36 -05:00
|
|
|
DELFILED(FN) ; Delete file data; PEP procedure; only for RxNorm files
|
2009-10-21 19:59:28 -04:00
|
|
|
; FN is Filenumber passed by Value
|
2009-11-03 14:29:36 -05:00
|
|
|
QUIT:$E(FN,1,3)'=176 ; Quit if not RxNorm files
|
2009-10-21 19:59:28 -04:00
|
|
|
D CLEAN^DILF ; Clean FM variables
|
2009-11-03 14:29:36 -05:00
|
|
|
N ROOT S ROOT=$$ROOT^DILFD(FN,"",1) ; global root
|
|
|
|
N ZERO S ZERO=@ROOT@(0) ; Save zero node
|
2009-10-21 19:59:28 -04:00
|
|
|
S $P(ZERO,U,3,9999)="" ; Remove entry # and last edited
|
2009-11-03 14:29:36 -05:00
|
|
|
K @ROOT ; Kill the file -- so sad!
|
|
|
|
S @ROOT@(0)=ZERO ; It riseth again!
|
2009-10-21 19:59:28 -04:00
|
|
|
QUIT
|
|
|
|
GETLINES(PATH,FILENAME) ; Get number of lines in a file
|
|
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
|
|
|
U IO
|
|
|
|
N I
|
|
|
|
F I=1:1 R LINE Q:$$STATUS^%ZISH
|
|
|
|
D CLOSE^%ZISH("FILE")
|
|
|
|
Q I-1
|
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"
|
2009-11-03 14:29:36 -05:00
|
|
|
D DELFILED(176.001) ; delete data
|
2009-10-21 19:59:28 -04:00
|
|
|
N LINES S LINES=$$GETLINES(PATH,FILENAME)
|
2008-11-16 21:29:09 -05:00
|
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
2009-10-21 19:59:28 -04:00
|
|
|
IF POP D EN^DDIOL("Error reading file..., Please check...") G EX
|
|
|
|
N C0CCOUNT
|
|
|
|
F C0CCOUNT=1:1 D Q:$$STATUS^%ZISH
|
2008-11-16 21:29:09 -05:00
|
|
|
. U IO
|
|
|
|
. N LINE R LINE
|
|
|
|
. IF $$STATUS^%ZISH QUIT
|
2009-10-21 19:59:28 -04:00
|
|
|
. I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
|
2008-11-16 21:29:09 -05:00
|
|
|
. 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
|
2009-10-21 19:59:28 -04:00
|
|
|
. N J F J=1:1:STRLINE S STR(J)=$E(STR,1,80) S STR=$E(STR,81,$L(STR))
|
2008-11-16 21:29:09 -05:00
|
|
|
. ; Now, construct the FDA array
|
|
|
|
. N RXNFDA
|
2009-10-21 19:59:28 -04:00
|
|
|
. S RXNFDA(176.001,"+"_C0CCOUNT_",",.01)=RXCUI
|
|
|
|
. S RXNFDA(176.001,"+"_C0CCOUNT_",",1)=RXAUI
|
|
|
|
. S RXNFDA(176.001,"+"_C0CCOUNT_",",2)=SAB
|
|
|
|
. S RXNFDA(176.001,"+"_C0CCOUNT_",",3)=TTY
|
|
|
|
. S RXNFDA(176.001,"+"_C0CCOUNT_",",4)=CODE
|
2008-11-16 21:29:09 -05:00
|
|
|
. D UPDATE^DIE("","RXNFDA")
|
2009-10-21 19:59:28 -04:00
|
|
|
. I $D(^TMP("DIERR",$J)) D EN^DDIOL("ERROR") G EX
|
2008-11-16 21:29:09 -05:00
|
|
|
. ; Now, file WP field STR
|
2009-10-21 19:59:28 -04:00
|
|
|
. D WP^DIE(176.001,C0CCOUNT_",",5,,$NA(STR))
|
|
|
|
EX D CLOSE^%ZISH("FILE")
|
|
|
|
QUIT
|
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"
|
2009-11-03 14:29:36 -05:00
|
|
|
D DELFILED(176.002) ; delete data
|
2009-10-21 19:59:28 -04:00
|
|
|
N LINES S LINES=$$GETLINES(PATH,FILENAME)
|
2008-11-16 21:29:09 -05:00
|
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
2009-10-21 19:59:28 -04:00
|
|
|
IF POP W "Error reading file..., Please check...",! G EX2
|
|
|
|
F C0CCOUNT=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
|
2009-10-21 19:59:28 -04:00
|
|
|
. I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
|
|
|
|
. IF LINE'["NDC|RXNORM" QUIT
|
2008-11-16 21:29:09 -05:00
|
|
|
. ; Otherwise, we are good to go
|
2009-02-15 18:06:34 -05:00
|
|
|
. N RXCUI,NDC ; Fileman fields below
|
2008-11-16 21:29:09 -05:00
|
|
|
. S RXCUI=$P(LINE,"|",1) ; .01
|
|
|
|
. S NDC=$P(LINE,"|",11) ; 2
|
|
|
|
. ; Using classic call to update.
|
|
|
|
. N DIC,X,DA,DR
|
|
|
|
. K DO
|
2009-10-21 19:59:28 -04:00
|
|
|
. S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI,DIC("DR")="2////"_NDC
|
2008-11-16 21:29:09 -05:00
|
|
|
. D FILE^DICN
|
2009-10-21 19:59:28 -04:00
|
|
|
. I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! G EX2
|
|
|
|
EX2 D CLOSE^%ZISH("FILE")
|
2009-02-15 18:06:34 -05:00
|
|
|
QUIT
|
2009-10-21 14:13:44 -04:00
|
|
|
READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
|
|
|
I PATH="" QUIT
|
|
|
|
N FILENAME S FILENAME="RXNSAB.RRF"
|
2009-11-03 14:29:36 -05:00
|
|
|
D DELFILED(176.003) ; delete data
|
2009-10-21 14:13:44 -04:00
|
|
|
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
2009-10-21 19:59:28 -04:00
|
|
|
IF POP W "Error reading file..., Please check...",! G EX3
|
2009-10-21 14:13:44 -04:00
|
|
|
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")
|
2009-10-21 19:59:28 -04:00
|
|
|
. I $D(^TMP("DIERR",$J)) U $P W "ERR" G EX
|
2009-10-21 14:13:44 -04:00
|
|
|
. ; Now, file WP field SCIT
|
|
|
|
. D WP^DIE(176.003,I_",",25,,$NA(SCIT))
|
2009-10-21 19:59:28 -04:00
|
|
|
EX3 D CLOSE^%ZISH("FILE")
|
2009-10-21 14:13:44 -04:00
|
|
|
Q
|
|
|
|
|