| 1 | unit uTIU;
 | 
|---|
| 2 | 
 | 
|---|
| 3 | interface
 | 
|---|
| 4 | 
 | 
|---|
| 5 | uses SysUtils, Classes, ORNet, ORFn, rCore, uCore, uConst, ORCtrls, ComCtrls, Controls;
 | 
|---|
| 6 | 
 | 
|---|
| 7 | type
 | 
|---|
| 8 | 
 | 
|---|
| 9 |   TEditNoteRec = record
 | 
|---|
| 10 |     DocType: Integer;
 | 
|---|
| 11 |     IsNewNote: boolean;
 | 
|---|
| 12 |     Title: Integer;
 | 
|---|
| 13 |     TitleName: string;
 | 
|---|
| 14 |     DateTime: TFMDateTime;
 | 
|---|
| 15 |     Author: Int64;
 | 
|---|
| 16 |     AuthorName: string;
 | 
|---|
| 17 |     Cosigner: Int64;
 | 
|---|
| 18 |     CosignerName: string;
 | 
|---|
| 19 |     Subject: string;
 | 
|---|
| 20 |     Location: Integer;
 | 
|---|
| 21 |     LocationName: string;
 | 
|---|
| 22 |     VisitDate: TFMDateTime;
 | 
|---|
| 23 |     PkgRef: string;      // 'IEN;GMR(123,' or 'IEN;SRF('
 | 
|---|
| 24 |     PkgIEN: integer;     // file IEN
 | 
|---|
| 25 |     PkgPtr: string;      // 'GMR(123,' or 'SRF(' 
 | 
|---|
| 26 |     NeedCPT: Boolean;
 | 
|---|
| 27 |     Addend: Integer;
 | 
|---|
| 28 |     LastCosigner: Int64;
 | 
|---|
| 29 |     LastCosignerName: string;
 | 
|---|
| 30 |     IDParent: integer;
 | 
|---|
| 31 |     ClinProcSummCode: integer;
 | 
|---|
| 32 |     ClinProcDateTime: TFMDateTime;
 | 
|---|
| 33 |     Lines: TStrings;
 | 
|---|
| 34 |     PRF_IEN: integer;
 | 
|---|
| 35 |     ActionIEN: string;
 | 
|---|
| 36 |   end;
 | 
|---|
| 37 | 
 | 
|---|
| 38 |   TNoteRec = TEditNoteRec;
 | 
|---|
| 39 | 
 | 
|---|
| 40 |   TActionRec = record
 | 
|---|
| 41 |     Success: Boolean;
 | 
|---|
| 42 |     Reason: string;
 | 
|---|
| 43 |   end;
 | 
|---|
| 44 | 
 | 
|---|
| 45 |   TCreatedDoc = record
 | 
|---|
| 46 |     IEN: Integer;
 | 
|---|
| 47 |     ErrorText: string;
 | 
|---|
| 48 |   end;
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   TTIUContext = record
 | 
|---|
| 51 |     Changed: Boolean;
 | 
|---|
| 52 |     BeginDate: string;
 | 
|---|
| 53 |     EndDate: string;
 | 
|---|
| 54 |     FMBeginDate: TFMDateTime;
 | 
|---|
| 55 |     FMEndDate: TFMDateTime;
 | 
|---|
| 56 |     Status: string;
 | 
|---|
| 57 |     Author: int64;
 | 
|---|
| 58 |     MaxDocs: integer;
 | 
|---|
| 59 |     ShowSubject: Boolean;
 | 
|---|
| 60 |     SortBy: string;
 | 
|---|
| 61 |     ListAscending: Boolean;
 | 
|---|
| 62 |     GroupBy: string;
 | 
|---|
| 63 |     TreeAscending: Boolean;
 | 
|---|
| 64 |     SearchField: string;
 | 
|---|
| 65 |     KeyWord: string;
 | 
|---|
| 66 |     Filtered: Boolean;
 | 
|---|
| 67 |     SearchString: String;  // Text Search CQ: HDS00002856
 | 
|---|
| 68 |   end ;
 | 
|---|
| 69 | 
 | 
|---|
| 70 |   TNoteTitles = class
 | 
|---|
| 71 |     DfltTitle: Integer;
 | 
|---|
| 72 |     DfltTitleName: string;
 | 
|---|
| 73 |     ShortList: TStringList;
 | 
|---|
| 74 |     constructor Create;
 | 
|---|
| 75 |     destructor Destroy; override;
 | 
|---|
| 76 |   end;
 | 
|---|
| 77 | 
 | 
|---|
| 78 |   TTIUPrefs = class
 | 
|---|
| 79 |     DfltLoc: Integer;
 | 
|---|
| 80 |     DfltLocName: string;
 | 
|---|
| 81 |     SortAscending: Boolean;
 | 
|---|
| 82 |     SortBy: string;    // D,R,S,A
 | 
|---|
| 83 |     AskNoteSubject: Boolean;
 | 
|---|
| 84 |     AskCosigner: Boolean;
 | 
|---|
| 85 |     DfltCosigner: Int64;
 | 
|---|
| 86 |     DfltCosignerName: string;
 | 
|---|
| 87 |     MaxNotes: Integer;
 | 
|---|
| 88 |   end;
 | 
|---|
| 89 | 
 | 
