Changeset 555
- Timestamp:
- Aug 27, 2009, 12:22:58 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CRNF.m
r508 r555 71 71 ; 72 72 GETN(GRTN,GFILE,GREF,GNDX,GNN) ; GET BY NAME ; RETURN A FIELD VALUE MAP 73 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1 74 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL 75 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN 76 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP 77 ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")="" 78 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP 79 ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE 80 ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE 81 ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP 82 ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP 83 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE 84 ; IF GREF IS "" THE FIRST RECORD IS OBTAINED 85 ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE 86 ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN 87 ; GREF IS THE VALUE FOR THE INDEX 88 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED 89 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN 90 ; 91 ; 92 N GIEN,GF 93 S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE 94 I ('$D(GNDX))!($G(GNDX)="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN 95 E D ; WE ARE USING AN INDEX 96 . ;N ZG 97 . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX 98 . I ZG'="" D ; 99 . . I $QS(ZG,3)=GREF D ; IS GREF IN INDEX? 100 . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN 101 . . E S GIEN="" ; NOT FOUND IN INDEX 102 . E S GIEN="" ; 103 ;W "IEN: ",GIEN,! 104 ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME 105 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED) 106 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED) 107 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE 108 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP 109 K C0CTMP 110 D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP") 111 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE 112 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE 113 S (C0CI,C0CJ)="" 114 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES 115 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE 116 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS 117 . . ;W C0CJ," ",C0CI,! 118 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME 119 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ; 120 . . I C0CVALUE["C0CTMP" D ; WP FIELD 121 . . . N ZT,ZWP S ZWP=0 ;ITERATOR 122 . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE 123 . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE 124 . . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ; 125 . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP 126 . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT " 127 . . . . S C0CVALUE=C0CVALUE_ZT ; 128 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3 129 . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I")) 130 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED 131 . S C0CI="" 132 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY 133 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES 134 Q 135 ; 136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP 73 137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1 74 138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL … … 134 198 Q 135 199 ; 136 GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP137 ; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1138 ; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL139 ; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN140 ; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP141 ; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""142 ; ... ANY FIELD USED BY ANY RECORD PROCESSED IS IN THE FIELD MAP143 ; .. VALUE MAP @GRTN@("V","IEN","FIELDNAME")=VALUE144 ; .. GRTN IS NOT INITIALIZED, SO MULTIPLE CALLS ARE CUMULATIVE145 ; .. IF GNN="ALL" THEN ALL FIELDS FOR THE FILE ARE IN THE FIELD MAP146 ; .. EVEN IF GNN="ALL" ONLY POPULATED FIELDS ARE RETURNED IN THE VALUE MAP147 ; .. NUL FIELDS CAN BE DETERMINED BY CHECKING FIELD MAP - THIS SAVES SPACE148 ; IF GREF IS "" THE FIRST RECORD IS OBTAINED149 ; IF GNDX IS NULL, GREF IS AN IEN FOR THE FILE150 ; GNDX IS THE INDEX TO USE TO OBTAIN THE IEN151 ; GREF IS THE VALUE FOR THE INDEX152 ; GANN= NOT NULL - IF GANN IS "ALL" THEN EVEN NULL FIELDS WILL BE RETURNED153 ; OTHERWISE, ONLY POPULATED FIELDS ARE RETURNED IN GRTN154 ;155 ;156 N GIEN,GF157 S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE158 I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN159 E D ; WE ARE USING AN INDEX160 . ;N ZG161 . S ZG=$Q(@GF@(GNDX,GREF)) ;ACCESS INDEX162 . I ZG'="" D ;163 . . I $QS(ZG,3)=GREF D ; IS GREF IN INDEX?164 . . . S GIEN=$QS(ZG,4) ; PULL OUT THE IEN165 . . E S GIEN="" ; NOT FOUND IN INDEX166 . E S GIEN="" ;167 ;W "IEN: ",GIEN,!168 ;N C0CTMP,C0CI,C0CJ,C0CREF,C0CNAME169 I $D(GNN) I GNN="ALL" S C0CNN=0 ; NOT NON-NULL (ALL FIELDS TO BE RETURNED)170 E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)171 S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE172 D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP173 K C0CTMP174 D GETS^DIQ(GFILE,C0CREF,"**","IE","C0CTMP")175 D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE176 S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE177 S (C0CI,C0CJ)=""178 F S C0CJ=$O(C0CTMP(C0CJ)) Q:C0CJ="" D ; FOR ALL SUBFILES179 . S C0CREF=$O(C0CTMP(C0CJ,"")) ; RECORD REFERENCE180 . F S C0CI=$O(C0CTMP(C0CJ,C0CREF,C0CI)) Q:C0CI="" D ; ARRAY OF FIELDS181 . . ;W C0CJ," ",C0CI,!182 . . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME183 . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,"E") ;184 . . I C0CVALUE["C0CTMP" D ; WP FIELD185 . . . N ZT,ZWP S ZWP=0 ;ITERATOR186 . . . S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) ; INIT TO FIRST LINE187 . . . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ; INIT TO FIRST LINE188 . . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ;189 . . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP190 . . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "191 . . . . S C0CVALUE=C0CVALUE_ZT ;192 . . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3193 . . S $P(@GRTN@(C0CNAME,"I"),"^",3)=$G(C0CTMP(C0CJ,C0CREF,C0CI,"I"))194 I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED195 . S C0CI=""196 . F S C0CI=$O(@GRTN@(C0CI)) Q:C0CI="" D ; GO THROUGH THE WHOLE ARRAY197 . . I $P(@GRTN@(C0CI),"^",3)="" K @GRTN@(C0CI) ; KILL THE NULL ENTRIES198 Q199 ;200 200 GETN2(GARTN,GAFILE,GAIDX,GACNT,GASTRT,GANN) ; RETURN FIELD MAP AND VALUES 201 201 ; GARTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
Note:
See TracChangeset
for help on using the changeset viewer.