source: cprs/branches/foia-cprs/CPRS-Chart/uDocTree.pas@ 459

Last change on this file since 459 was 459, checked in by Kevin Toppenberg, 16 years ago

Adding foia-cprs branch

File size: 26.7 KB
Line 
1unit uDocTree;
2
3interface
4
5uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, uConst, ORCtrls, ComCtrls, uTIU;
6
7
8type
9 PDocTreeObject = ^TDocTreeObject;
10 TDocTreeObject = record
11 DocID : string ; //Document IEN
12 DocDate : string; //Formatted date of document
13 DocTitle : string; //Document Title Text
14 NodeText : string; //Title, Location, Author (depends on tab)
15 ImageCount : integer; //Number of images
16 VisitDate : string; //ADM/VIS: date;FMDate
17 DocFMDate : string; //FM date of document
18 DocHasChildren : string; //Has children (+,>,<)
19 DocParent : string; //Parent document, or context
20 Author : string; //DUZ;Author name
21 PkgRef : string; //IEN;Package (consults only, for now)
22 Location : string; //Location name
23 Status : string; //Status
24 Subject : string; //Subject
25 OrderID : string; //Order file IEN (consults only, for now)
26 OrderByTitle : boolean; //Within ID Parents, order children by title, not date
27 end;
28
29// Procedures for document treeviews/listviews
30procedure CreateListItemsForDocumentTree(Dest, Source: TStrings; Context: integer; GroupBy: string;
31 Ascending: boolean; TabIndex: integer);
32procedure BuildDocumentTree(DocList: TStrings; const Parent: string; Tree: TORTreeView; Node: TORTreeNode;
33 TIUContext: TTIUContext; TabIndex: integer);
34procedure SetTreeNodeImagesAndFormatting(Node: TORTreeNode; CurrentContext: TTIUContext; TabIndex: integer);
35procedure ResetDocTreeObjectStrings(AnObject: PDocTreeObject);
36procedure KillDocTreeObjects(TreeView: TORTreeView);
37procedure KillDocTreeNode(ANode: TTreeNode);
38function ContextMatch(ANode: TORTreeNode; AParentID: string; AContext: TTIUContext): Boolean;
39function TextFound(ANode: TORTreeNode; CurrentContext: TTIUContext): Boolean;
40procedure RemoveParentsWithNoChildren(Tree: TTreeView; Context: TTIUContext);
41procedure TraverseTree(ATree: TTreeView; AListView: TListView; ANode: TTreeNode; MyNodeID: string;
42 AContext: TTIUContext);
43procedure AddListViewItem(ANode: TTreeNode; AListView: TListView);
44function MakeNoteTreeObject(x: string): PDocTreeObject;
45function MakeDCSummTreeObject(x: string): PDocTreeObject;
46function MakeConsultsNoteTreeObject(x: string): PDocTreeObject;
47
48implementation
49
50uses
51 rConsults, uDCSumm, uConsults;
52
53{==============================================================
54RPC [TIU DOCUMENTS BY CONTEXT] returns
55the following string '^' pieces:
56===============================================================
57 1 - Document IEN
58 2 - Document Title
59 3 - FM date of document
60 4 - Patient Name
61 5 - DUZ;Author name
62 6 - Location
63 7 - Status
64 8 - ADM/VIS: date;FMDate
65 9 - Discharge Date;FMDate
66 10 - Package variable pointer
67 11 - Number of images
68 12 - Subject
69 13 - Has children
70 14 - Parent document
71 15 - Order children of ID Note by title rather than date
72===============================================================}
73
74procedure CreateListItemsForDocumentTree(Dest, Source: TStrings; Context: integer; GroupBy: string;
75 Ascending: Boolean; TabIndex: integer);
76const
77 NO_MATCHES = '^No Matching Documents Found^^^^^^^^^^^%^0';
78var
79 i: Integer;
80 x, x1, x2, x3, MyParent, MyTitle, MyLocation, MySubject: string;
81 AList, SrcList: TStringList;
82begin
83 AList := TStringList.Create;
84 SrcList := TStringList.Create;
85 try
86 SrcList.Assign(Source);
87 with SrcList do
88 begin
89 if (Count = 0) then
90 begin
91 Dest.Insert(0, IntToStr(Context) + NO_MATCHES);
92 Exit;
93 end;
94 for i := 0 to Count - 1 do
95 begin
96 x := Strings[i];
97 MyParent := Piece(x, U, 14);
98 MyTitle := Piece(x, U, 2);
99 if Length(Trim(MyTitle)) = 0 then
100 begin
101 MyTitle := '** No Title **';
102 SetPiece(x, U, 2, MyTitle);
103 end;
104 MyLocation := Piece(x, U, 6);
105 if Length(Trim(MyLocation)) = 0 then
106 begin
107 MyLocation := '** No Location **';
108 SetPiece(x, U, 6, MyLocation);
109 end;
110 MySubject := Piece(x, U, 12);
111(* case TIUContext.SearchField[1] of
112 'T': if ((TextFound(MyTitle)) then continue;
113 'S': if (not TextFound(MySubject)) then continue;
114 'B': if not ((TextFound(MyTitle)) or (TextFound(MySubject))) then continue;
115 end;*)
116 if GroupBy <> '' then case GroupBy[1] of
117 'D': begin
118 x1 := Piece(Piece(x, U, 8), ';', 1); // Visit date
119 x2 := Piece(Piece(Piece(x, U, 8), ';', 2), '.', 1); // Visit date (FM) no time - v15.4
120 if x2 = '' then
121 begin
122 x2 := 'No Visit';
123 x1 := Piece(x1, ':', 1) + ': No Visit';
124 end;
125 (*else
126 x1 := Piece(x1, ':', 1) + ': ' + FormatFMDateTimeStr('mmm dd,yy@hh:nn',x2)*) //removed v15.4
127 if MyParent = IntToStr(Context) then
128 SetPiece(x, U, 14, MyParent + x2 + Copy(x1, 1, 3)); // '2980324Adm'
129 x3 := x2 + Copy(x1, 1, 3) + U + MixedCase(x1) + U + IntToStr(Context) + MixedCase(Copy(x1, 1, 3));
130 if (Copy(MyTitle, 1, 8) <> 'Addendum') and (AList.IndexOf(x3) = -1) then
131 AList.Add(x3); // '2980324Adm^Mar 24,98'
132 end;
133 'L': begin
134 if MyParent = IntToStr(Context) then // keep ID notes together, or
135 SetPiece(x, U, 14, MyParent + MyLocation);
136(* if (Copy(MyTitle, 1, 8) <> 'Addendum') then // split ID Notes by location?
137 SetPiece(x, U, 14, IntToStr(Context) + MyLocation);*)
138 x3 := MyLocation + U + MixedCase(MyLocation) + U + IntToStr(Context);
139 if (Copy(MyTitle, 1, 8) <> 'Addendum') and (AList.IndexOf(x3) = -1) then
140 AList.Add(x3);
141 end;
142 'T': begin
143 if MyParent = IntToStr(Context) then // keep ID notes together, or
144 SetPiece(x, U, 14, MyParent + MyTitle);
145(* if (Copy(MyTitle, 1, 8) <> 'Addendum') then // split ID Notes by title?
146 SetPiece(x, U, 14, IntToStr(Context) + MyTitle);*)
147 x3 := MyTitle + U + MixedCase(MyTitle) + U + IntToStr(Context);
148 if (Copy(MyTitle, 1, 8) <> 'Addendum') and (AList.IndexOf(x3) = -1) then
149 AList.Add(x3);
150 end;
151 'A': begin
152 x1 := Piece(Piece(x, U, 5), ';', 3);
153 if x1 = '' then x1 := '** No Author **';
154 if MyParent = IntToStr(Context) then // keep ID notes together, or
155 SetPiece(x, U, 14, MyParent + x1);
156 //if (Copy(MyTitle, 1, 8) <> 'Addendum') then // split ID Notes by author?
157 // SetPiece(x, U, 14, IntToStr(Context) + x1);
158 x3 := x1 + U + MixedCase(x1) + U + IntToStr(Context);
159 if (Copy(MyTitle, 1, 8) <> 'Addendum') and(AList.IndexOf(x3) = -1) then
160 AList.Add(x3);
161 end;
162(* 'A': begin // Makes note appear both places in tree,
163 x1 := Piece(Piece(x, U, 5), ';', 3); // but also appears TWICE in lstNotes.
164 if x1 = '' then x1 := '** No Author **'; // IS THIS REALLY A PROBLEM??
165 if MyParent = IntToStr(Context) then // Impact on EditingIndex?
166 SetPiece(x, U, 14, MyParent + x1); // Careful when deleting note being edited!!!
167 Dest.Add(x); // Need to find and delete ALL occurrences!
168 SetPiece(x, U, 14, IntToStr(Context) + x1);
169 x3 := x1 + U + MixedCase(x1) + U + IntToStr(Context);
170 if (AList.IndexOf(x3) = -1) then AList.Add(x3);
171 end;*)
172 end;
173 Dest.Add(x);
174 end; {for}
175 SortByPiece(TStringList(Dest), U, 3);
176 if not Ascending then InvertStringList(TStringList(Dest));
177 if GroupBy <> '' then if GroupBy[1] ='D' then
178 begin
179 AList.Add('Adm^Inpatient Notes' + U + IntToStr(Context));
180 AList.Add('Vis^Outpatient Notes' + U + IntToStr(Context));
181 end;
182 Dest.Insert(0, IntToStr(Context) + '^' + NC_TV_TEXT[TabIndex, Context] + '^^^^^^^^^^^%^0');
183 Alist.Sort;
184 InvertStringList(AList);
185 if GroupBy <> '' then if GroupBy[1] ='D' then
186 if (not Ascending) then InvertStringList(AList);
187 for i := 0 to AList.Count-1 do
188 Dest.Insert(0, IntToStr(Context) + Piece(AList[i], U, 1) + '^' + Piece(AList[i], U, 2) + '^^^^^^^^^^^%^' + Piece(AList[i], U, 3));
189 end;
190 finally
191 AList.Free;
192 SrcList.Free;
193 end;
194end;
195
196procedure BuildDocumentTree(DocList: TStrings; const Parent: string; Tree: TORTreeView; Node: TORTreeNode;
197 TIUContext: TTIUContext; TabIndex: integer);
198var
199 MyID, MyParent, Name: string;
200 i: Integer;
201 ChildNode, tmpNode: TORTreeNode;
202 DocHasChildren: Boolean;
203 AnObject: PDocTreeObject;
204begin
205 with DocList do for i := 0 to Count - 1 do
206 begin
207 tmpNode := nil;
208 MyParent := Piece(Strings[i], U, 14);
209 if (MyParent = Parent) then
210 begin
211 MyID := Piece(Strings[i], U, 1);
212 if Piece(Strings[i], U, 13) <> '%' then
213 case TabIndex of
214 CT_NOTES: Name := MakeNoteDisplayText(Strings[i]);
215 CT_CONSULTS: Name := MakeConsultNoteDisplayText(Strings[i]);
216 CT_DCSUMM: Name := MakeDCSummDisplayText(Strings[i]);
217 end
218 else
219 Name := Piece(Strings[i], U, 2);
220 DocHasChildren := (Piece(Strings[i], U, 13) <> '');
221 if Node <> nil then if Node.HasChildren then
222 tmpNode := Tree.FindPieceNode(MyID, 1, U, Node);
223 if (tmpNode <> nil) and tmpNode.HasAsParent(Node) then
224 Continue
225 else
226 begin
227 case TabIndex of
228 CT_NOTES: AnObject := MakeNoteTreeObject(Strings[i]);
229 CT_CONSULTS: AnObject := MakeConsultsNoteTreeObject(Strings[i]);
230 CT_DCSUMM: AnObject := MakeDCSummTreeObject(Strings[i]);
231 else
232 AnObject := nil;
233 end;
234 ChildNode := TORTreeNode(Tree.Items.AddChildObject(TORTreeNode(Node), Name, AnObject));
235 ChildNode.StringData := Strings[i];
236 SetTreeNodeImagesAndFormatting(ChildNode, TIUContext, TabIndex);
237 if DocHasChildren then BuildDocumentTree(DocList, MyID, Tree, ChildNode, TIUContext, TabIndex);
238 end;
239 end;
240 end;
241end;
242
243procedure SetTreeNodeImagesAndFormatting(Node: TORTreeNode; CurrentContext: TTIUContext; TabIndex: integer);
244var
245 tmpAuthor: int64;
246 i: integer;
247
248 procedure MakeBold(ANode: TORTreeNode);
249 begin
250 with ANode do
251 begin
252 Bold := True;
253 if Parent <> nil then
254 begin
255 Parent.Expand(False);
256 if Parent.Parent <> nil then
257 begin
258 Parent.Parent.Expand(False);
259 if Parent.Parent.Parent <> nil then
260 Parent.Parent.Parent.Expand(False);
261 end;
262 end;
263 end;
264 end;
265
266begin
267 with Node, PDocTreeObject(Node.Data)^ do
268 begin
269 i := Pos('*', DocTitle);
270 if i > 0 then i := i + 1 else i := 0;
271 if (Copy(DocTitle, i + 1, 8) = 'Addendum') then
272 ImageIndex := IMG_ADDENDUM
273 else if (DocHasChildren = '') then
274 ImageIndex := IMG_SINGLE
275 else if Pos('+>', DocHasChildren) > 0 then
276 ImageIndex := IMG_ID_CHILD_ADD
277 else if (DocHasChildren = '>') then
278 ImageIndex := IMG_ID_CHILD
279 else if Pos('+<', DocHasChildren) > 0 then
280 ImageIndex := IMG_IDPAR_ADDENDA_SHUT
281 else if DocParent = '0' then
282 begin
283 ImageIndex := IMG_TOP_LEVEL;
284 SelectedIndex := IMG_TOP_LEVEL;
285 StateIndex := -1;
286 with CurrentContext, Node do
287 begin
288 if Node.HasChildren and (GroupBy <> '') then case GroupBy[1] of
289 'T': Text := NC_TV_TEXT[TabIndex, StrToInt(DocID)] + ' by title';
290 'D': Text := NC_TV_TEXT[TabIndex, StrToInt(DocID)] + ' by visit date';
291 'L': Text := NC_TV_TEXT[TabIndex, StrToInt(DocID)] + ' by location';
292 'A': Text := NC_TV_TEXT[TabIndex, StrToInt(DocID)] + ' by author';
293 end;
294 if TabIndex <> CT_CONSULTS then
295 begin
296 if (DocID = '2') or (DocID ='3') then
297 begin
298 if StrToIntDef(Status, 0) in [NC_UNSIGNED, NC_UNCOSIGNED] then
299 begin
300 if Author = 0 then tmpAuthor := User.DUZ else tmpAuthor := Author;
301 Text := Text + ' for ' + ExternalName(tmpAuthor, 200);
302 end
303 else
304 Text := Text + ' for ' + User.Name;
305 end;
306 if DocID = '4' then
307 Text := Text + ' for ' + ExternalName(Author, 200);
308 end;
309 end;
310 end
311 else
312 case DocHasChildren[1] of
313 '<': ImageIndex := IMG_IDNOTE_SHUT;
314 '+': ImageIndex := IMG_PARENT;
315 '%': begin
316 StateIndex := -1;
317 ImageIndex := IMG_GROUP_SHUT;
318 SelectedIndex := IMG_GROUP_OPEN;
319 end;
320 end;
321 SelectedIndex := ImageIndex;
322 if (ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
323 StateIndex := IMG_NONE
324 else
325 begin
326 if ImageCount > 0 then
327 StateIndex := IMG_1_IMAGE
328 else if ImageCount = 0 then
329 StateIndex := IMG_NO_IMAGES
330 else if ImageCount = -1 then
331 StateIndex := IMG_IMAGES_HIDDEN;
332 end;
333 if (Parent <> nil) and
334 (Parent.ImageIndex in [IMG_PARENT, IMG_IDNOTE_SHUT, IMG_IDNOTE_OPEN, IMG_IDPAR_ADDENDA_SHUT, IMG_IDPAR_ADDENDA_OPEN]) and
335 (StateIndex in [IMG_1_IMAGE, IMG_IMAGES_HIDDEN]) then
336 begin
337 Parent.StateIndex := IMG_CHILD_HAS_IMAGES;
338 end;
339(* case ImageCount of
340 0: StateIndex := IMG_NO_IMAGES;
341 1: StateIndex := IMG_1_IMAGE;
342 2: StateIndex := IMG_2_IMAGES;
343 else
344 StateIndex := IMG_MANY_IMAGES;
345 end;*)
346 if Node.Parent <> nil then
347 if not CurrentContext.Filtered then
348 //don't bother to BOLD every entry
349 else
350 begin
351 if (*ContextMatch(Node) then
352 if (CurrentContext.KeyWord = '') or *)TextFound(Node, CurrentContext) then MakeBold(Node);
353 end;
354 end;
355end;
356
357procedure TraverseTree(ATree: TTreeView; AListView: TListView; ANode: TTreeNode; MyNodeID: string; AContext: TTIUContext);
358var
359 IncludeIt: Boolean;
360 x: string;
361begin
362 if ANode = nil then Exit;
363 IncludeIt := False;
364 if (ContextMatch(TORTreeNode(ANode), MyNodeID, AContext) and TextFound(TORTreeNode(ANode), AContext)) then
365 with PDocTreeObject(ANode.Data)^ do
366 begin
367 if (AContext.GroupBy <> '') and
368 (ATree.Selected.ImageIndex in [IMG_GROUP_OPEN, IMG_GROUP_SHUT]) then
369 begin
370 case AContext.GroupBy[1] of
371 'T': if (UpperCase(DocTitle) = UpperCase(PDocTreeObject(ATree.Selected.Data)^.DocTitle)) or
372 (UpperCase(DocTitle) = UpperCase('Addendum to ' + PDocTreeObject(ATree.Selected.Data)^.DocTitle)) or
373 (AContext.Filtered and TextFound(TORTreeNode(ANode), AContext)) then
374 IncludeIt := True;
375 'D': begin
376 x := PDocTreeObject(ATree.Selected.Data)^.DocID;
377 if (Copy(x, 2, 3) = 'Vis') or (Copy(x, 2, 3) = 'Adm') then
378 begin
379 if Copy(VisitDate, 1, 3) = Copy(x, 2, 3) then
380 IncludeIt := True;
381 end
382 else if Piece(Piece(VisitDate, ';', 2), '.', 1) = Copy(x, 2, Length(x) - 4) then
383 IncludeIt := True;
384 end;
385 'L': if MyNodeID + Location = PDocTreeObject(ATree.Selected.Data)^.DocID then
386 IncludeIt := True;
387 'A': if MyNodeID + Piece(Author, ';', 2) = PDocTreeObject(ATree.Selected.Data)^.DocID then
388 IncludeIt := True;
389 end;
390 end
391 else
392 IncludeIt := True;
393 end;
394 if IncludeIt then AddListViewItem(ANode, AListView);
395 if ANode.HasChildren then TraverseTree(ATree, AListView, ANode.GetFirstChild, MyNodeID, AContext);
396 TraverseTree(ATree, AListView, ANode.GetNextSibling, MyNodeID, AContext);
397end;
398
399function ContextMatch(ANode: TORTreeNode; AParentID: string; AContext: TTIUContext): Boolean;
400var
401 Status: string;
402 Author: int64;
403begin
404 Result := True;
405 if not Assigned(ANode.Data) then Exit;
406 Status := PDocTreeObject(ANode.Data)^.Status;
407
408 if (AContext.Status <> AParentID[1]) or (AContext.Author = 0) then
409 Author := User.DUZ
410 else
411 Author := AContext.Author;
412
413 if Length(Trim(Status)) = 0 then exit;
414 (*if PDocTreeObject(ANode.Data)^.DocHasChildren = '%' then Result := False else Result := True;
415 Result := False;*)
416 case AParentID[1] of
417 '1': Result := (Status = 'completed') or
418 (Status = 'deleted') or
419 (Status = 'amended') or
420 (Status = 'uncosigned') or
421 (Status = 'retracted');
422 '2': Result := ((Status = 'unsigned') or
423 (Status = 'unreleased') or
424 (Status = 'deleted') or
425 (Status = 'retracted') or
426 (Status = 'unverified')) and
427 (Piece(PDocTreeObject(ANode.Data)^.Author, ';', 1) = IntToStr(Author));
428 '3': Result := ((Status = 'uncosigned') or
429 (Status = 'unsigned') or
430 (Status = 'unreleased') or
431 (Status = 'deleted') or
432 (Status = 'retracted') or
433 (Status = 'unverified')) ;//and
434 { TODO -oRich V. -cSort/Search : Uncosigned notes - need to check cosigner, not author, but don't have it }
435 //(Piece(PDocTreeObject(ANode.Data)^.Author, ';', 1) = IntToStr(Author));
436 '4': Result := (Piece(PDocTreeObject(ANode.Data)^.Author, ';', 1) = IntToStr(Author));
437 '5': if PDocTreeObject(ANode.Data)^.DocHasChildren = '%' then Result := False
438 else Result := (StrToFloat(PDocTreeObject(ANode.Data)^.DocFMDate) >= AContext.FMBeginDate) and
439 (Trunc(StrToFloat(PDocTreeObject(ANode.Data)^.DocFMDate)) <= AContext.FMEndDate);
440 'N': Result := True; // NEW NOTE
441 'E': Result := True; // EDITING NOTE
442 'A': Result := True; // NEW ADDENDUM or processing alert
443 end;
444end;
445
446function TextFound(ANode: TORTreeNode; CurrentContext: TTIUContext): Boolean;
447var
448 MySearch: string;
449begin
450 Result := False;
451 if not Assigned(ANode.Data) then Exit;
452 if CurrentContext.SearchField <> '' then
453 case CurrentContext.SearchField[1] of
454 'T': MySearch := PDocTreeObject(ANode.Data)^.DocTitle;
455 'S': MySearch := PDocTreeObject(ANode.Data)^.Subject;
456 'B': MySearch := PDocTreeObject(ANode.Data)^.DocTitle + ' ' + PDocTreeObject(ANode.Data)^.Subject;
457 end;
458 Result := (not CurrentContext.Filtered) or
459 ((CurrentContext.Filtered) and (Pos(UpperCase(CurrentContext.KeyWord), UpperCase(MySearch)) > 0));
460end;
461
462procedure ResetDocTreeObjectStrings(AnObject: PDocTreeObject);
463begin
464 with AnObject^ do
465 begin
466 DocID := '';
467 DocDate := '';
468 DocTitle := '';
469 NodeText := '';
470 VisitDate := '';
471 DocFMDate := '';
472 DocHasChildren := '';
473 DocParent := '';
474 Author := '';
475 PkgRef := '';
476 Location := '';
477 Status := '';
478 Subject := '';
479 OrderID := '';
480 end;
481end;
482
483procedure KillDocTreeObjects(TreeView: TORTreeView);
484var
485 i: integer;
486begin
487 with TreeView do
488 for i := 0 to Items.Count-1 do
489 begin
490 if(Assigned(Items[i].Data)) then
491 begin
492 ResetDocTreeObjectStrings(PDocTreeObject(Items[i].Data));
493 Dispose(PDocTreeObject(Items[i].Data));
494 Items[i].Data := nil;
495 end;
496 end;
497end;
498
499procedure KillDocTreeNode(ANode: TTreeNode);
500begin
501 if(Assigned(ANode.Data)) then
502 begin
503 ResetDocTreeObjectStrings(PDocTreeObject(ANode.Data));
504 Dispose(PDocTreeObject(ANode.Data));
505 ANode.Data := nil;
506 end;
507 ANode.Owner.Delete(ANode);
508end;
509
510procedure RemoveParentsWithNoChildren(Tree: TTreeView; Context: TTIUContext);
511var
512 n: integer;
513begin
514 with Tree do
515 for n := Items.Count - 1 downto 0 do
516 if ((Items[n].ImageIndex = IMG_GROUP_SHUT)) then
517 begin
518 if (not Items[n].HasChildren) then
519 KillDocTreeNode(Items[n])
520 else if Context.Filtered then // if any hits, would be IMG_GROUP_OPEN
521 KillDocTreeNode(Items[n]);
522 end;
523end;
524
525procedure AddListViewItem(ANode: TTreeNode; AListView: TListView);
526var
527 ListItem: TListItem;
528begin
529 if not Assigned(ANode.Data) then Exit;
530 with Anode, PDocTreeObject(ANode.Data)^, AListView do
531 begin
532(* if (FCurrentContext.Status = '1') and
533 (Copy(DocTitle, 1 , 8) = 'Addendum') then Exit;*)
534 if ANode.ImageIndex in [IMG_TOP_LEVEL, IMG_GROUP_OPEN, IMG_GROUP_SHUT] then Exit;
535 ListItem := Items.Add;
536 ListItem.Caption := DocDate; // date
537 ListItem.StateIndex := ANode.StateIndex;
538 ListItem.ImageIndex := ANode.ImageIndex;
539 with ListItem.SubItems do
540 begin
541 Add(DocTitle); // title
542 Add(Subject); // subject
543 Add(MixedCase(Piece(Author, ';', 2))); // author
544 Add(Location); // location
545 Add(DocFMDate); // reference date (FM)
546 Add(DocID); // TIUDA
547 end;
548 end;
549end;
550
551function MakeNoteTreeObject(x: string): PDocTreeObject;
552var
553 AnObject: PDocTreeObject;
554begin
555 New(AnObject);
556 with AnObject^ do
557 begin
558 DocID := Piece(x, U, 1);
559 DocDate := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3)));
560 DocTitle := Piece(x, U, 2);
561 Location := Piece(x, U, 6);
562 NodeText := MakeNoteDisplayText(x);
563 ImageCount := StrToIntDef(Piece(x, U, 11), 0);
564 VisitDate := Piece(x, U, 8);
565 DocFMDate := Piece(x, U, 3);
566 DocHasChildren := Piece(x, U, 13);
567 if Copy(DocHasChildren, 1, 1) = '*' then
568 DocHasChildren := Copy(DocHasChildren, 2, 5);
569 DocParent := Piece(x, U, 14);
570 Author := Piece(Piece(x, U, 5), ';', 1) + ';' + Piece(Piece(x, U, 5), ';', 3);
571 PkgRef := Piece(x, U, 10);
572 Status := Piece(x, U, 7);
573 Subject := Piece(x, U, 12);
574 OrderByTitle := Piece(x, U, 15) = '1';
575 end;
576 Result := AnObject;
577end;
578
579function MakeDCSummTreeObject(x: string): PDocTreeObject;
580var
581 AnObject: PDocTreeObject;
582begin
583 New(AnObject);
584 if Copy(Piece(x, U, 9), 1, 4) = ' ' then SetPiece(x, U, 9, 'Dis: ');
585 with AnObject^ do
586 begin
587 DocID := Piece(x, U, 1);
588 DocDate := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3)));
589 DocTitle := Piece(x, U, 2);
590 Location := Piece(x, U, 6);
591 NodeText := MakeDCSummDisplayText(x);
592 DocFMDate := Piece(x, U, 3);
593 ImageCount := StrToIntDef(Piece(x, U, 11), 0);
594 DocHasChildren := Piece(x, U, 13);
595 if Copy(DocHasChildren, 1, 1) = '*' then
596 DocHasChildren := Copy(DocHasChildren, 2, 5);
597 DocParent := Piece(x, U, 14);
598 Author := Piece(Piece(x, U, 5), ';', 1) + ';' + Piece(Piece(x, U, 5), ';', 3);
599 PkgRef := Piece(x, U, 10);
600 Status := Piece(x, U, 7);
601 Subject := Piece(x, U, 12);
602 VisitDate := Piece(x, U, 8);
603 OrderByTitle := Piece(x, U, 15) = '1';
604 end;
605 Result := AnObject;
606end;
607
608function MakeConsultsNoteTreeObject(x: string): PDocTreeObject;
609var
610 AnObject: PDocTreeObject;
611begin
612 New(AnObject);
613 with AnObject^ do
614 begin
615 DocID := Piece(x, U, 1);
616 DocDate := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3)));
617 DocTitle := Piece(x, U, 2);
618 Location := Piece(x, U, 6);
619 NodeText := MakeConsultNoteDisplayText(x);
620 DocFMDate := Piece(x, U, 3);
621 Status := Piece(x, U, 7);
622 Author := Piece(Piece(x, U, 5), ';', 1) + ';' + Piece(Piece(x, U, 5), ';', 3);
623 PkgRef := Piece(x, U, 10);
624 if Piece(PkgRef, ';', 2) = PKG_CONSULTS then
625 OrderID := GetConsultOrderIEN(StrToIntDef(Piece(PkgRef, ';', 1), 0));
626 ImageCount := StrToIntDef(Piece(x, U, 11), 0);
627 VisitDate := Piece(x, U, 8);
628 DocHasChildren := Piece(x, U, 13);
629 if Copy(DocHasChildren, 1, 1) = '*' then
630 DocHasChildren := Copy(DocHasChildren, 2, 5);
631 DocParent := Piece(x, U, 14);
632 OrderByTitle := Piece(x, U, 15) = '1';
633 end;
634 Result := AnObject;
635end;
636
637
638end.
Note: See TracBrowser for help on using the repository browser.