| 1 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 2 | //Name: fPCEBase.pas, fPCEBase.dfm | 
|---|
| 3 | //Created: Jan 1999 | 
|---|
| 4 | //By: Robert Bott | 
|---|
| 5 | //Location: ISL | 
|---|
| 6 | //Description: Parent form for all PCE tabs.  This form will hold methods that are | 
|---|
| 7 | // universal for a PCE tabs.  These forms will be child forms to fEncounterFrame. | 
|---|
| 8 | ////////////////////////////////////////////////////////////////////////////////} | 
|---|
| 9 |  | 
|---|
| 10 | unit fPCEBase; | 
|---|
| 11 |  | 
|---|
| 12 | {$OPTIMIZATION OFF}                              // REMOVE AFTER UNIT IS DEBUGGED | 
|---|
| 13 |  | 
|---|
| 14 | interface | 
|---|
| 15 |  | 
|---|
| 16 | uses | 
|---|
| 17 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, uConst, | 
|---|
| 18 | StdCtrls, fAutoSz, Buttons, ORCtrls, ORFn, uPCE, ORDtTm, Checklst, | 
|---|
| 19 | ComCtrls; | 
|---|
| 20 |  | 
|---|
| 21 | type | 
|---|
| 22 | TfrmPCEBase = class(TfrmAutoSz) | 
|---|
| 23 | btnOK: TBitBtn; | 
|---|
| 24 | btnCancel: TBitBtn; | 
|---|
| 25 | procedure FormCreate(Sender: TObject); | 
|---|
| 26 | procedure btnCancelClick(Sender: TObject); | 
|---|
| 27 | procedure btnOKClick(Sender: TObject); virtual; | 
|---|
| 28 | procedure FormClose(Sender: TObject; var Action: TCloseAction); | 
|---|
| 29 | procedure FormShow(Sender: TObject); | 
|---|
| 30 | private | 
|---|
| 31 | FDisplayCount: Integer;                      // number of times page displayed | 
|---|
| 32 | FPatientCount: Integer;                      // number of times page displayed for given pt | 
|---|
| 33 | FCallingContext: Integer; | 
|---|
| 34 | //    function GetInitPage: Boolean; | 
|---|
| 35 | //    function GetInitPatient: Boolean; | 
|---|
| 36 | //    function GetPatientViewed: Boolean; | 
|---|
| 37 | procedure UMResizePage(var Message: TMessage); message UM_RESIZEPAGE; | 
|---|
| 38 | protected | 
|---|
| 39 | FClosing: boolean; | 
|---|
| 40 | FSectionTabs: array[0..2] of Integer; | 
|---|
| 41 | FSectionTabCount: integer; | 
|---|
| 42 | FTabName: string; | 
|---|
| 43 | //    procedure CreateParams(var Params: TCreateParams); override; | 
|---|
| 44 | function ActiveCtrl: TWinControl; | 
|---|
| 45 | function SectionString: string; | 
|---|
| 46 | procedure DoEnter; override; | 
|---|
| 47 | public | 
|---|
| 48 | constructor CreateLinked(AParent: TWinControl); | 
|---|
| 49 | procedure Loaded; override; | 
|---|
| 50 | //    function AllowContextChange: Boolean; virtual; | 
|---|
| 51 | //    procedure ClearPtData; virtual; | 
|---|
| 52 | procedure DisplayPage; virtual; | 
|---|
| 53 | //    procedure NotifyOrder(OrderAction: Integer; AnOrder: TOrder); virtual;  //*no ordering will be done*// | 
|---|
| 54 | //    procedure RequestPrint; virtual; | 
|---|
| 55 | procedure SetFontSize(NewFontSize: Integer); virtual; | 
|---|
| 56 | procedure AllowTabChange(var AllowChange: boolean); virtual; | 
|---|
| 57 |  | 
|---|
| 58 | property CallingContext: Integer read FCallingContext; | 
|---|
| 59 | //    property InitPage: Boolean read GetInitPage; | 
|---|
| 60 | //    property InitPatient: Boolean read GetInitPatient; | 
|---|
| 61 | //    property PatientViewed: Boolean read GetPatientViewed; | 
|---|
| 62 | procedure FocusFirstControl; | 
|---|
| 63 | end; | 
|---|
| 64 |  | 
|---|
| 65 | var | 
|---|
| 66 | frmPCEBase: TfrmPCEBase; | 
|---|
| 67 |  | 
|---|
| 68 | implementation | 
|---|
| 69 |  | 
|---|
| 70 | {$R *.DFM} | 
|---|
| 71 |  | 
|---|
| 72 | uses | 
|---|
| 73 | fEncounterFrame; | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 77 | //Name: procedure TfrmPCEBase.FormCreate(Sender: TObject); | 
|---|
| 78 | //Created: Jan 1999 | 
|---|
| 79 | //By: Robert Bott | 
|---|
| 80 | //Location: ISL | 
|---|
| 81 | //Description: Initialize counters to zero | 
|---|
| 82 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 83 | procedure TfrmPCEBase.FormCreate(Sender: TObject); | 
|---|
| 84 | begin | 
|---|
| 85 | FDisplayCount := 0; | 
|---|
| 86 | FPatientCount := 0; | 
|---|
| 87 | end; | 
|---|
| 88 |  | 
|---|
| 89 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 90 | //Name: procedure TfrmPCEBase.CreateParams(var Params: TCreateParams); | 
|---|
| 91 | //Created: Jan 1999 | 
|---|
| 92 | //By: Robert Bott | 
|---|
| 93 | //Location: ISL | 
|---|
| 94 | //Description: turn the form into a child window | 
|---|
| 95 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 96 | (*procedure TfrmPCEBase.CreateParams(var Params: TCreateParams); | 
|---|
| 97 | { turn the form into a child window } | 
|---|
| 98 | begin | 
|---|
| 99 | inherited CreateParams(Params); | 
|---|
| 100 | with Params do | 
|---|
| 101 | begin | 
|---|
| 102 | if Owner is TPanel | 
|---|
| 103 | then WndParent := TPanel(Owner).Handle | 
|---|
| 104 | else if owner is TForm then | 
|---|
| 105 | WndParent := (Owner as TForm).Handle; | 
|---|
| 106 | Style := WS_CHILD or WS_CLIPSIBLINGS; | 
|---|
| 107 | X := 0; Y := 0; | 
|---|
| 108 | end; | 
|---|
| 109 | end; | 
|---|
| 110 | *) | 
|---|
| 111 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 112 | //Name: procedure TfrmPCEBase.Loaded; | 
|---|
| 113 | //Created: Jan 1999 | 
|---|
| 114 | //By: Robert Bott | 
|---|
| 115 | //Location: ISL | 
|---|
| 116 | //Description: make the form borderless to allow it to be a child window | 
|---|
| 117 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 118 | procedure TfrmPCEBase.Loaded; | 
|---|
| 119 | begin | 
|---|
| 120 | inherited Loaded; | 
|---|
| 121 | Visible := False; | 
|---|
| 122 | Position := poDefault; | 
|---|
| 123 | BorderIcons := []; | 
|---|
| 124 | BorderStyle := bsNone; | 
|---|
| 125 | HandleNeeded; | 
|---|
| 126 | SetBounds(0, 0, Width, Height); | 
|---|
| 127 | end; | 
|---|
| 128 |  | 
|---|
| 129 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 130 | //Name: function TfrmPCEBase.AllowContextChange: Boolean; | 
|---|
| 131 | //Created: Jan 1999 | 
|---|
| 132 | //By: Robert Bott | 
|---|
| 133 | //Location: ISL | 
|---|
| 134 | //Description: | 
|---|
| 135 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 136 | (*function TfrmPCEBase.AllowContextChange: Boolean; | 
|---|
| 137 | begin | 
|---|
| 138 | Result := True; | 
|---|
| 139 | end; | 
|---|
| 140 |  | 
|---|
| 141 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 142 | //Name: procedure TfrmPCEBase.ClearPtData; | 
|---|
| 143 | //Created: Jan 1999 | 
|---|
| 144 | //By: Robert Bott | 
|---|
| 145 | //Location: ISL | 
|---|
| 146 | //Description: clear all patient related data on a page | 
|---|
| 147 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 148 | procedure TfrmPCEBase.ClearPtData; | 
|---|
| 149 | begin | 
|---|
| 150 | FPatientCount := 0; | 
|---|
| 151 | end; | 
|---|
| 152 | *) | 
|---|
| 153 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 154 | //Name: procedure TfrmPCEBase.DisplayPage; | 
|---|
| 155 | //Created: Jan 1999 | 
|---|
| 156 | //By: Robert Bott | 
|---|
| 157 | //Location: ISL | 
|---|
| 158 | //Description: cause the page to be displayed and update the display counters | 
|---|
| 159 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 160 | procedure TfrmPCEBase.DisplayPage; | 
|---|
| 161 | begin | 
|---|
| 162 | BringToFront; | 
|---|
| 163 | //  FocusControl(ActiveCtrl); | 
|---|
| 164 | //SetFocus; | 
|---|
| 165 | Inc(FDisplayCount); | 
|---|
| 166 | Inc(FPatientCount); | 
|---|
| 167 | FCallingContext := frmEncounterFrame.ChangeSource; | 
|---|
| 168 | if (FCallingContext = CC_CLICK) and (FPatientCount = 1) | 
|---|
| 169 | then FCallingContext := CC_INIT_PATIENT; | 
|---|
| 170 | end; | 
|---|
| 171 | (* | 
|---|
| 172 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 173 | //Name: procedure TfrmPCEBase.RequestPrint; | 
|---|
| 174 | //Created: Jan 1999 | 
|---|
| 175 | //By: Robert Bott | 
|---|
| 176 | //Location: ISL | 
|---|
| 177 | //Description: For posible future use when printing is supported. | 
|---|
| 178 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 179 | procedure TfrmPCEBase.RequestPrint; | 
|---|
| 180 | begin | 
|---|
| 181 | // | 
|---|
| 182 | end; | 
|---|
| 183 | *) | 
|---|
| 184 |  | 
|---|
| 185 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 186 | //Name: procedure TfrmPCEBase.SetFontSize(NewFontSize: Integer); | 
|---|
| 187 | //Created: Jan 1999 | 
|---|
| 188 | //By: Robert Bott | 
|---|
| 189 | //Location: ISL | 
|---|
| 190 | //Description: Assign the new font size. | 
|---|
| 191 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 192 | procedure TfrmPCEBase.SetFontSize(NewFontSize: Integer); | 
|---|
| 193 | begin | 
|---|
| 194 | Font.Size := NewFontSize; | 
|---|
| 195 | end; | 
|---|
| 196 | (* | 
|---|
| 197 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 198 | //Name: function TfrmPCEBase.GetInitPage: Boolean; | 
|---|
| 199 | //Created: Jan 1999 | 
|---|
| 200 | //By: Robert Bott | 
|---|
| 201 | //Location: ISL | 
|---|
| 202 | //Description: if the count is one, this is the first time the page is being displayed. | 
|---|
| 203 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 204 | function TfrmPCEBase.GetInitPage: Boolean; | 
|---|
| 205 | begin | 
|---|
| 206 | Result := FDisplayCount = 1; | 
|---|
| 207 | end; | 
|---|
| 208 |  | 
|---|
| 209 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 210 | //Name: function TfrmPCEBase.GetInitPatient: Boolean; | 
|---|
| 211 | //Created: Jan 1999 | 
|---|
| 212 | //By: Robert Bott | 
|---|
| 213 | //Location: ISL | 
|---|
| 214 | //Description: if the count is one, this is the first time the page is being | 
|---|
| 215 | // displayed for a given patient | 
|---|
| 216 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 217 | function TfrmPCEBase.GetInitPatient: Boolean; | 
|---|
| 218 | begin | 
|---|
| 219 | Result := FPatientCount = 1; | 
|---|
| 220 | end; | 
|---|
| 221 |  | 
|---|
| 222 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 223 | //Name: function TfrmPCEBase.GetPatientViewed: Boolean; | 
|---|
| 224 | //Created: Jan 1999 | 
|---|
| 225 | //By: Robert Bott | 
|---|
| 226 | //Location: ISL | 
|---|
| 227 | //Description: returns false if the tab has never been clicked for this patient | 
|---|
| 228 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 229 | function TfrmPCEBase.GetPatientViewed: Boolean; | 
|---|
| 230 | begin | 
|---|
| 231 | Result := FPatientCount > 0; | 
|---|
| 232 | end; | 
|---|
| 233 | *) | 
|---|
| 234 | (* | 
|---|
| 235 | procedure RepaintControl(AControl: TControl); | 
|---|
| 236 | var | 
|---|
| 237 | i: Integer; | 
|---|
| 238 | begin | 
|---|
| 239 | AControl.Invalidate; | 
|---|
| 240 | AControl.Update; | 
|---|
| 241 | if AControl is TWinControl then with TWinControl(AControl) do | 
|---|
| 242 | for i := 0 to ControlCount - 1 do RepaintControl(Controls[i]); | 
|---|
| 243 | end; | 
|---|
| 244 | *) | 
|---|
| 245 |  | 
|---|
| 246 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 247 | //Name: procedure TfrmPCEBase.UMResizePage(var Message: TMessage); | 
|---|
| 248 | //Created: Jan 1999 | 
|---|
| 249 | //By: Robert Bott | 
|---|
| 250 | //Location: ISL | 
|---|
| 251 | //Description: Redraw the controls on the form when it is resized. | 
|---|
| 252 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 253 | procedure TfrmPCEBase.UMResizePage(var Message: TMessage); | 
|---|
| 254 | var | 
|---|
| 255 | i: Integer; | 
|---|
| 256 | begin | 
|---|
| 257 | for i := 0 to ComponentCount - 1 do | 
|---|
| 258 | if Components[i] is TControl then with TControl(Components[i]) do Invalidate; | 
|---|
| 259 | Update; | 
|---|
| 260 | end; | 
|---|
| 261 |  | 
|---|
| 262 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 263 | //Name: procedure TfrmPCEBase.btnCancelClick(Sender: TObject); | 
|---|
| 264 | //Created: Jan 1999 | 
|---|
| 265 | //By: Robert Bott | 
|---|
| 266 | //Location: ISL | 
|---|
| 267 | //Description: Indicate to the frame that cancel was pressed, and close the frame. | 
|---|
| 268 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 269 | procedure TfrmPCEBase.btnCancelClick(Sender: TObject); | 
|---|
| 270 | begin | 
|---|
| 271 | inherited; | 
|---|
| 272 | frmencounterframe.Abort := FALSE; | 
|---|
| 273 | frmEncounterFrame.Cancel := true; | 
|---|
| 274 | frmencounterframe.Close; | 
|---|
| 275 | end; | 
|---|
| 276 |  | 
|---|
| 277 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 278 | //Name: procedure TfrmPCEBase.btnCancelClick(Sender: TObject); | 
|---|
| 279 | //Created: Jan 1999 | 
|---|
| 280 | //By: Robert Bott | 
|---|
| 281 | //Location: ISL | 
|---|
| 282 | //Description: Indicate to the frame that it should close and save data. | 
|---|
| 283 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 284 | procedure TfrmPCEBase.btnOKClick(Sender: TObject); | 
|---|
| 285 | begin | 
|---|
| 286 | frmencounterframe.Abort := FALSE; | 
|---|
| 287 | frmencounterframe.Close; | 
|---|
| 288 | end; | 
|---|
| 289 |  | 
|---|
| 290 |  | 
|---|
| 291 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 292 | //Name: procedure TfrmPCEBase.FormClose(Sender: TObject; var Action: TCloseAction); | 
|---|
| 293 | //Created: Jan 1999 | 
|---|
| 294 | //By: Robert Bott | 
|---|
| 295 | //Location: ISL | 
|---|
| 296 | //Description: Free the memory held by the form. | 
|---|
| 297 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 298 | procedure TfrmPCEBase.FormClose(Sender: TObject; var Action: TCloseAction); | 
|---|
| 299 | begin | 
|---|
| 300 | inherited; | 
|---|
| 301 | action := caFree;    //destroy the forms when closed | 
|---|
| 302 | FClosing := TRUE; | 
|---|
| 303 | end; | 
|---|
| 304 |  | 
|---|
| 305 | {/////////////////////////////////////////////////////////////////////////////// | 
|---|
| 306 | //Name: procedure TfrmPCEBase.CheckListDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; | 
|---|
| 307 | //  State: TOwnerDrawState); | 
|---|
| 308 | //Created: Jan 1999 | 
|---|
| 309 | //By: Robert Bott | 
|---|
| 310 | //Location: ISL | 
|---|
| 311 | //Description: Populate the checklist | 
|---|
| 312 | ///////////////////////////////////////////////////////////////////////////////} | 
|---|
| 313 | procedure TfrmPCEBase.AllowTabChange(var AllowChange: boolean); | 
|---|
| 314 | begin | 
|---|
| 315 | end; | 
|---|
| 316 |  | 
|---|
| 317 | constructor TfrmPCEBase.CreateLinked(AParent: TWinControl); | 
|---|
| 318 | begin | 
|---|
| 319 | inherited Create(GetParentForm(AParent)); | 
|---|
| 320 | Parent := AParent; | 
|---|
| 321 | Align := alClient; | 
|---|
| 322 | Show; | 
|---|
| 323 | end; | 
|---|
| 324 |  | 
|---|
| 325 | function TfrmPCEBase.ActiveCtrl: TWinControl; | 
|---|
| 326 | begin | 
|---|
| 327 | Result := GetParentForm(Self).ActiveControl; | 
|---|
| 328 | if(Result is TORComboEdit) then | 
|---|
| 329 | Result := TWinControl(Result.Owner); | 
|---|
| 330 | end; | 
|---|
| 331 |  | 
|---|
| 332 | function TfrmPCEBase.SectionString: string; | 
|---|
| 333 | var | 
|---|
| 334 | v, i: integer; | 
|---|
| 335 |  | 
|---|
| 336 | begin | 
|---|
| 337 | Result := ''; | 
|---|
| 338 | if FSectionTabCount = 0 then exit; | 
|---|
| 339 | v := 0; | 
|---|
| 340 | for i := 0 to FSectionTabCount-1 do | 
|---|
| 341 | begin | 
|---|
| 342 | if(Result <> '') then | 
|---|
| 343 | Result := Result + ','; | 
|---|
| 344 | Result := Result + IntToStr(FSectionTabs[i]); | 
|---|
| 345 | v := FSectionTabs[i]; | 
|---|
| 346 | end; | 
|---|
| 347 | for i := 1 to 20 do | 
|---|
| 348 | begin | 
|---|
| 349 | if(v<0) then | 
|---|
| 350 | dec(v,32) | 
|---|
| 351 | else | 
|---|
| 352 | inc(v,32); | 
|---|
| 353 | if Result <> '' then Result := Result + ','; | 
|---|
| 354 | Result := Result + inttostr(v); | 
|---|
| 355 | end; | 
|---|
| 356 | end; | 
|---|
| 357 |  | 
|---|
| 358 | procedure TfrmPCEBase.DoEnter; | 
|---|
| 359 | begin | 
|---|
| 360 | inherited; | 
|---|
| 361 | frmEncounterFrame.SelectTab(FTabName); | 
|---|
| 362 | end; | 
|---|
| 363 |  | 
|---|
| 364 | procedure TfrmPCEBase.FocusFirstControl; | 
|---|
| 365 | begin | 
|---|
| 366 | //  SetFocus; | 
|---|
| 367 | FindNextControl(self, True, True, False).SetFocus; | 
|---|
| 368 | end; | 
|---|
| 369 |  | 
|---|
| 370 | procedure TfrmPCEBase.FormShow(Sender: TObject); | 
|---|
| 371 | begin | 
|---|
| 372 | inherited; | 
|---|
| 373 | FocusFirstControl; | 
|---|
| 374 | end; | 
|---|
| 375 |  | 
|---|
| 376 | end. | 
|---|