More updated to C0CRXNRD. Now it deletes the RxNorm files priors to building them again
This commit is contained in:
parent
7dfacb9382
commit
7c6a2de1a6
89
p/C0CRXNRD.m
89
p/C0CRXNRD.m
|
@ -2,16 +2,46 @@ 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
|
||||
;
|
||||
DELFILED(FN,ERR) ; Delete file data; PEP procedure; READ WARNING
|
||||
; FN is Filenumber passed by Value
|
||||
; ERR is error info, passed by reference
|
||||
; If ERR is 1, then the operation failed.
|
||||
; WARNING: THIS IS VERY DANGEROUS OPERATION
|
||||
; I DON'T EVEN CHECK THE DEL NODE ON THE FILE!!!!
|
||||
;
|
||||
D CLEAN^DILF ; Clean FM variables
|
||||
N C0CFINFO ; File info
|
||||
D FILE^DID(FN,"","GLOBAL NAME","C0CROOT") ; Get file info
|
||||
I $D(DIERR) D EN^DDIOL("Error...") S ERR=1 QUIT
|
||||
N ROOT2 S ROOT2=C0CROOT("GLOBAL NAME") ; Open global root
|
||||
N CLROOT S CLROOT=$$CREF^DILF(ROOT2) ; Closed Root
|
||||
N ZERO S ZERO=@CLROOT@(0) ; Save zero node
|
||||
S $P(ZERO,U,3,9999)="" ; Remove entry # and last edited
|
||||
K @CLROOT ; Kill the file -- so sad!
|
||||
S @CLROOT@(0)=ZERO ; It riseth again!
|
||||
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
|
||||
READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
|
||||
I PATH="" QUIT
|
||||
N FILENAME S FILENAME="RXNCONSO.RRF"
|
||||
N ERR
|
||||
D DELFILED(176.001,.ERR) ; delete data
|
||||
IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX
|
||||
N LINES S LINES=$$GETLINES(PATH,FILENAME)
|
||||
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
||||
IF POP W "Error reading file..., Please check...",! BREAK
|
||||
F I=1:1 Q:$$STATUS^%ZISH D
|
||||
IF POP D EN^DDIOL("Error reading file..., Please check...") G EX
|
||||
N C0CCOUNT
|
||||
F C0CCOUNT=1:1 D Q:$$STATUS^%ZISH
|
||||
. 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
|
||||
. I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
|
||||
. N RXCUI,RXAUI,SAB,TTY,CODE,STR ; Fileman fields numbers below
|
||||
. S RXCUI=$P(LINE,"|",1) ; .01
|
||||
. S RXAUI=$P(LINE,"|",8) ; 1
|
||||
|
@ -24,54 +54,55 @@ READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
|
|||
. ; 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))
|
||||
. N J 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
|
||||
. 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
|
||||
. D UPDATE^DIE("","RXNFDA")
|
||||
. I $D(^TMP("DIERR",$J)) U $P BREAK
|
||||
. I $D(^TMP("DIERR",$J)) D EN^DDIOL("ERROR") G EX
|
||||
. ; Now, file WP field STR
|
||||
. D WP^DIE(176.001,I_",",5,,$NA(STR))
|
||||
D CLOSE^%ZISH("FILE")
|
||||
Q
|
||||
;
|
||||
. D WP^DIE(176.001,C0CCOUNT_",",5,,$NA(STR))
|
||||
EX D CLOSE^%ZISH("FILE")
|
||||
QUIT
|
||||
READNDC(PATH) ; Open and read NDC/RxNorm/VANDF relationship file: RXNSAT.RRF
|
||||
I PATH="" QUIT
|
||||
N FILENAME S FILENAME="RXNSAT.RRF"
|
||||
N ERR
|
||||
D DELFILED(176.002,.ERR) ; delete data
|
||||
IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX2
|
||||
N LINES S LINES=$$GETLINES(PATH,FILENAME)
|
||||
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
||||
IF POP W "Error reading file..., Please check...",! BREAK
|
||||
F I=1:1 Q:$$STATUS^%ZISH D
|
||||
IF POP W "Error reading file..., Please check...",! G EX2
|
||||
F C0CCOUNT=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|RXNORM" U $P W ?20,"No NDC Here :-)",! U IO QUIT
|
||||
. I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
|
||||
. IF LINE'["NDC|RXNORM" QUIT
|
||||
. ; Otherwise, we are good to go
|
||||
. U $P W ?20,"Found RXNORM/NDC Set",! U IO
|
||||
. N RXCUI,NDC ; Fileman fields below
|
||||
. S RXCUI=$P(LINE,"|",1) ; .01
|
||||
. 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
|
||||
. S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI,DIC("DR")="2////"_NDC
|
||||
. D FILE^DICN
|
||||
. I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! BREAK
|
||||
. S DIE=DIC,DA=$P(Y,"^")
|
||||
. S DR="2////^S X=NDC"
|
||||
. D ^DIE
|
||||
D CLOSE^%ZISH("FILE")
|
||||
U $P ; reset back to principle device
|
||||
. I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! G EX2
|
||||
EX2 D CLOSE^%ZISH("FILE")
|
||||
QUIT
|
||||
READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
||||
I PATH="" QUIT
|
||||
N FILENAME S FILENAME="RXNSAB.RRF"
|
||||
N ERR
|
||||
D DELFILED(176.003,.ERR) ; delete data
|
||||
IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX2
|
||||
D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
|
||||
IF POP W "Error reading file..., Please check...",! BREAK
|
||||
IF POP W "Error reading file..., Please check...",! G EX3
|
||||
F I=1:1 Q:$$STATUS^%ZISH D
|
||||
. U IO
|
||||
. N LINE R LINE
|
||||
|
@ -102,9 +133,9 @@ READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
|
|||
. 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
|
||||
. I $D(^TMP("DIERR",$J)) U $P W "ERR" G EX
|
||||
. ; Now, file WP field SCIT
|
||||
. D WP^DIE(176.003,I_",",25,,$NA(SCIT))
|
||||
D CLOSE^%ZISH("FILE")
|
||||
EX3 D CLOSE^%ZISH("FILE")
|
||||
Q
|
||||
|
||||
|
|
Loading…
Reference in New Issue