Index: ccr/trunk/p/C0CRNF.m
===================================================================
--- ccr/trunk/p/C0CRNF.m	(revision 300)
+++ ccr/trunk/p/C0CRNF.m	(revision 301)
@@ -43,6 +43,6 @@
  Q
  ;
-GET(GRTN,GFILE,GIEN,GNN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
- ; BY NAME
+GETN(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
+ ; GRTN IS PASSED BY NAME
  ;
  N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
@@ -68,7 +68,14 @@
  Q
  ;
-GET2(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ;RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
- ; BY NAME
- ; GET IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
+GETN2(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
+ ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
+ ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
+ ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
+ ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
+ ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE
+ ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE
+ ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP
+ ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
+ ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
  ; IF GREF IS "" THE FIRST RECORD IS OBTAINED
  ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE
@@ -77,10 +84,16 @@
  ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED
  ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN
- ; 
  ;
- N GIEN
+ ;
+ N GIEN,GF
+ S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
  I '$D(GNDX) S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
  E  D  ; WE ARE USING AN INDEX
- . 
+ . ;N ZG
+ . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX
+ . I $QS(ZG,3)=GREF D  ; IS GREF IN INDEX?
+ . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN
+ . E  S GIEN="" ; NOT FOUND IN INDEX
+ W "IEN: ",GIEN,!
  N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME
  I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
@@ -105,17 +118,17 @@
  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
+GETALL(GARTN,GAFILE,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
+ ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
+ ; .. FIELD MAP @GARTN@("F","FIELDNAME^FILE^FIELD#")=""
+ ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP
+ ; .. VALUE MAP @GARTN@("V","IEN","FIELDNAME")=VALUE
+ ; .. GARTN 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
+ ; .. EVEN IF GANN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP
+ ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE
+ ; GAFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE
+ ; GACNT 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
+ ; GASTRT 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
@@ -131,5 +144,5 @@
 FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
  ;
- N C0CF 
+ N C0CF
  S C0CF=^DIC(FNUM,0,"GL") ;OPEN ROOT TO FILE
  S C0CF=$P(C0CF,",",1)_")" ; CLOSE THE ROOT