|---|
| 90 | //  notes tab specific procedures
 | 
|---|
| 91 | function MakeNoteDisplayText(RawText: string): string;
 | 
|---|
| 92 | function MakeConsultDisplayText(RawText:string): string;
 | 
|---|
| 93 | function SetLinesTo74ForSave(AStrings: TStrings; AParent: TWinControl): TStrings;
 | 
|---|
| 94 | 
 | 
|---|
| 95 | const
 | 
|---|
| 96 |   TX_SAVE_ERROR1 = 'An error was encountered while trying to save the note you are editing.' + CRLF + CRLF + '    Error:  ';
 | 
|---|
| 97 |   TX_SAVE_ERROR2 = CRLF + CRLF + 'Please try again now using CTRL-SHIFT-S, or ''Save without signature''.' + CRLF +
 | 
|---|
| 98 |                    'These actions will improve the likelihood that no text will be lost.' + CRLF + CRLF +
 | 
|---|
| 99 |                    'If problems continue, or network connectivity is lost, please copy all of your text to' + CRLF +
 | 
|---|
| 100 |                    'the clipboard and paste it into Microsoft Word before continuing or before closing CPRS.';
 | 
|---|
| 101 |   TC_SAVE_ERROR =  'Error saving note text';
 | 
|---|
| 102 | 
 | 
|---|
| 103 | implementation
 | 
|---|
| 104 | 
 | 
|---|
| 105 | function MakeConsultDisplayText(RawText:string): string;
 | 
|---|
| 106 | var
 | 
|---|
| 107 |  x: string;
 | 
|---|
| 108 | begin
 | 
|---|
| 109 |    x := RawText;
 | 
|---|
| 110 |    Result := Piece(x, U, 2) + ',' + Piece(x, U, 3) + ',' +
 | 
|---|
| 111 |              Piece(x, U, 4) + ', '+ Piece(x, U, 5);
 | 
|---|
| 112 | 
 | 
|---|
| 113 | end;
 | 
|---|
| 114 | 
 | 
|---|
| 115 | function MakeNoteDisplayText(RawText: string): string;
 | 
|---|
| 116 | var
 | 
|---|
| 117 |   x: string;
 | 
|---|
| 118 | begin
 | 
|---|
| 119 |   x := RawText;
 | 
|---|
| 120 |   if Piece(x, U, 1) = '' then
 | 
|---|
| 121 |     Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3))) + '  ' +
 | 
|---|
| 122 |         Piece(x, U, 2) + ', ' + Piece(x, U, 6) + ', ' + Piece(Piece(x, U, 5), ';', 2)
 | 
|---|
| 123 |   else if Piece(x, U, 1)[1] in ['A', 'N', 'E'] then
 | 
|---|
| 124 |     Result := Piece(x, U, 2)
 | 
|---|
| 125 |   else
 | 
|---|
| 126 |     Result := FormatFMDateTime('mmm dd,yy', MakeFMDateTime(Piece(x, U, 3))) + '  ' +
 | 
|---|
| 127 |               Piece(x, U, 2) + ', ' + Piece(x, U, 6) + ', ' + Piece(Piece(x, U, 5), ';', 2);
 | 
|---|
| 128 | end;
 | 
|---|
| 129 | 
 | 
|---|
| 130 | 
 | 
|---|
| 131 | { Progress Note Titles  -------------------------------------------------------------------- }
 | 
|---|
| 132 | constructor TNoteTitles.Create;
 | 
|---|
| 133 | { creates an object to store progress note titles so only obtained from server once }
 | 
|---|
| 134 | begin
 | 
|---|
| 135 |   inherited Create;
 | 
|---|
| 136 |   ShortList := TStringList.Create;
 | 
|---|
| 137 | end;
 | 
|---|
| 138 | 
 | 
|---|
| 139 | destructor TNoteTitles.Destroy;
 | 
|---|
| 140 | { frees the lists that were used to store the progress note titles }
 | 
|---|
| 141 | begin
 | 
|---|
| 142 |   ShortList.Free;
 | 
|---|
| 143 |   inherited Destroy;
 | 
|---|
| 144 | end;
 | 
|---|
| 145 | 
 | 
|---|
| 146 | function SetLinesTo74ForSave(AStrings: TStrings; AParent: TWinControl): TStrings;
 | 
|---|
| 147 | var
 | 
|---|
| 148 |   ARichEdit74: TRichEdit;
 | 
|---|
| 149 | begin
 | 
|---|
| 150 |   Result := AStrings;
 | 
|---|
| 151 |   ARichEdit74 := TRichEdit.Create(AParent);
 | 
|---|
| 152 |   try
 | 
|---|
| 153 |     with ARichEdit74 do
 | 
|---|
| 154 |       begin
 | 
|---|
| 155 |         Parent := AParent;
 | 
|---|
| 156 |         Lines.Text := AStrings.Text;
 | 
|---|
| 157 |         Width := 525;
 | 
|---|
| 158 |         Result.Assign(Lines);
 | 
|---|
| 159 |       end;
 | 
|---|
| 160 |   finally
 | 
|---|
| 161 |     ARichEdit74.Free;
 | 
|---|
| 162 |   end;
 | 
|---|
| 163 | end;
 | 
|---|
| 164 | 
 | 
|---|
| 165 | end.
 | 
|---|