[456] | 1 | unit fPatientFlagMulti;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
[830] | 7 | Dialogs, StdCtrls, fAutoSz, ORCtrls, ExtCtrls, ComCtrls, rMisc, fBase508Form,
|
---|
| 8 | VA508AccessibilityManager;
|
---|
[456] | 9 |
|
---|
| 10 | type
|
---|
| 11 | {This object holds a List of Notes Linked to a PRF as Returned VIA the RPCBroker}
|
---|
| 12 | TPRFNotes = class(TObject)
|
---|
| 13 | private
|
---|
| 14 | FPRFNoteList : TStringList;
|
---|
| 15 | public
|
---|
| 16 | //procedure to show the Notes in a ListView, requires a listview parameter
|
---|
| 17 | procedure ShowActionsOnList(DisplayList : TCaptionListView);
|
---|
| 18 | //procedure to load the notes, this will call the RPC
|
---|
| 19 | procedure Load(TitleIEN : Int64; DFN : String);
|
---|
| 20 | function getNoteIEN(index: integer): String;
|
---|
| 21 | constructor create;
|
---|
| 22 | destructor Destroy(); override;
|
---|
| 23 | end;
|
---|
| 24 |
|
---|
[830] | 25 | TfrmFlags = class(TfrmBase508Form)
|
---|
[456] | 26 | Splitter1: TSplitter;
|
---|
| 27 | pnlTop: TORAutoPanel;
|
---|
| 28 | lblFlags: TLabel;
|
---|
[830] | 29 | lstFlagsCat2: TORListBox;
|
---|
[456] | 30 | memFlags: TRichEdit;
|
---|
| 31 | pnlNotes: TPanel;
|
---|
| 32 | lvPRF: TCaptionListView;
|
---|
| 33 | lblNoteTitle: TLabel;
|
---|
| 34 | Splitter2: TSplitter;
|
---|
| 35 | pnlBottom: TORAutoPanel;
|
---|
| 36 | btnClose: TButton;
|
---|
[830] | 37 | lstFlagsCat1: TORListBox;
|
---|
| 38 | lblCat1: TLabel;
|
---|
| 39 | TimerTextFlash: TTimer;
|
---|
| 40 | procedure lstFlagsCat1Click(Sender: TObject);
|
---|
[456] | 41 | procedure FormKeyDown(Sender: TObject; var Key: Word;
|
---|
| 42 | Shift: TShiftState);
|
---|
| 43 | procedure FormShow(Sender: TObject);
|
---|
| 44 | procedure FormCreate(Sender: TObject);
|
---|
| 45 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 46 | procedure FormDestroy(Sender: TObject);
|
---|
| 47 | procedure lvPRFClick(Sender: TObject);
|
---|
| 48 | procedure lvPRFKeyDown(Sender: TObject; var Key: Word;
|
---|
| 49 | Shift: TShiftState);
|
---|
[830] | 50 | procedure TimerTextFlashTimer(Sender: TObject);
|
---|
| 51 | procedure lstFlagsCat2Click(Sender: TObject);
|
---|
[456] | 52 | private
|
---|
| 53 | FFlagID: integer;
|
---|
| 54 | FPRFNotes : TPRFNotes;
|
---|
| 55 | FNoteTitle: String;
|
---|
[830] | 56 | procedure GetNotes(SelectedList : TORListBox);
|
---|
| 57 | procedure MakeCat1FlagsStandOut;
|
---|
| 58 | procedure LoadSelectedFlagData(SelectedList : TORListBox);
|
---|
| 59 | procedure ActivateSpecificFlag;
|
---|
| 60 | procedure PutFlagsOnLists(flags, Cat1List, Cat2List: TStrings);
|
---|
| 61 | function GetListToActivate : TORListBox;
|
---|
[456] | 62 | public
|
---|
| 63 | { Public declarations }
|
---|
| 64 | end;
|
---|
| 65 | const
|
---|
| 66 | HIDDEN_COL = 'Press enter or space bar to view this note:';
|
---|
| 67 | //TIU GET LINKED PRF NOTES, return position constants
|
---|
| 68 | NOTE_IEN_POS = 1;
|
---|
| 69 | ACTION_POS = 2;
|
---|
| 70 | NOTE_DATE_POS = 3;
|
---|
| 71 | AUTHOR_POS = 4;
|
---|
| 72 | //TIU GET PRF TITLE, return position constants
|
---|
| 73 | NOTE_TITLE_IEN = 1;
|
---|
| 74 | NOTE_TITLE = 2;
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | procedure ShowFlags(FlagId: integer = 0);
|
---|
| 78 |
|
---|
| 79 | implementation
|
---|
| 80 |
|
---|
| 81 | uses uCore,uOrPtf,ORFn, ORNet, uConst, fRptBox, rCover;
|
---|
| 82 | {$R *.dfm}
|
---|
| 83 |
|
---|
| 84 | procedure ShowFlags(FlagId: integer);
|
---|
| 85 | var
|
---|
| 86 | frmFlags: TfrmFlags;
|
---|
| 87 | begin
|
---|
| 88 | frmFlags := TFrmFlags.Create(Nil);
|
---|
| 89 | try
|
---|
| 90 | SetFormPosition(frmFlags);
|
---|
| 91 | if HasFlag then
|
---|
| 92 | begin
|
---|
[830] | 93 | with frmFlags do begin
|
---|
| 94 | FFlagID := FlagId;
|
---|
| 95 | PutFlagsOnLists(FlagList, lstFlagsCat1.Items, lstFlagsCat2.Items);
|
---|
| 96 | end;
|
---|
[456] | 97 | frmFlags.memFlags.SelStart := 0;
|
---|
| 98 | ResizeFormToFont(TForm(frmFlags));
|
---|
| 99 | frmFlags.ShowModal;
|
---|
| 100 | end
|
---|
| 101 | finally
|
---|
| 102 | frmFlags.Release;
|
---|
| 103 | end;
|
---|
| 104 | end;
|
---|
| 105 |
|
---|
[830] | 106 | procedure TfrmFlags.lstFlagsCat1Click(Sender: TObject);
|
---|
[456] | 107 | begin
|
---|
[830] | 108 | if lstFlagsCat1.ItemIndex >= 0 then
|
---|
[456] | 109 | begin
|
---|
[830] | 110 | with lstFlagsCat2 do
|
---|
| 111 | Selected[ItemIndex] := False;
|
---|
| 112 | LoadSelectedFlagData(lstFlagsCat1);
|
---|
[456] | 113 | end;
|
---|
| 114 | end;
|
---|
| 115 |
|
---|
| 116 | procedure TfrmFlags.FormKeyDown(Sender: TObject; var Key: Word;
|
---|
| 117 | Shift: TShiftState);
|
---|
| 118 | begin
|
---|
| 119 | if Key = VK_ESCAPE then
|
---|
| 120 | Close;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | procedure TfrmFlags.FormShow(Sender: TObject);
|
---|
| 125 | begin
|
---|
| 126 | inherited;
|
---|
| 127 | SetFormPosition(Self);
|
---|
[830] | 128 | if lstFlagsCat1.Count > 0 then
|
---|
| 129 | MakeCat1FlagsStandOut;
|
---|
| 130 |
|
---|
| 131 | ActivateSpecificFlag;
|
---|
[456] | 132 | end;
|
---|
| 133 |
|
---|
| 134 | procedure TfrmFlags.FormCreate(Sender: TObject);
|
---|
| 135 | begin
|
---|
| 136 | inherited;
|
---|
| 137 | FFlagID := 0;
|
---|
| 138 | end;
|
---|
| 139 |
|
---|
| 140 | procedure TfrmFlags.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 141 | begin
|
---|
| 142 | inherited;
|
---|
| 143 | SaveUserBounds(Self);
|
---|
| 144 | end;
|
---|
| 145 |
|
---|
[830] | 146 | procedure TfrmFlags.GetNotes(SelectedList : TORListBox);
|
---|
[456] | 147 | var
|
---|
| 148 | NoteTitleIEN, FlagID : Int64;
|
---|
| 149 | begin
|
---|
| 150 | if FPRFNotes = nil then
|
---|
| 151 | FPRFNotes := TPRFNotes.Create;
|
---|
[830] | 152 | FlagID := SelectedList.ItemID;
|
---|
[456] | 153 | CallV('TIU GET PRF TITLE', [Patient.DFN,FlagID]);
|
---|
| 154 | FNoteTitle := Piece(RPCBrokerV.Results[0],U,NOTE_TITLE);
|
---|
| 155 | lblNoteTitle.Caption := 'Signed, Linked Notes of Title: '+ FNoteTitle;
|
---|
| 156 | NoteTitleIEN := StrToInt(Piece(RPCBrokerV.Results[0],U,NOTE_TITLE_IEN));
|
---|
| 157 | FPRFNotes.Load(NoteTitleIEN,Patient.DFN);
|
---|
| 158 | FPRFNotes.ShowActionsOnList(lvPRF);
|
---|
| 159 | with lvPRF do begin
|
---|
| 160 |
|
---|
| 161 | Columns.BeginUpdate;
|
---|
| 162 | Columns.EndUpdate;
|
---|
| 163 | end;
|
---|
| 164 | end;
|
---|
| 165 |
|
---|
| 166 | { TPRFNotes }
|
---|
| 167 |
|
---|
| 168 | constructor TPRFNotes.create;
|
---|
| 169 | begin
|
---|
| 170 | inherited;
|
---|
| 171 | FPRFNoteList := TStringList.create;
|
---|
| 172 | end;
|
---|
| 173 |
|
---|
| 174 | destructor TPRFNotes.Destroy;
|
---|
| 175 | begin
|
---|
| 176 | FPRFNoteList.Free;
|
---|
| 177 | inherited;
|
---|
| 178 | end;
|
---|
| 179 |
|
---|
| 180 | function TPRFNotes.getNoteIEN(index: integer): String;
|
---|
| 181 | begin
|
---|
| 182 | Result := Piece(FPRFNoteList[index],U,NOTE_IEN_POS);
|
---|
| 183 | end;
|
---|
| 184 |
|
---|
| 185 | procedure TPRFNotes.Load(TitleIEN: Int64; DFN: String);
|
---|
| 186 | const
|
---|
| 187 | REVERSE_CHRONO = 1;
|
---|
| 188 | begin
|
---|
| 189 | CallV('TIU GET LINKED PRF NOTES', [DFN,TitleIEN,REVERSE_CHRONO]);
|
---|
[830] | 190 | FastAssign(RPCBrokerV.Results, FPRFNoteList);
|
---|
[456] | 191 | end;
|
---|
| 192 |
|
---|
| 193 | procedure TPRFNotes.ShowActionsOnList(DisplayList: TCaptionListView);
|
---|
| 194 | var
|
---|
| 195 | i : integer;
|
---|
| 196 | ListItem: TListItem;
|
---|
| 197 | begin
|
---|
| 198 | DisplayList.Clear;
|
---|
| 199 | for i := 0 to FPRFNoteList.Count-1 do
|
---|
| 200 | begin
|
---|
| 201 | //Caption="Text for Screen Reader" SubItem1=Flag SubItem2=Date SubItem3=Action SubItem4=Note
|
---|
| 202 | ListItem := DisplayList.Items.Add;
|
---|
| 203 | ListItem.Caption := HIDDEN_COL; //Screen readers don't read the first column title on a listview.
|
---|
| 204 | ListItem.SubItems.Add(Piece(FPRFNoteList[i],U,NOTE_DATE_POS));
|
---|
| 205 | ListItem.SubItems.Add(Piece(FPRFNoteList[i],U,ACTION_POS));
|
---|
| 206 | ListItem.SubItems.Add(Piece(FPRFNoteList[i],U,AUTHOR_POS));
|
---|
| 207 | end;
|
---|
| 208 | end;
|
---|
| 209 |
|
---|
| 210 | procedure TfrmFlags.FormDestroy(Sender: TObject);
|
---|
| 211 | begin
|
---|
| 212 | FPRFNotes.Free;
|
---|
| 213 | end;
|
---|
| 214 |
|
---|
| 215 | procedure TfrmFlags.lvPRFClick(Sender: TObject);
|
---|
| 216 | begin
|
---|
| 217 | if lvPRF.ItemIndex > -1 then
|
---|
| 218 | begin
|
---|
| 219 | NotifyOtherApps(NAE_REPORT, 'TIU^' + FPRFNotes.getNoteIEN(lvPRF.ItemIndex));
|
---|
| 220 | ReportBox(DetailPosting(FPRFNotes.getNoteIEN(lvPRF.ItemIndex)), FNoteTitle, True);
|
---|
| 221 | end;
|
---|
| 222 | end;
|
---|
| 223 |
|
---|
| 224 | procedure TfrmFlags.lvPRFKeyDown(Sender: TObject; var Key: Word;
|
---|
| 225 | Shift: TShiftState);
|
---|
| 226 | begin
|
---|
| 227 | if (Key = VK_SPACE) or (Key = VK_RETURN) then
|
---|
| 228 | lvPRFClick(Sender);
|
---|
| 229 | end;
|
---|
| 230 |
|
---|
[830] | 231 |
|
---|
| 232 | procedure TfrmFlags.MakeCat1FlagsStandOut;
|
---|
| 233 | Const
|
---|
| 234 | FONT_INC = 4;
|
---|
| 235 | clBrightOrange = TColor($3ABEF3); //Blue 58 Green 190 Red 243
|
---|
| 236 | begin
|
---|
| 237 | lblCat1.Font.Size := lblCat1.Font.Size + FONT_INC;
|
---|
| 238 | lstFlagsCat1.Font.Size := lstFlagsCat1.Font.Size + FONT_INC;
|
---|
| 239 | lblCat1.Color := Get508CompliantColor(clBrightOrange);
|
---|
| 240 | lstFlagsCat1.Color := Get508CompliantColor(clBrightOrange);
|
---|
| 241 | lblCat1.Font.Color := Get508CompliantColor(clWhite);
|
---|
| 242 | lstFlagsCat1.Font.Color := Get508CompliantColor(clWhite);
|
---|
| 243 | TimerTextFlash.Enabled := true;
|
---|
| 244 | end;
|
---|
| 245 |
|
---|
| 246 | procedure TfrmFlags.TimerTextFlashTimer(Sender: TObject);
|
---|
| 247 | begin
|
---|
| 248 | if lblCat1.Font.Color = Get508CompliantColor(clWhite) then
|
---|
| 249 | lblCat1.Font.Color := Get508CompliantColor(clBlack)
|
---|
| 250 | else
|
---|
| 251 | lblCat1.Font.Color := Get508CompliantColor(clWhite);
|
---|
| 252 | end;
|
---|
| 253 |
|
---|
| 254 | procedure TfrmFlags.LoadSelectedFlagData(SelectedList: TORListBox);
|
---|
| 255 | var
|
---|
| 256 | FlagArray: TStringList;
|
---|
| 257 | begin
|
---|
| 258 | FlagArray := TStringList.Create;
|
---|
| 259 | GetActiveFlg(FlagArray, Patient.DFN, SelectedList.ItemID);
|
---|
| 260 | if FlagArray.Count > 0 then
|
---|
| 261 | QuickCopy(FlagArray, memFlags);
|
---|
| 262 | memFlags.SelStart := 0;
|
---|
| 263 | GetNotes(SelectedList);
|
---|
| 264 | end;
|
---|
| 265 |
|
---|
| 266 | procedure TfrmFlags.lstFlagsCat2Click(Sender: TObject);
|
---|
| 267 | begin
|
---|
| 268 | if lstFlagsCat2.ItemIndex >= 0 then
|
---|
| 269 | begin
|
---|
| 270 | with lstFlagsCat1 do
|
---|
| 271 | Selected[ItemIndex] := False;
|
---|
| 272 | LoadSelectedFlagData(lstFlagsCat2);
|
---|
| 273 | end;
|
---|
| 274 | end;
|
---|
| 275 |
|
---|
| 276 | procedure TfrmFlags.ActivateSpecificFlag;
|
---|
| 277 | var
|
---|
| 278 | idx: integer;
|
---|
| 279 | SelectedList : TORListBox;
|
---|
| 280 | begin
|
---|
| 281 | idx := 0;
|
---|
| 282 | SelectedList := GetListToActivate;
|
---|
| 283 | if FFlagID > 0 then
|
---|
| 284 | idx := SelectedList.SelectByIEN(FFlagId);
|
---|
| 285 | SelectedList.ItemIndex := idx;
|
---|
| 286 | SelectedList.OnClick(Self);
|
---|
| 287 | ActiveControl := memFlags;
|
---|
| 288 | GetNotes(SelectedList);
|
---|
| 289 | end;
|
---|
| 290 |
|
---|
| 291 | function TfrmFlags.GetListToActivate: TORListBox;
|
---|
| 292 | begin
|
---|
| 293 | Result := nil;
|
---|
| 294 | if FFlagID > 0 then begin
|
---|
| 295 | if lstFlagsCat1.SelectByIEN(FFlagId) > -1 then
|
---|
| 296 | Result := lstFlagsCat1
|
---|
| 297 | else if lstFlagsCat2.SelectByIEN(FFlagId) > -1 then
|
---|
| 298 | Result := lstFlagsCat2
|
---|
| 299 | end;
|
---|
| 300 | if Result = nil then
|
---|
| 301 | if lstFlagsCat1.Items.Count > 0 then
|
---|
| 302 | Result := lstFlagsCat1
|
---|
| 303 | else
|
---|
| 304 | Result := lstFlagsCat2;
|
---|
| 305 |
|
---|
| 306 | end;
|
---|
| 307 |
|
---|
| 308 | procedure TfrmFlags.PutFlagsOnLists(flags, Cat1List, Cat2List: TStrings);
|
---|
| 309 | Const
|
---|
| 310 | FLAG_TYPE_POS = 3;
|
---|
| 311 | TRUE_STRING = '1';
|
---|
| 312 | var
|
---|
| 313 | i : integer;
|
---|
| 314 | begin
|
---|
| 315 | for i := 0 to flags.Count-1 do begin
|
---|
| 316 | if Piece(flags[i],U,FLAG_TYPE_POS) = TRUE_STRING then
|
---|
| 317 | Cat1List.Add(flags[i])
|
---|
| 318 | else
|
---|
| 319 | Cat2List.Add(flags[i]);
|
---|
| 320 | end;
|
---|
| 321 | end;
|
---|
| 322 |
|
---|
[456] | 323 | end.
|
---|