source: cprs/branches/tmg-cprs/CPRS-Chart/Encounter/fPCEEdit.pas@ 1248

Last change on this file since 1248 was 453, checked in by Kevin Toppenberg, 16 years ago

Initial upload of TMG-CPRS 1.0.26.69

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