Changeset 300
- Timestamp:
- Dec 6, 2008, 8:50:51 PM (16 years ago)
- Location:
- ccr/trunk/p
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CDIC.m
r299 r300 99 99 Q 100 100 ; 101 FIELDS(C0CFRTN,C0CF) ; RETURNS AN ARRAY OF THE FIELDS IN FILE C0CF,102 ; C0CFRTN IS PASSED BY NAME, C0CF IS PASSED BY VALUE103 ;104 N C0CFI,C0CFJ ;INNER LOOP, OUTER LOOP105 N C0CFN ; FIELD NAME106 S C0CFI=0 S C0CFJ=C0CF107 K @C0CFRTN ; CLEAR THE RETURN ARRAY108 F Q:C0CFJ'[C0CF D ; FOR THE C0CF FILE AND ALL SUBFILES INCLUSIVE109 . ;W "1: "_C0CFJ," ",C0CFI,!110 . F S C0CFI=$O(^DD(C0CFJ,C0CFI)) Q:+C0CFI=0 D ; EVERY FIELD111 . . ;W "2: "_C0CFJ," ",C0CFI,!112 . . S C0CFN=$P(^DD(C0CFJ,C0CFI,0),"^",1) ;PULL FIELD NAME FROM ^DD113 . . ;W "N: ",C0CFN,!114 . . ;I C0CFN="STR" W C0CFN," ",C0CFJ,!115 . . I $D(@C0CFRTN@(C0CFN)) D ; IS THIS A DUPLICATE?116 . . . W "DUPLICATE FOUND! ",C0CFJ," ",C0CFI," ",C0CFN,!,@C0CFRTN@(C0CFN),!117 . . . S @C0CFRTN@(C0CFN_"_"_C0CFJ)=C0CFJ_"^"_C0CFI118 . . E S @C0CFRTN@(C0CFN)=C0CFJ_"^"_C0CFI119 . S C0CFJ=$O(^DD(C0CFJ)) ; NEXT SUBFILE120 Q121 ;122 GET(GRTN,GFILE,GIEN,GNN) ; RETURN THE DICTIONARY RECORD GIEN IN ARRAY GRTN, PASSED123 ; BY NAME124 ;125 N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME126 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)127 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)128 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE129 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP130 D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP")131 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE132 S (C0CI,C0CJ)=""133 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES134 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE135 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS136 . . ;W C0CJ," ",C0CI,!137 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME138 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI) ;139 . . I C0CVALUE["C0CTMP" S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,1) ;1ST LINE OF WP140 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3141 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED142 . S C0CI=""143 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY144 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES145 Q146 ;147 GETALL(GARFLD,GARVAL,GAFILE,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES148 ; GARFLD, PASSED BY NAME, RETURNS FIELD MAP @GARFLD@("FIELDNAME")149 ; .. ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP150 ; .. GARFLD IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE151 ; .. IF GANN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP152 ; GARVAL, PASSED BY NAME, RETURNS VALUES AS @GARVAL@(IEN,"FIELDNAME")=VALUE153 ; .. FOR EVERY RECORD PROCESSED. IT IS NOT INITIALEZED SO IT IS CUMMULATIVE154 ; .. EVEN IF GANN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN GARVAL155 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING GARFLD - THIS SAVES SPACE156 ; GARFILE IS THE FILE NUMBER TO BE PROCESSED. IT IS PASSED BY VALUE157 ; GARCNT IS THE NUMBER OF RECORDS TO PROCESS. IT IS PASSED BY VALUE158 ; .. IF GARCNT IS NULL, ALL RECORDS ARE PROCESSED159 ; GARSTRT IS THE IEN OF THE FIRST RECORD TO PROCESS. IT IS PASSED BY VALUE160 ; .. IF GARSTART IS NULL, PROCESSING STARTS AT THE FIRST RECORD161 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED162 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GARFLD AND GARVAL163 N GATMP,GAI,GAF164 S GAF=^DIC(GAFILE,0,"GL") ;OPEN ROOT TO FILE165 S GAF=$P(GAF,",",1)_")" ; CLOSE THE ROOT166 W $O(@GAF@(0)) ;167 S GAI=0 ;ITERATOR168 ; F S GAI=$O(@GAF@169 Q170 ;171 101 INIT ; INITIALIZE CCR DICTIONARY BASED ON VARIABLE NAMES 172 102 ; … … 192 122 . ;W C0CZX,! 193 123 . K C0CA,C0CN ; CLEAR OUT THE LAST ONE 194 . D GET ("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH124 . D GET^C0CRNF("C0CA",170,C0CZX,"ALL") ; GET VARIABLE HASH 195 125 . ;ZWR C0CA B ; 196 126 . S C0CN=$$ZVALUE("VARIABLE") ;NAME OF THE VARIABLE … … 237 167 ; 238 168 N C0CSI,C0CSJ 239 S C0CSI=$$ZFILE(C0CSN ) ; FILE NUMBER240 S C0CSJ=$$ZFIELD(C0CSN ) ; FIELD NUMBER169 S C0CSI=$$ZFILE(C0CSN,"C0CA") ; FILE NUMBER 170 S C0CSJ=$$ZFIELD(C0CSN,"C0CA") ; FIELD NUMBER 241 171 S C0CFDA(C0CZX,C0CSI,C0CZX_",",C0CSJ)=C0CSV 242 172 Q 243 ZFILE(ZFN ) ; INTERNALEXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED173 ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED 244 174 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN) 245 Q $P(C0CA(ZFN),"^",1) 246 ZFIELD(ZFN) ;INTERNAL EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 175 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA 176 I '$D(ZTAB) S ZTAB="C0CA" 177 Q $P(@ZTAB@(ZFN),"^",1) 178 ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED 247 179 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN) 248 Q $P(C0CA(ZFN),"^",2) 249 ZVALUE(ZFN) ;INTERNAL EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 180 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA 181 I '$D(ZTAB) S ZTAB="C0CA" 182 Q $P(@ZTAB@(ZFN),"^",2) 183 ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED 250 184 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN) 251 Q $P(C0CA(ZFN),"^",3) 185 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA 186 I '$D(ZTAB) S ZTAB="C0CA" 187 Q $P(@ZTAB@(ZFN),"^",3) 252 188 ;
Note:
See TracChangeset
for help on using the changeset viewer.