updates to GETN^C0CRNF .. changed GET to GETN

This commit is contained in:
george 2008-12-08 17:59:46 +00:00
parent 7c33cb00bb
commit e09a29dceb
2 changed files with 35 additions and 22 deletions

View File

@ -121,7 +121,7 @@ INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES
F S C0CZX=$O(^C0CDIC(170,C0CZX)) Q:+C0CZX=0 D ; FOR EACH DICT ENTRY
. ;W C0CZX,!
. K C0CA,C0CN ; CLEAR OUT THE LAST ONE
. D GET^C0CRNF("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH
. D GETN^C0CRNF("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH
. ;ZWR C0CA B ;
. S C0CN=$$ZVALUE("VARIABLE") ;NAME OF THE VARIABLE
. W "VARIABLE: ",C0CN,!

View File

@ -42,8 +42,8 @@ FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
. S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE
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
I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)
@ -67,21 +67,34 @@ GET(GRTN,GFILE,GIEN,GNN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASS
. . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES
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
; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN
; GREF IS THE VALUE FOR THE INDEX
; 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)
E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
@ -104,19 +117,19 @@ GET2(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ;RETURN THE DICTIONARY RECORD GIEN
. . 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
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
; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL
@ -130,7 +143,7 @@ GETALL(GARFLD,GARVAL,GAFILE,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES
;
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
Q C0CF
@ -150,4 +163,4 @@ ZVALUE(ZFN,ZTAB) ;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),"^",3)
;
;