source: cprs/branches/HealthSevak-CPRS/CPRS-Chart/Encounter/fPCEEdit.pas@ 1722

Last change on this file since 1722 was 1693, checked in by healthsevak, 9 years ago

Committing the files for first time to this new branch

File size: 4.0 KB
RevLine 
[456]1unit fPCEEdit;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
[829]7 StdCtrls, ORFn, uPCE, fBase508Form, VA508AccessibilityManager;
[456]8
9type
[829]10 TfrmPCEEdit = class(TfrmBase508Form)
[456]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
24function EditPCEData(NoteData: TPCEData): boolean;
25
26implementation
27
28uses uCore, rCore, fEncnt, fFrame, fEncounterFrame;
29
30{$R *.DFM}
31
32const
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
39var
40 uPCETemp: TPCEData = nil;
41 uPCETempOld: TPCEData = nil;
42 uPatient: string = '';
43
44function EditPCEData(NoteData: TPCEData): boolean; // Returns TRUE if NoteData is edited
45var
46 frmPCEEdit: TfrmPCEEdit;
47 BtnTxt, NewTxt, txt: string;
48 Ans: integer;
49
50begin
51 Result := FALSE;
[1693]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;
[456]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;
135end;
136
137procedure TfrmPCEEdit.FormCreate(Sender: TObject);
138begin
[1693]139 (* agp moved to EditPCEData procedure to addrss a problem
140 with editing an encounter without a note displaying in CPRS
[456]141 if uPatient <> Patient.DFN then
142 begin
143 KillObj(@uPCETemp);
144 KillObj(@uPCETempOld);
145 end;
[1693]146 uPatient := Patient.DFN; *)
[456]147end;
148
149initialization
150
151finalization
152 KillObj(@uPCETemp);
153 KillObj(@uPCETempOld);
154 uPatient := '';
155
156end.
Note: See TracBrowser for help on using the repository browser.