Index: /ccr/trunk/p/C0CRXNRD.m
===================================================================
--- /ccr/trunk/p/C0CRXNRD.m	(revision 593)
+++ /ccr/trunk/p/C0CRXNRD.m	(revision 594)
@@ -1,5 +1,9 @@
 C0CRXNRD ; WV/SMH - CCR/CCD PROJECT: Routine to Read RxNorm files;11/15/08
- ;;0.1;CCDCCR;nopatch;noreleasedate
+ ;;0.1;C0C;nopatch;noreleasedate
  W "No entry from top" Q
+IMPORT(PATH)
+ I PATH="" QUIT
+ D READSRC(PATH),READCON(PATH),READNDC(PATH)
+ QUIT
  ;
 DELFILED(FN) ; Delete file data; PEP procedure; only for RxNorm files
@@ -20,6 +24,9 @@
  D CLOSE^%ZISH("FILE")
  Q I-1
-READCON(PATH) ; Open and read concepts file: RXNCONSO.RRF
+READCON(PATH,INCRES) ; Open and read concepts file: RXNCONSO.RRF; EP
+ ; PATH ByVal, path of RxNorm files
+ ; INCRES ByVal, include restricted sources. 1 for yes, 0 for no
  I PATH="" QUIT
+ S INCRES=+$G(INCRES) ; if not passed, becomes zero.
  N FILENAME S FILENAME="RXNCONSO.RRF"
  D DELFILED(176.001) ; delete data
@@ -37,4 +44,10 @@
  . S RXAUI=$P(LINE,"|",8)	; 1
  . S SAB=$P(LINE,"|",12)	; 2
+ . ; If the source is a restricted source, decide what to do based on what's asked.
+ . N SRCIEN S SRCIEN=$$FIND1^DIC(176.003,"","QX",SAB,"B") ; SrcIEN in RXNORM SOURCES file
+ . N RESTRIC S RESTRIC=$$GET1^DIQ(176.003,SRCIEN,14,"I") ; 14 is restriction field; values 0-4
+ . ; If RESTRIC is zero, then it's unrestricted. Everything else is restricted.
+ . ; If user didn't ask to include restricted sources, and the source is restricted, then quit
+ . I 'INCRES,RESTRIC QUIT
  . S TTY=$P(LINE,"|",13)	; 3
  . S CODE=$P(LINE,"|",14)	; 4
@@ -53,5 +66,6 @@
  . S RXNFDA(176.001,"+"_C0CCOUNT_",",3)=TTY
  . S RXNFDA(176.001,"+"_C0CCOUNT_",",4)=CODE
- . D UPDATE^DIE("","RXNFDA")
+ . N RXNIEN S RXNIEN(1)=C0CCOUNT
+ . D UPDATE^DIE("","RXNFDA","RXNIEN")
  . I $D(^TMP("DIERR",$J)) D EN^DDIOL("ERROR") G EX
  . ; Now, file WP field STR
@@ -95,5 +109,5 @@
  . 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
+ . N VCUI,RCUI,VSAB,RSAB,SON,SF,SVER,SRL,SCIT ; Fileman fields numbers below
  . S VCUI=$P(LINE,"|",1)        ; .01
  . S RCUI=$P(LINE,"|",2)        ; 2
@@ -103,4 +117,5 @@
  . S SF=$P(LINE,"|",6)          ; 6
  . S SVER=$P(LINE,"|",7)        ; 7
+ . S SRL=$P(LINE,"|",14)		; 14
  . S SCIT=$P(LINE,"|",25)       ; 25
  . ; Remove embedded "^"
@@ -119,4 +134,5 @@
  . S RXNFDA(176.003,"+"_I_",",6)=SF
  . S RXNFDA(176.003,"+"_I_",",7)=SVER
+ . S RXNFDA(176.003,"+"_I_",",14)=SRL
  . D UPDATE^DIE("","RXNFDA")
  . I $D(^TMP("DIERR",$J)) U $P W "ERR" G EX
