Changeset 582 for ccr/trunk


Ignore:
Timestamp:
Oct 21, 2009, 7:59:28 PM (15 years ago)
Author:
Sam Habiel
Message:

More updated to C0CRXNRD. Now it deletes the RxNorm files priors to building them again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CRXNRD.m

    r581 r582  
    33 W "No entry from top" Q
    44 ;
     5DELFILED(FN,ERR) ; Delete file data; PEP procedure; READ WARNING
     6 ; FN is Filenumber passed by Value
     7 ; ERR is error info, passed by reference
     8 ; If ERR is 1, then the operation failed.
     9 ; WARNING: THIS IS VERY DANGEROUS OPERATION
     10 ; I DON'T EVEN CHECK THE DEL NODE ON THE FILE!!!!
     11 ;
     12 D CLEAN^DILF ; Clean FM variables
     13 N C0CFINFO ; File info
     14 D FILE^DID(FN,"","GLOBAL NAME","C0CROOT") ; Get file info
     15 I $D(DIERR) D EN^DDIOL("Error...") S ERR=1 QUIT
     16 N ROOT2 S ROOT2=C0CROOT("GLOBAL NAME") ; Open global root
     17 N CLROOT S CLROOT=$$CREF^DILF(ROOT2) ; Closed Root
     18 N ZERO S ZERO=@CLROOT@(0) ; Save zero node
     19 S $P(ZERO,U,3,9999)="" ; Remove entry # and last edited
     20 K @CLROOT ; Kill the file -- so sad!
     21 S @CLROOT@(0)=ZERO ; It riseth again!
     22 QUIT
     23GETLINES(PATH,FILENAME) ; Get number of lines in a file
     24 D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
     25 U IO
     26 N I
     27 F I=1:1 R LINE Q:$$STATUS^%ZISH
     28 D CLOSE^%ZISH("FILE")
     29 Q I-1
    530READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
    631 I PATH="" QUIT
    732 N FILENAME S FILENAME="RXNCONSO.RRF"
     33 N ERR
     34 D DELFILED(176.001,.ERR) ; delete data
     35 IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX
     36 N LINES S LINES=$$GETLINES(PATH,FILENAME)
    837 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
     38 IF POP D EN^DDIOL("Error reading file..., Please check...") G EX
     39 N C0CCOUNT
     40 F C0CCOUNT=1:1 D  Q:$$STATUS^%ZISH
    1141 . U IO
    1242 . N LINE R LINE
    1343 . IF $$STATUS^%ZISH QUIT
    14  . U $P W I,! U IO  ; Write I to the screen, then go back to reading the file
     44 . I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
    1545 . N RXCUI,RXAUI,SAB,TTY,CODE,STR  ; Fileman fields numbers below
    1646 . S RXCUI=$P(LINE,"|",1)       ; .01
     
    2555 . N STRLINE S STRLINE=$L(STR)\80+1
    2656 . ; 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))
     57 . N J F J=1:1:STRLINE S STR(J)=$E(STR,1,80) S STR=$E(STR,81,$L(STR))
    2858 . ; Now, construct the FDA array
    2959 . 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
     60 . S RXNFDA(176.001,"+"_C0CCOUNT_",",.01)=RXCUI
     61 . S RXNFDA(176.001,"+"_C0CCOUNT_",",1)=RXAUI
     62 . S RXNFDA(176.001,"+"_C0CCOUNT_",",2)=SAB
     63 . S RXNFDA(176.001,"+"_C0CCOUNT_",",3)=TTY
     64 . S RXNFDA(176.001,"+"_C0CCOUNT_",",4)=CODE
    3565 . D UPDATE^DIE("","RXNFDA")
    36  . I $D(^TMP("DIERR",$J)) U $P BREAK
     66 . I $D(^TMP("DIERR",$J)) D EN^DDIOL("ERROR") G EX
    3767 . ; Now, file WP field STR
    38  . D WP^DIE(176.001,I_",",5,,$NA(STR))
    39  D CLOSE^%ZISH("FILE")
    40  Q
    41  ;
     68 . D WP^DIE(176.001,C0CCOUNT_",",5,,$NA(STR))
     69EX D CLOSE^%ZISH("FILE")
     70 QUIT
    4271READNDC(PATH) ; Open and read NDC/RxNorm/VANDF relationship file: RXNSAT.RRF
    4372 I PATH="" QUIT
    4473 N FILENAME S FILENAME="RXNSAT.RRF"
     74 N ERR
     75 D DELFILED(176.002,.ERR) ; delete data
     76 IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX2
     77 N LINES S LINES=$$GETLINES(PATH,FILENAME)
    4578 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
     79 IF POP W "Error reading file..., Please check...",! G EX2
     80 F C0CCOUNT=1:1 Q:$$STATUS^%ZISH  D
    4881 . U IO
    4982 . N LINE R LINE
    5083 . IF $$STATUS^%ZISH QUIT
    51  . U $P W I U IO
    52  . IF LINE'["NDC|RXNORM" U $P W ?20,"No NDC Here :-)",! U IO QUIT
     84 . I '(C0CCOUNT#1000) U $P W C0CCOUNT," of ",LINES," read ",! U IO ; update every 1000
     85 . IF LINE'["NDC|RXNORM" QUIT
    5386 . ; Otherwise, we are good to go
    54  . U $P W ?20,"Found RXNORM/NDC Set",! U IO
    5587 . N RXCUI,NDC ; Fileman fields below
    5688 . S RXCUI=$P(LINE,"|",1)       ; .01
     
    5991 . N DIC,X,DA,DR
    6092 . K DO
    61  . S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI
     93 . S DIC="^C0CRXN(176.002,",DIC(0)="F",X=RXCUI,DIC("DR")="2////"_NDC
    6294 . D FILE^DICN
    63  . I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! BREAK
    64  . S DIE=DIC,DA=$P(Y,"^")
    65  . S DR="2////^S X=NDC"
    66  . D ^DIE
    67  D CLOSE^%ZISH("FILE")
    68  U $P ; reset back to principle device
     95 . I Y<1 U $P W !,"THERE IS TROUBLE IN RIVER CITY",! G EX2
     96EX2 D CLOSE^%ZISH("FILE")
    6997 QUIT
    7098READSRC(PATH) ; Open the read RxNorm Sources file: RXNSAB.RRF
    7199 I PATH="" QUIT
    72100 N FILENAME S FILENAME="RXNSAB.RRF"
     101 N ERR
     102 D DELFILED(176.003,.ERR) ; delete data
     103 IF $G(ERR) D EN^DDIOL("Couldn't delete file") G EX2
    73104 D OPEN^%ZISH("FILE",PATH,FILENAME,"R")
    74  IF POP W "Error reading file..., Please check...",! BREAK
     105 IF POP W "Error reading file..., Please check...",! G EX3
    75106 F I=1:1 Q:$$STATUS^%ZISH  D
    76107 . U IO
     
    103134 . S RXNFDA(176.003,"+"_I_",",7)=SVER
    104135 . D UPDATE^DIE("","RXNFDA")
    105  . I $D(^TMP("DIERR",$J)) U $P BREAK
     136 . I $D(^TMP("DIERR",$J)) U $P W "ERR" G EX
    106137 . ; Now, file WP field SCIT
    107138 . D WP^DIE(176.003,I_",",25,,$NA(SCIT))
    108  D CLOSE^%ZISH("FILE")
     139EX3 D CLOSE^%ZISH("FILE")
    109140 Q
    110141
Note: See TracChangeset for help on using the changeset viewer.