Index: ccr/trunk/p/C0CDIC.m
===================================================================
--- ccr/trunk/p/C0CDIC.m	(revision 299)
+++ ccr/trunk/p/C0CDIC.m	(revision 300)
@@ -99,74 +99,4 @@
  Q
  ;
-FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
- ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE
- ;
- N C0CFI,C0CFJ ;INNER LOOP, OUTER LOOP
- N C0CFN ; FIELD NAME
- S C0CFI=0 S C0CFJ=C0CF
- K @C0CFRTN ; CLEAR THE RETURN ARRAY
- F  Q:C0CFJ'[C0CF  D ; FOR THE C0CF FILE AND ALL SUBFILES INCLUSIVE
- . ;W "1: "_C0CFJ," ",C0CFI,!
- . F  S C0CFI=$O(^DD(C0CFJ,C0CFI)) Q:+C0CFI=0  D  ; EVERY FIELD
- . . ;W "2: "_C0CFJ," ",C0CFI,!
- . . S C0CFN=$P(^DD(C0CFJ,C0CFI,0),"^",1) ;PULL FIELD NAME FROM ^DD
- . . ;W "N: ",C0CFN,!
- . . ;I C0CFN="STR" W C0CFN," ",C0CFJ,!
- . . I $D(@C0CFRTN@(C0CFN)) D  ; IS THIS A DUPLICATE?
- . . . W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),!
- . . . S @C0CFRTN@(C0CFN_"_"_C0CFJ)=C0CFJ_"^"_C0CFI
- . . E  S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI
- . S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE
- Q
- ;
-GET(GRTN,GFILE,GIEN,GNN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
- ; BY NAME
- ;
- N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
- I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
- E  S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
- S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
- D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
- D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP")
- D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
- S (C0CI,C0CJ)=""
- F  S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ=""  D  ; FOR ALL SUBFILES
- . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE
- . F  S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI=""  D  ; ARRAY OF FIELDS
- . . ;W C0CJ," ",C0CI,!
- . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
- . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI) ;
- . . I C0CVALUE["C0CTMP" S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,1) ;1ST LINE OF WP
- . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
- I C0CNN D  ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
- . S C0CI=""
- . F  S C0CI=$O(@GRTN@(C0CI)) Q:C0CI=""  D  ; GO THROUGH THE WHOLE ARRAY
- . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
- Q
- ;
-GETALL(GARFLD,GARVAL,GAFILE,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
- ; GARFLD, PASSED BY NAME, RETURNS FIELD MAP @GARFLD@("FIELDNAME")
- ; .. ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
- ; .. GARFLD IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
- ; .. IF GANN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
- ; GARVAL, PASSED BY NAME, RETURNS VALUES AS @GARVAL@(IEN,"FIELDNAME")=VALUE
- ; .. FOR EVERY RECORD PROCESSED. IT IS NOT INITIALEZED SO IT IS CUMMULATIVE
- ; .. EVEN IF GANN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN GARVAL
- ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING GARFLD - THIS SAVES SPACE
- ; GARFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE
- ; GARCNT IS THE NUMBER OF RECORDS TO PROCESS. IT IS PASSED BY VALUE
- ; .. IF GARCNT IS NULL, ALL RECORDS ARE PROCESSED
- ; GARSTRT IS THE IEN OF THE FIRST RECORD TO PROCESS. IT IS PASSED BY VALUE
- ; .. IF GARSTART IS NULL, PROCESSING STARTS AT THE FIRST RECORD
- ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
- ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL
- N GATMP,GAI,GAF
- S GAF=^DIC(GAFILE,0,"GL") ;OPEN ROOT TO FILE
- S GAF=$P(GAF,",",1)_")" ; CLOSE THE ROOT
- W $O(@GAF@(0)) ;
- S GAI=0 ;ITERATOR
- ; F  S GAI=$O(@GAF@
- Q
- ;
 INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES
  ;
@@ -192,5 +122,5 @@
  . ;W C0CZX,!
  . K C0CA,C0CN ; CLEAR OUT THE LAST ONE
- . D GET("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH
+ . D GET^C0CRNF("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH
  . ;ZWR C0CA B ;
  . S C0CN=$$ZVALUE("VARIABLE") ;NAME OF THE VARIABLE
@@ -237,16 +167,22 @@
  ;
  N C0CSI,C0CSJ
- S C0CSI=$$ZFILE(C0CSN) ; FILE NUMBER
- S C0CSJ=$$ZFIELD(C0CSN) ; FIELD NUMBER
+ S C0CSI=$$ZFILE(C0CSN,"C0CA") ; FILE NUMBER
+ S C0CSJ=$$ZFIELD(C0CSN,"C0CA") ; FIELD NUMBER
  S C0CFDA(C0CZX,C0CSI,C0CZX_",",C0CSJ)=C0CSV
  Q
-ZFILE(ZFN) ; INTERNAL EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
+ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
  ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
- Q $P(C0CA(ZFN),"^",1)
-ZFIELD(ZFN) ;INTERNAL EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
+ ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
+ I '$D(ZTAB) S ZTAB="C0CA"
+ Q $P(@ZTAB@(ZFN),"^",1)
+ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
  ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
- Q $P(C0CA(ZFN),"^",2)
-ZVALUE(ZFN) ;INTERNAL EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
+ ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
+ I '$D(ZTAB) S ZTAB="C0CA"
+ Q $P(@ZTAB@(ZFN),"^",2)
+ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
  ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
- Q $P(C0CA(ZFN),"^",3)
+ ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
+ I '$D(ZTAB) S ZTAB="C0CA"
+ Q $P(@ZTAB@(ZFN),"^",3)
  ;
