[459] | 1 | unit fPCEEdit;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | StdCtrls, ORFn, uPCE;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmPCEEdit = class(TForm)
|
---|
| 11 | btnNew: TButton;
|
---|
| 12 | btnNote: TButton;
|
---|
| 13 | lblNew: TMemo;
|
---|
| 14 | lblNote: TMemo;
|
---|
| 15 | btnCancel: TButton;
|
---|
| 16 | Label1: TStaticText;
|
---|
| 17 | procedure FormCreate(Sender: TObject);
|
---|
| 18 | private
|
---|
| 19 | { Private declarations }
|
---|
| 20 | public
|
---|
| 21 | { Public declarations }
|
---|
| 22 | end;
|
---|
| 23 |
|
---|
| 24 | function EditPCEData(NoteData: TPCEData): boolean;
|
---|
| 25 |
|
---|
| 26 | implementation
|
---|
| 27 |
|
---|
| 28 | uses uCore, rCore, fEncnt, fFrame, fEncounterFrame;
|
---|
| 29 |
|
---|
| 30 | {$R *.DFM}
|
---|
| 31 |
|
---|
| 32 | const
|
---|
| 33 | TX_NEED_VISIT2 = 'A visit is required before entering encounter information.';
|
---|
| 34 | TX_NOPCE_TXT1 = 'the encounter date is in the future.';
|
---|
| 35 | TX_NOPCE_TXT2 = 'encounter entry has been disabled.';
|
---|
| 36 | TX_NOPCE_TXT = 'You can not edit encounter information because ';
|
---|
| 37 | TX_NOPCE_HDR = 'Can not edit encounter';
|
---|
| 38 |
|
---|
| 39 | var
|
---|
| 40 | uPCETemp: TPCEData = nil;
|
---|
| 41 | uPCETempOld: TPCEData = nil;
|
---|
| 42 | uPatient: string = '';
|
---|
| 43 |
|
---|
| 44 | function EditPCEData(NoteData: TPCEData): boolean; // Returns TRUE if NoteData is edited
|
---|
| 45 | var
|
---|
| 46 | frmPCEEdit: TfrmPCEEdit;
|
---|
| 47 | BtnTxt, NewTxt, txt: string;
|
---|
| 48 | Ans: integer;
|
---|
| 49 |
|
---|
| 50 | begin
|
---|
| 51 | Result := FALSE;
|
---|
| 52 | if (Encounter.VisitCategory = 'H') then
|
---|
| 53 | begin
|
---|
| 54 | if Assigned(NoteData) then
|
---|
| 55 | Ans := mrNo
|
---|
| 56 | else
|
---|
| 57 | begin
|
---|
| 58 | InfoBox('Can not edit admission encounter', 'Error', MB_OK or MB_ICONERROR);
|
---|
| 59 | Ans := mrCancel;
|
---|
| 60 | end;
|
---|
| 61 | end
|
---|
| 62 | else
|
---|
| 63 | if not Assigned(NoteData) then
|
---|
| 64 | Ans := mrYes
|
---|
| 65 | else
|
---|
| 66 | if (NoteData.VisitString = Encounter.VisitStr) then
|
---|
| 67 | Ans := mrNo
|
---|
| 68 | else
|
---|
| 69 | begin
|
---|
| 70 | frmPCEEdit := TfrmPCEEdit.Create(Application);
|
---|
| 71 | try
|
---|
| 72 | if Encounter.NeedVisit then
|
---|
| 73 | begin
|
---|
| 74 | NewTxt := 'Create New Encounter';
|
---|
| 75 | BtnTxt := 'New Encounter';
|
---|
| 76 | end
|
---|
| 77 | else
|
---|
| 78 | begin
|
---|
| 79 | NewTxt := 'Edit Encounter for ' + Encounter.LocationName + ' on ' +
|
---|
| 80 | FormatFMDateTime('mmm dd yyyy hh:nn', Encounter.DateTime);
|
---|
| 81 | BtnTxt := 'Edit Current Encounter';
|
---|
| 82 | end;
|
---|
| 83 | frmPCEEdit.lblNew.Text := NewTxt;
|
---|
| 84 | frmPCEEdit.btnNew.Caption := BtnTxt;
|
---|
| 85 | frmPCEEdit.lblNote.Text := 'Edit Note Encounter for ' + ExternalName(NoteData.Location, 44) + ' on ' +
|
---|
| 86 | FormatFMDateTime('mmm dd yyyy hh:nn', NoteData.VisitDateTime);
|
---|
| 87 | ans := frmPCEEdit.ShowModal;
|
---|
| 88 | finally
|
---|
| 89 | frmPCEEdit.Free;
|
---|
| 90 | end;
|
---|
| 91 | end;
|
---|
| 92 | if ans = mrYes then
|
---|
| 93 | begin
|
---|
| 94 | if Encounter.NeedVisit then
|
---|
| 95 | begin
|
---|
| 96 | UpdateVisit(8);
|
---|
| 97 | frmFrame.DisplayEncounterText;
|
---|
| 98 | end;
|
---|
| 99 | if Encounter.NeedVisit then
|
---|
| 100 | begin
|
---|
| 101 | InfoBox(TX_NEED_VISIT2, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
|
---|
| 102 | Exit;
|
---|
| 103 | end;
|
---|
| 104 | if not assigned(uPCETemp) then
|
---|
| 105 | uPCETemp := TPCEData.Create;
|
---|
| 106 | uPCETemp.UseEncounter := True;
|
---|
| 107 | if not CanEditPCE(uPCETemp) then
|
---|
| 108 | begin
|
---|
| 109 | if FutureEncounter(uPCETemp) then
|
---|
| 110 | txt := TX_NOPCE_TXT1
|
---|
| 111 | else
|
---|
| 112 | txt := TX_NOPCE_TXT2;
|
---|
| 113 | InfoBox(TX_NOPCE_TXT + txt, TX_NOPCE_HDR, MB_OK or MB_ICONWARNING);
|
---|
| 114 | Exit;
|
---|
| 115 | end;
|
---|
| 116 | uPCETemp.PCEForNote(USE_CURRENT_VISITSTR, uPCETempOld);
|
---|
| 117 | UpdatePCE(uPCETemp);
|
---|
| 118 | if not assigned(uPCETempOld) then
|
---|
| 119 | uPCETempOld := TPCEData.Create;
|
---|
| 120 | uPCETemp.CopyPCEData(uPCETempOld);
|
---|
| 121 | end
|
---|
| 122 | else
|
---|
| 123 | if ans = mrNo then
|
---|
| 124 | begin
|
---|
| 125 | UpdatePCE(NoteData);
|
---|
| 126 | Result := TRUE;
|
---|
| 127 | end;
|
---|
| 128 | end;
|
---|
| 129 |
|
---|
| 130 | procedure TfrmPCEEdit.FormCreate(Sender: TObject);
|
---|
| 131 | begin
|
---|
| 132 | if uPatient <> Patient.DFN then
|
---|
| 133 | begin
|
---|
| 134 | KillObj(@uPCETemp);
|
---|
| 135 | KillObj(@uPCETempOld);
|
---|
| 136 | end;
|
---|
| 137 | uPatient := Patient.DFN;
|
---|
| 138 | end;
|
---|
| 139 |
|
---|
| 140 | initialization
|
---|
| 141 |
|
---|
| 142 | finalization
|
---|
| 143 | KillObj(@uPCETemp);
|
---|
| 144 | KillObj(@uPCETempOld);
|
---|
| 145 | uPatient := '';
|
---|
| 146 |
|
---|
| 147 | end.
|
---|