fixes to GET and FIELD to handle duplicate field titles

This commit is contained in:
george 2008-12-05 20:04:15 +00:00
parent a1deebffc8
commit 8c2924b83d
1 changed files with 13 additions and 4 deletions

View File

@ -111,17 +111,20 @@ FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,
. . ;W "2: "_C0CFJ," ",C0CFI,! . . ;W "2: "_C0CFJ," ",C0CFI,!
. . S C0CFN=$P(^DD(C0CFJ,C0CFI,0),"^",1) ;PULL FIELD NAME FROM ^DD . . S C0CFN=$P(^DD(C0CFJ,C0CFI,0),"^",1) ;PULL FIELD NAME FROM ^DD
. . ;W "N: ",C0CFN,! . . ;W "N: ",C0CFN,!
. . ;I C0CFN="STR" W C0CFN," ",C0CFJ,!
. . I $D(@C0CFRTN@(C0CFN)) D ; IS THIS A DUPLICATE? . . I $D(@C0CFRTN@(C0CFN)) D ; IS THIS A DUPLICATE?
. . . W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),! . . . W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),!
. . . S @C0CFRTN@("M",@C0CFRTN@(C0CFN),C0CFN)=C0CFJ_"^"_C0CFI . . . S @C0CFRTN@(C0CFN_"_"_C0CFJ)=C0CFJ_"^"_C0CFI
. . E S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI . . E S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI
. S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE . S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE
Q Q
; ;
GET(GRTN,GFILE,GIEN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED GET(GRTN,GFILE,GIEN,GNN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
; BY NAME ; BY NAME
; ;
N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME ;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 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP") D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP")
D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
@ -131,7 +134,13 @@ GET(GRTN,GFILE,GIEN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED
. F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS
. . ;W C0CJ," ",C0CI,! . . ;W C0CJ," ",C0CI,!
. . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
. . S $P(@GRTN@(C0CNAME),"^",3)=C0CTMP(C0CJ,C0CREF,C0CI) ;RETURN VALUE IN P3 . . 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 Q
; ;
INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES