1 | unit fPCEEdit;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | StdCtrls, ORFn, uPCE, fBase508Form, VA508AccessibilityManager;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmPCEEdit = class(TfrmBase508Form)
|
---|
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 | (* agp moved from FormCreate to addrss a problem with editing an encounter without a note displaying in CPRS*)
|
---|
53 | if uPatient <> Patient.DFN then
|
---|
54 | begin
|
---|
55 | KillObj(@uPCETemp);
|
---|
56 | KillObj(@uPCETempOld);
|
---|
57 | end;
|
---|
58 | uPatient := Patient.DFN;
|
---|
59 | if (Encounter.VisitCategory = 'H') then
|
---|
60 | begin
|
---|
61 | if Assigned(NoteData) then
|
---|
62 | Ans := mrNo
|
---|
63 | else
|
---|
64 | begin
|
---|
65 | InfoBox('Can not edit admission encounter', 'Error', MB_OK or MB_ICONERROR);
|
---|
66 | Ans := mrCancel;
|
---|
67 | end;
|
---|
68 | end
|
---|
69 | else
|
---|
70 | if not Assigned(NoteData) then
|
---|
71 | Ans := mrYes
|
---|
72 | else
|
---|
73 | if (NoteData.VisitString = Encounter.VisitStr) then
|
---|
74 | Ans := mrNo
|
---|
75 | else
|
---|
76 | begin
|
---|
77 | frmPCEEdit := TfrmPCEEdit.Create(Application);
|
---|
78 | try
|
---|
79 | if Encounter.NeedVisit then
|
---|
80 | begin
|
---|
81 | NewTxt := 'Create New Encounter';
|
---|
82 | BtnTxt := 'New Encounter';
|
---|
83 | end
|
---|
84 | else
|
---|
85 | begin
|
---|
86 | NewTxt := 'Edit Encounter for ' + Encounter.LocationName + ' on ' +
|
---|
87 | FormatFMDateTime('mmm dd yyyy hh:nn', Encounter.DateTime);
|
---|
88 | BtnTxt := 'Edit Current Encounter';
|
---|
89 | end;
|
---|
90 | frmPCEEdit.lblNew.Text := NewTxt;
|
---|
91 | frmPCEEdit.btnNew.Caption := BtnTxt;
|
---|
92 | frmPCEEdit.lblNote.Text := 'Edit Note Encounter for ' + ExternalName(NoteData.Location, 44) + ' on ' +
|
---|
93 | FormatFMDateTime('mmm dd yyyy hh:nn', NoteData.VisitDateTime);
|
---|
94 | ans := frmPCEEdit.ShowModal;
|
---|
95 | finally
|
---|
96 | frmPCEEdit.Free;
|
---|
97 | end;
|
---|
98 | end;
|
---|
99 | if ans = mrYes then
|
---|
100 | begin
|
---|
101 | if Encounter.NeedVisit then
|
---|
102 | begin
|
---|
103 | UpdateVisit(8);
|
---|
104 | frmFrame.DisplayEncounterText;
|
---|
105 | end;
|
---|
106 | if Encounter.NeedVisit then
|
---|
107 | begin
|
---|
108 | InfoBox(TX_NEED_VISIT2, TX_NO_VISIT, MB_OK or MB_ICONWARNING);
|
---|
109 | Exit;
|
---|
110 | end;
|
---|
111 | if not assigned(uPCETemp) then
|
---|
112 | uPCETemp := TPCEData.Create;
|
---|
113 | uPCETemp.UseEncounter := True;
|
---|
114 | if not CanEditPCE(uPCETemp) then
|
---|
115 | begin
|
---|
116 | if FutureEncounter(uPCETemp) then
|
---|
117 | txt := TX_NOPCE_TXT1
|
---|
118 | else
|
---|
119 | txt := TX_NOPCE_TXT2;
|
---|
120 | InfoBox(TX_NOPCE_TXT + txt, TX_NOPCE_HDR, MB_OK or MB_ICONWARNING);
|
---|
121 | Exit;
|
---|
122 | end;
|
---|
123 | uPCETemp.PCEForNote(USE_CURRENT_VISITSTR, uPCETempOld);
|
---|
124 | UpdatePCE(uPCETemp);
|
---|
125 | if not assigned(uPCETempOld) then
|
---|
126 | uPCETempOld := TPCEData.Create;
|
---|
127 | uPCETemp.CopyPCEData(uPCETempOld);
|
---|
128 | end
|
---|
129 | else
|
---|
130 | if ans = mrNo then
|
---|
131 | begin
|
---|
132 | UpdatePCE(NoteData);
|
---|
133 | Result := TRUE;
|
---|
134 | end;
|
---|
135 | end;
|
---|
136 |
|
---|
137 | procedure TfrmPCEEdit.FormCreate(Sender: TObject);
|
---|
138 | begin
|
---|
139 | (* agp moved to EditPCEData procedure to addrss a problem
|
---|
140 | with editing an encounter without a note displaying in CPRS
|
---|
141 | if uPatient <> Patient.DFN then
|
---|
142 | begin
|
---|
143 | KillObj(@uPCETemp);
|
---|
144 | KillObj(@uPCETempOld);
|
---|
145 | end;
|
---|
146 | uPatient := Patient.DFN; *)
|
---|
147 | end;
|
---|
148 |
|
---|
149 | initialization
|
---|
150 |
|
---|
151 | finalization
|
---|
152 | KillObj(@uPCETemp);
|
---|
153 | KillObj(@uPCETempOld);
|
---|
154 | uPatient := '';
|
---|
155 |
|
---|
156 | end.
|
---|