[453] | 1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
| 2 | unit fOrderVw;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses
|
---|
| 7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 8 | fAutoSz, StdCtrls, ComCtrls, ExtCtrls, ORCtrls, ORFn, rOrders, ORDtTm,
|
---|
| 9 | DKLang;
|
---|
| 10 |
|
---|
| 11 | type
|
---|
| 12 | TfrmOrderView = class(TfrmAutoSz)
|
---|
| 13 | pnlView: TPanel;
|
---|
| 14 | lblView: TLabel;
|
---|
| 15 | Panel1: TPanel;
|
---|
| 16 | Panel2: TPanel;
|
---|
| 17 | lblFilter: TLabel;
|
---|
| 18 | trFilters: TCaptionTreeView;
|
---|
| 19 | Panel3: TPanel;
|
---|
| 20 | treService: TCaptionTreeView;
|
---|
| 21 | lblService: TLabel;
|
---|
| 22 | Panel4: TPanel;
|
---|
| 23 | chkDateRange: TCheckBox;
|
---|
| 24 | GroupBox1: TGroupBox;
|
---|
| 25 | lblFrom: TLabel;
|
---|
| 26 | lblThru: TLabel;
|
---|
| 27 | calFrom: TORDateBox;
|
---|
| 28 | calThru: TORDateBox;
|
---|
| 29 | chkInvChrono: TCheckBox;
|
---|
| 30 | chkByService: TCheckBox;
|
---|
| 31 | cmdOK: TButton;
|
---|
| 32 | cmdCancel: TButton;
|
---|
| 33 | Splitter1: TSplitter;
|
---|
| 34 | procedure FormCreate(Sender: TObject);
|
---|
| 35 | procedure treServiceClick(Sender: TObject);
|
---|
| 36 | procedure cmdCancelClick(Sender: TObject);
|
---|
| 37 | procedure cmdOKClick(Sender: TObject);
|
---|
| 38 | procedure chkDateRangeClick(Sender: TObject);
|
---|
| 39 | procedure calChange(Sender: TObject);
|
---|
| 40 | procedure trFiltersClick(Sender: TObject);
|
---|
| 41 | procedure Splitter1Moved(Sender: TObject);
|
---|
| 42 | private
|
---|
| 43 | FChanged: Boolean;
|
---|
| 44 | FDGroup: Integer;
|
---|
| 45 | FDGroupName: string;
|
---|
| 46 | FFilter: Integer;
|
---|
| 47 | FFilterName: string;
|
---|
| 48 | FInvChrono: Boolean;
|
---|
| 49 | FByService: Boolean;
|
---|
| 50 | FTimeFrom: TFMDateTime;
|
---|
| 51 | FTimeThru: TFMDateTime;
|
---|
| 52 | procedure LoadDGroups(const Parent: string; Node: TTreeNode);
|
---|
| 53 | procedure LoadFilters(const Parent: string; Node: TTreeNode);
|
---|
| 54 | procedure SynchViewData;
|
---|
| 55 | procedure UpdateViewName;
|
---|
| 56 | public
|
---|
| 57 | { Public declarations }
|
---|
| 58 | end;
|
---|
| 59 |
|
---|
| 60 | procedure SelectOrderView(var OrderView: TOrderView);
|
---|
| 61 |
|
---|
| 62 | implementation
|
---|
| 63 |
|
---|
| 64 | {$R *.DFM}
|
---|
| 65 |
|
---|
| 66 | //const
|
---|
| 67 | //TX_DATES = 'To list orders for a specific date range, both From & Thru dates are required.'; <-- original line. //kt 8/8/2007
|
---|
| 68 | //TC_DATES = 'Error in Date Range'; <-- original line. //kt 8/8/2007
|
---|
| 69 |
|
---|
| 70 | var
|
---|
| 71 | TX_DATES : string; //kt
|
---|
| 72 | TC_DATES : string; //kt
|
---|
| 73 |
|
---|
| 74 | procedure SetupVars;
|
---|
| 75 | //kt Added entire function to replace constant declarations 8/8/2007
|
---|
| 76 | begin
|
---|
| 77 | TX_DATES := DKLangConstW('fOrderVw_To_list_orders_for_a_specific_date_rangex_both_From_x_Thru_dates_are_requiredx');
|
---|
| 78 | TC_DATES := DKLangConstW('fOrderVw_Error_in_Date_Range');
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | var
|
---|
| 82 | uDGroupList: TStringList;
|
---|
| 83 | uFilterList: TStringList;
|
---|
| 84 |
|
---|
| 85 | procedure SelectOrderView(var OrderView: TOrderView);
|
---|
| 86 | var
|
---|
| 87 | frmOrderView: TfrmOrderView;
|
---|
| 88 | begin
|
---|
| 89 | frmOrderView := TfrmOrderView.Create(Application);
|
---|
| 90 | try
|
---|
| 91 | ResizeFormToFont(TForm(frmOrderView));
|
---|
| 92 | with frmOrderView do
|
---|
| 93 | begin
|
---|
| 94 | FDGroup := OrderView.DGroup;
|
---|
| 95 | FFilter := OrderView.Filter;
|
---|
| 96 | FInvChrono := OrderView.InvChrono;
|
---|
| 97 | FByService := OrderView.ByService;
|
---|
| 98 | FTimeFrom := OrderView.TimeFrom;
|
---|
| 99 | FTimeThru := OrderView.TimeThru;
|
---|
| 100 | SynchViewData;
|
---|
| 101 | ShowModal;
|
---|
| 102 | if FChanged then
|
---|
| 103 | begin
|
---|
| 104 | OrderView.Changed := FChanged;
|
---|
| 105 | OrderView.DGroup := FDGroup;
|
---|
| 106 | OrderView.Filter := FFilter;
|
---|
| 107 | OrderView.InvChrono := FInvChrono;
|
---|
| 108 | OrderView.ByService := FByService;
|
---|
| 109 | OrderView.TimeFrom := FTimeFrom;
|
---|
| 110 | OrderView.TimeThru := FTimeThru;
|
---|
| 111 | OrderView.CtxtTime := 0; // set by RefreshOrderList
|
---|
| 112 | OrderView.TextView := 0; // set by RefreshOrderList
|
---|
| 113 | OrderView.ViewName := lblView.Caption;
|
---|
| 114 | OrderView.EventDelay.EventType := 'C';
|
---|
| 115 | OrderView.EventDelay.Specialty := 0; // treating specialty only for event delayed
|
---|
| 116 | OrderView.EventDelay.Effective := 0; // effective date only for discharge orders
|
---|
| 117 | end
|
---|
| 118 | else OrderView.Changed := False;
|
---|
| 119 | end; {with}
|
---|
| 120 | finally
|
---|
| 121 | frmOrderView.Release;
|
---|
| 122 | end;
|
---|
| 123 | end;
|
---|
| 124 |
|
---|
| 125 | procedure TfrmOrderView.FormCreate(Sender: TObject);
|
---|
| 126 | begin
|
---|
| 127 | inherited;
|
---|
| 128 | FChanged := False;
|
---|
| 129 | uDGroupList := TStringList.Create;
|
---|
| 130 | uFilterList := TStringList.Create;
|
---|
| 131 | try
|
---|
| 132 | ListDGroupAll(uDGroupList);
|
---|
| 133 | LoadDGroups('0', nil);
|
---|
| 134 |
|
---|
| 135 | ListOrderFiltersAll(uFilterList);
|
---|
| 136 | LoadFilters('0', nil);
|
---|
| 137 | finally
|
---|
| 138 | uDGroupList.Free;
|
---|
| 139 | uDGroupList := nil;
|
---|
| 140 | uFilterList.Free;
|
---|
| 141 | uFilterList := nil;
|
---|
| 142 | end;
|
---|
| 143 | end;
|
---|
| 144 |
|
---|
| 145 | procedure TfrmOrderView.UpdateViewName;
|
---|
| 146 | const
|
---|
| 147 | FMT_TIME = 'mm/dd/yy';
|
---|
| 148 | var
|
---|
| 149 | DateText, FilterText: string;
|
---|
| 150 | begin
|
---|
| 151 | if chkDateRange.Checked
|
---|
| 152 | then DateText := ' (' + FormatFMDateTime(FMT_TIME, calFrom.FMDateTime) +
|
---|
| 153 | ' thru ' + FormatFMDateTIme(FMT_TIME, calThru.FMDateTime) + ')'
|
---|
| 154 | else DateText := '';
|
---|
| 155 | if FFilter in [6, 8, 9, 10, 19, 20]
|
---|
| 156 | then FilterText := FFilterName
|
---|
| 157 | // else FilterText := FFilterName + ' Orders'; <-- original line. //kt 8/8/2007
|
---|
| 158 | else FilterText := FFilterName + DKLangConstW('fOrderVw_Orders'); //kt added 8/8/2007
|
---|
| 159 | lblView.Caption := FilterText + ' - ' + FDGroupName + DateText;
|
---|
| 160 | end;
|
---|
| 161 |
|
---|
| 162 | procedure TfrmOrderView.SynchViewData;
|
---|
| 163 | var
|
---|
| 164 | i: Integer;
|
---|
| 165 | begin
|
---|
| 166 | with treService.Items do for i := 0 to Count - 1 do if Integer(Item[i].Data) = FDGroup then
|
---|
| 167 | begin
|
---|
| 168 | Item[i].Expanded := True;
|
---|
| 169 | Item[i].Selected := True;
|
---|
| 170 | FDGroupName := Item[i].Text;
|
---|
| 171 | Break;
|
---|
| 172 | end;
|
---|
| 173 |
|
---|
| 174 | with trFilters.Items do for i := 0 to Count - 1 do if Integer(Item[i].Data) = FFilter then
|
---|
| 175 | begin
|
---|
| 176 | Item[i].Expanded := True;
|
---|
| 177 | Item[i].Selected := True;
|
---|
| 178 | FDGroupName := Item[i].Text;
|
---|
| 179 | Break;
|
---|
| 180 | end;
|
---|
| 181 |
|
---|
| 182 | if (FTimeFrom > 0) or (FTimeThru > 0) then
|
---|
| 183 | begin
|
---|
| 184 | calFrom.FMDateTime := FTimeFrom;
|
---|
| 185 | calThru.FMDateTime := FTimeThru;
|
---|
| 186 | chkDateRange.Checked := True;
|
---|
| 187 | chkDateRangeClick(Self);
|
---|
| 188 | end;
|
---|
| 189 | UpdateViewName;
|
---|
| 190 | chkByService.Checked := FByService;
|
---|
| 191 | chkInvChrono.Checked := FInvChrono;
|
---|
| 192 | end;
|
---|
| 193 |
|
---|
| 194 | procedure TfrmOrderView.LoadDGroups(const Parent: string; Node: TTreeNode);
|
---|
| 195 | var
|
---|
| 196 | MyID, MyParent, Name: string;
|
---|
| 197 | i, IEN: Integer;
|
---|
| 198 | ChildNode: TTreeNode;
|
---|
| 199 | HasChildren: Boolean;
|
---|
| 200 | begin
|
---|
| 201 | with uDGroupList do for i := 0 to Count - 1 do
|
---|
| 202 | begin
|
---|
| 203 | MyParent := Piece(Strings[i], U, 3);
|
---|
| 204 | if MyParent = Parent then
|
---|
| 205 | begin
|
---|
| 206 | MyID := Piece(Strings[i], U, 1);
|
---|
| 207 | IEN := StrToIntDef(MyID, 0);
|
---|
| 208 | Name := Piece(Strings[i], U, 2);
|
---|
| 209 | HasChildren := Piece(Strings[i], U, 4) = '+';
|
---|
| 210 | ChildNode := treService.Items.AddChildObject(Node, Name, Pointer(IEN));
|
---|
| 211 | if HasChildren then LoadDGroups(MyID, ChildNode);
|
---|
| 212 | end;
|
---|
| 213 | end;
|
---|
| 214 | end;
|
---|
| 215 |
|
---|
| 216 | procedure TfrmOrderView.LoadFilters(const Parent: string; Node: TTreeNode);
|
---|
| 217 | var
|
---|
| 218 | MyID, MyParent, Name: string;
|
---|
| 219 | i, IEN: Integer;
|
---|
| 220 | ChildNode: TTreeNode;
|
---|
| 221 | HasChildren: Boolean;
|
---|
| 222 | begin
|
---|
| 223 | with uFilterList do for i := 0 to Count - 1 do
|
---|
| 224 | begin
|
---|
| 225 | MyParent := Piece(Strings[i], U, 3);
|
---|
| 226 | if MyParent = Parent then
|
---|
| 227 | begin
|
---|
| 228 | MyID := Piece(Strings[i], U, 1);
|
---|
| 229 | IEN := StrToIntDef(MyID, 0);
|
---|
| 230 | Name := Piece(Strings[i], U, 2);
|
---|
| 231 | HasChildren := Piece(Strings[i], U, 4) = '+';
|
---|
| 232 | ChildNode := trFilters.Items.AddChildObject(Node, Name, Pointer(IEN));
|
---|
| 233 | if HasChildren then LoadFilters(MyID, ChildNode);
|
---|
| 234 | end;
|
---|
| 235 | end;
|
---|
| 236 | end;
|
---|
| 237 |
|
---|
| 238 | procedure TfrmOrderView.treServiceClick(Sender: TObject);
|
---|
| 239 | var
|
---|
| 240 | Node: TTreeNode;
|
---|
| 241 | begin
|
---|
| 242 | inherited;
|
---|
| 243 | Node := treService.Selected;
|
---|
| 244 | if Node <> nil then
|
---|
| 245 | begin
|
---|
| 246 | FDGroup := Integer(Node.Data);
|
---|
| 247 | FDGroupName := Node.Text;
|
---|
| 248 | UpdateViewName;
|
---|
| 249 | end;
|
---|
| 250 | end;
|
---|
| 251 |
|
---|
| 252 | procedure TfrmOrderView.chkDateRangeClick(Sender: TObject);
|
---|
| 253 | begin
|
---|
| 254 | inherited;
|
---|
| 255 | lblThru.Enabled := chkDateRange.Checked;
|
---|
| 256 | calThru.Enabled := chkDateRange.Checked;
|
---|
| 257 | lblFrom.Enabled := chkDateRange.Checked;
|
---|
| 258 | calFrom.Enabled := chkDateRange.Checked;
|
---|
| 259 | if chkDateRange.Checked then
|
---|
| 260 | begin
|
---|
| 261 | calFrom.Color := clWindow;
|
---|
| 262 | calThru.Color := clWindow;
|
---|
| 263 | if calThru.FMDateTime = 0 then calThru.Text := 'NOW';
|
---|
| 264 | end else
|
---|
| 265 | begin
|
---|
| 266 | calFrom.FMDateTime := 0;
|
---|
| 267 | calThru.FMDateTime := 0;
|
---|
| 268 | calFrom.Color := clBtnFace;
|
---|
| 269 | calThru.Color := clBtnFace;
|
---|
| 270 | end;
|
---|
| 271 | UpdateViewName;
|
---|
| 272 | end;
|
---|
| 273 |
|
---|
| 274 | procedure TfrmOrderView.calChange(Sender: TObject);
|
---|
| 275 | begin
|
---|
| 276 | inherited;
|
---|
| 277 | UpdateViewName;
|
---|
| 278 | end;
|
---|
| 279 |
|
---|
| 280 | procedure TfrmOrderView.cmdOKClick(Sender: TObject);
|
---|
| 281 | begin
|
---|
| 282 | SetupVars; //kt added 8/8/2007 to replace constants with vars.
|
---|
| 283 | inherited;
|
---|
| 284 | if chkDateRange.Checked and ((not calFrom.IsValid) or (not calThru.IsValid)) then
|
---|
| 285 | begin
|
---|
| 286 | InfoBox(TX_DATES, TC_DATES, MB_OK);
|
---|
| 287 | Exit;
|
---|
| 288 | end;
|
---|
| 289 | if chkDateRange.Checked then
|
---|
| 290 | begin
|
---|
| 291 | FTimeFrom := calFrom.FMDateTime;
|
---|
| 292 | FTimeThru := calThru.FMDateTime;
|
---|
| 293 | end else
|
---|
| 294 | begin
|
---|
| 295 | FTimeFrom := 0;
|
---|
| 296 | FTimeThru := 0;
|
---|
| 297 | end;
|
---|
| 298 | FChanged := True;
|
---|
| 299 | FInvChrono := chkInvChrono.Checked;
|
---|
| 300 | FByService := chkByService.Checked;
|
---|
| 301 | Close;
|
---|
| 302 | end;
|
---|
| 303 |
|
---|
| 304 | procedure TfrmOrderView.cmdCancelClick(Sender: TObject);
|
---|
| 305 | begin
|
---|
| 306 | inherited;
|
---|
| 307 | Close;
|
---|
| 308 | end;
|
---|
| 309 |
|
---|
| 310 | procedure TfrmOrderView.trFiltersClick(Sender: TObject);
|
---|
| 311 | var
|
---|
| 312 | Node: TTreeNode;
|
---|
| 313 | begin
|
---|
| 314 | inherited;
|
---|
| 315 | Node := trFilters.Selected;
|
---|
| 316 | if Node <> nil then
|
---|
| 317 | begin
|
---|
| 318 | FFilter := Integer(Node.Data);
|
---|
| 319 | FFilterName := Node.Text;
|
---|
| 320 | if FFilter = 2 then // disallow date range for active orders view
|
---|
| 321 | begin
|
---|
| 322 | chkDateRange.Checked := False;
|
---|
| 323 | chkDateRangeClick(Self);
|
---|
| 324 | end;
|
---|
| 325 | if FFilter in [8, 9, 10, 20] then chkDateRange.Checked := True else
|
---|
| 326 | begin
|
---|
| 327 | if (calFrom.Text = '') and (calThru.Text = '') then chkDateRange.Checked := False;
|
---|
| 328 | end;
|
---|
| 329 | UpdateViewName;
|
---|
| 330 | end;
|
---|
| 331 | end;
|
---|
| 332 |
|
---|
| 333 | procedure TfrmOrderView.Splitter1Moved(Sender: TObject);
|
---|
| 334 | begin
|
---|
| 335 | inherited;
|
---|
| 336 | Splitter1.Align := alNone;
|
---|
| 337 | Splitter1.Align := alLeft;
|
---|
| 338 | end;
|
---|
| 339 |
|
---|
| 340 | end.
|
---|