source: cprs/branches/tmg-cprs/CPRS-Chart/fDCSummProps.pas@ 1482

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 23.1 KB
Line 
1//kt -- Modified with SourceScanner on 7/15/2007
2unit fDCSummProps;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 StdCtrls, ORDtTm, ORCtrls, ExtCtrls, uConst, rTIU, rDCSumm, uDocTree, uDCSumm, uTIU,
9 DKLang;
10
11type
12 TfrmDCSummProperties = class(TForm)
13 bvlConsult: TBevel;
14 pnlFields: TORAutoPanel;
15 lblNewTitle: TLabel;
16 lblDateTime: TLabel;
17 lblAuthor: TLabel;
18 lblCosigner: TLabel;
19 cboNewTitle: TORComboBox;
20 calSumm: TORDateBox;
21 cboAuthor: TORComboBox;
22 cboAttending: TORComboBox;
23 pnlTranscription: TORAutoPanel;
24 lblTranscriptionist: TLabel;
25 lblUrgency: TLabel;
26 cboTranscriptionist: TORComboBox;
27 cboUrgency: TORComboBox;
28 pnlAdmissions: TORAutoPanel;
29 cmdOK: TButton;
30 cmdCancel: TButton;
31 pnlLabels: TORAutoPanel;
32 lblDCSumm1: TStaticText;
33 lblDCSumm2: TStaticText;
34 lblLocation: TLabel;
35 lblDate: TLabel;
36 lblType: TLabel;
37 lblSummStatus: TLabel;
38 lstAdmissions: TORListBox;
39 DKLanguageController1: TDKLanguageController;
40 procedure FormShow(Sender: TObject);
41 procedure cboNewTitleNeedData(Sender: TObject; const StartFrom: String;
42 Direction, InsertAt: Integer);
43 procedure cboAuthorNeedData(Sender: TObject; const StartFrom: String;
44 Direction, InsertAt: Integer);
45 procedure cboAttendingNeedData(Sender: TObject; const StartFrom: String;
46 Direction, InsertAt: Integer);
47 procedure cmdOKClick(Sender: TObject);
48 procedure cmdCancelClick(Sender: TObject);
49 procedure cboNewTitleExit(Sender: TObject);
50 procedure cboNewTitleMouseClick(Sender: TObject);
51 procedure cboNewTitleEnter(Sender: TObject);
52 procedure cboAttendingExit(Sender: TObject);
53 procedure cboAuthorExit(Sender: TObject);
54 procedure cboAuthorMouseClick(Sender: TObject);
55 procedure cboAuthorEnter(Sender: TObject);
56 procedure cboNewTitleDropDownClose(Sender: TObject);
57 procedure lstAdmissionsChange(Sender: TObject);
58 procedure cboNewTitleDblClick(Sender: TObject);
59 procedure FormClose(Sender: TObject; var Action: TCloseAction);
60 private
61 //kt Begin Mod (change Consts to Vars) 7/15/2007
62 TC_REQ_FIELDS : string; //kt
63 TX_REQ_TITLE : string; //kt
64 TX_REQ_AUTHOR : string; //kt
65 TX_REQ_REFDATE : string; //kt
66 TX_REQ_COSIGNER : string; //kt
67 TX_NO_FUTURE : string; //kt
68 TX_COS_SELF : string; //kt
69 TX_COS_AUTH : string; //kt
70 TX_BAD_ADMISSION : string; //kt
71 TX_NO_ADMISSION : string; //kt
72 TX_NO_MORE_SUMMS : string; //kt
73 TC_NO_EDIT : string; //kt
74 TC_EDIT_EXISTING : string; //kt
75 TX_EDIT_EXISTING : string; //kt
76 //kt End Mod -------------------
77 FCosignIEN: Int64; // store cosigner that was passed in
78 FCosignName: string; // store cosigner that was passed in
79 FDocType: Integer; // store document type that was passed in
80 FAddend: Integer; // store IEN of note being addended (if make addendum)
81 FLastAuthor: Int64; // set by mouseclick to avoid redundant call on exit
82 FLastTitle: Integer; // set by mouseclick to avoid redundant call on exit
83 FAdmitDateTime: string ;
84 FLocation: integer;
85 FLocationName: string;
86 FVisitStr: string;
87 FEditIEN: integer;
88 //FFixCursor: Boolean; // to fix the problem where the list box is an I-bar
89 FLastCosigner: Int64; // holds cosigner from previous note (for defaulting)
90 FLastCosignerName: string; // holds cosigner from previous note (for defaulting)
91 FShowAdmissions: Boolean;
92 FIDNoteTitlesOnly: boolean;
93 procedure SetCosignerRequired;
94 procedure ShowAdmissionList;
95 procedure UMDelayEvent(var Message: TMessage); message UM_DELAYEVENT;
96 procedure SetupVars; //kt 7-15-07
97 public
98 { Public declarations }
99 end;
100
101function ExecuteDCSummProperties(var ASumm: TEditDCSummRec; var ListBoxItem: string; ShowAdmissions, IDNoteTitlesOnly: boolean): Boolean;
102
103var
104 EditLines: TStringList;
105
106implementation
107
108{$R *.DFM}
109
110uses ORFn, uCore, rCore, uPCE, rPCE, rMisc;
111{ Initial values in ASumm
112
113 Title Type Author DateTime Cosigner Location Consult NeedCPT
114 New DCSumm dflt 244 DUZ NOW dflt Encnt 0 ?
115 Edit DCSumm ien 244 ien DtTm ien ien ien fld
116 Addend DCSumm ien 81 DUZ NOW 0 N/A N/A? no
117
118 New Summ - setup as much as possible, then call ExecuteDCSummProperties if necessary.
119
120}
121
122//const
123//TC_REQ_FIELDS = 'Required Information'; <-- original line. //kt 7/15/2007
124//TX_REQ_TITLE = CRLF + 'A title must be selected.'; <-- original line. //kt 7/15/2007
125//TX_REQ_AUTHOR = CRLF + 'The author of the note must be identified.'; <-- original line. //kt 7/15/2007
126//TX_REQ_REFDATE = CRLF + 'A valid date/time for the note must be entered.'; <-- original line. //kt 7/15/2007
127//TX_REQ_COSIGNER = CRLF + 'An attending must be identified.'; <-- original line. //kt 7/15/2007
128//TX_NO_FUTURE = CRLF + 'A reference date/time in the future is not allowed.'; <-- original line. //kt 7/15/2007
129//TX_COS_SELF = CRLF + 'You cannot make yourself a cosigner.'; <-- original line. //kt 7/15/2007
130//TX_COS_AUTH = CRLF + ' is not authorized to cosign this document.'; <-- original line. //kt 7/15/2007
131//TX_BAD_ADMISSION = CRLF + 'Admission information is missing or invalid.'; <-- original line. //kt 7/15/2007
132//TX_NO_ADMISSION = CRLF + 'An admission must be selected'; <-- original line. //kt 7/15/2007
133//TX_NO_MORE_SUMMS = CRLF + 'Only one discharge summary may be written for each admission.'; <-- original line. //kt 7/15/2007
134//TC_NO_EDIT = 'Unable to Edit'; <-- original line. //kt 7/15/2007
135//TC_EDIT_EXISTING = 'Unsigned document in progress'; <-- original line. //kt 7/15/2007
136//TX_EDIT_EXISTING = 'Would you like to continue editing the existing unsigned summary for this admission?'; <-- original line. //kt 7/15/2007
137
138
139
140procedure TfrmDCSummProperties.SetupVars;
141//kt Added entire function to replace constant declarations 7/15/2007
142begin
143 TC_REQ_FIELDS := DKLangConstW('fDCSummProps_Required_Information');
144 TX_REQ_TITLE := CRLF + DKLangConstW('fDCSummProps_A_title_must_be_selected');
145 TX_REQ_AUTHOR := CRLF + DKLangConstW('fDCSummProps_The_author_of_the_note_must_be_identified');
146 TX_REQ_REFDATE := CRLF + DKLangConstW('fDCSummProps_A_valid_datetime_for_the_note_must_be_entered');
147 TX_REQ_COSIGNER := CRLF + DKLangConstW('fDCSummProps_An_attending_must_be_identified');
148 TX_NO_FUTURE := CRLF + DKLangConstW('fDCSummProps_A_reference_datetime_in_the_future_is_not_allowed');
149 TX_COS_SELF := CRLF + DKLangConstW('fDCSummProps_You_cannot_make_yourself_a_cosigner');
150 TX_COS_AUTH := CRLF + DKLangConstW('fDCSummProps_is_not_authorized_to_cosign_this_document');
151 TX_BAD_ADMISSION := CRLF + DKLangConstW('fDCSummProps_Admission_information_is_missing_or_invalid');
152 TX_NO_ADMISSION := CRLF + DKLangConstW('fDCSummProps_An_admission_must_be_selected');
153 TX_NO_MORE_SUMMS := CRLF + DKLangConstW('fDCSummProps_Only_one_discharge_summary_may_be_written_for_each_admission');
154 TC_NO_EDIT := DKLangConstW('fDCSummProps_Unable_to_Edit');
155 TC_EDIT_EXISTING := DKLangConstW('fDCSummProps_Unsigned_document_in_progress');
156 TX_EDIT_EXISTING := DKLangConstW('fDCSummProps_Would_you_like_to_continue_editing_the_existing_unsigned_summary_for_this_admission');
157end;
158
159function ExecuteDCSummProperties(var ASumm: TEditDCSummRec; var ListBoxItem: string; ShowAdmissions, IDNoteTitlesOnly: boolean): Boolean;
160var
161 frmDCSummProperties: TfrmDCSummProperties;
162 x: string;
163begin
164 frmDCSummProperties := TfrmDCSummProperties.Create(Application);
165 EditLines := TStringList.Create;
166 try
167 ResizeAnchoredFormToFont(frmDCSummProperties);
168 with frmDCSummProperties do
169 begin
170 // setup common fields (title, reference date, author)
171 FShowAdmissions := ShowAdmissions;
172 FIDNoteTitlesOnly := IDNoteTitlesOnly;
173 pnlTranscription.Visible := False; {was never used on old form}
174 if not pnlTranscription.Visible then
175 begin
176 Height := Height - pnlTranscription.Height;
177 Top := Top - pnlTranscription.Height;
178 end;
179 Height := Height - pnlAdmissions.Height - pnlLabels.Height;
180 if ASumm.DocType <> TYP_ADDENDUM then
181 begin
182 cboNewTitle.InitLongList('');
183 ListDCSummTitlesShort(cboNewTitle.Items);
184 end
185 else //if addendum
186 cboNewTitle.Items.Insert(0, IntToStr(ASumm.Title) + U + ASumm.TitleName);
187 if ASumm.Title > 0 then cboNewTitle.SelectByIEN(ASumm.Title);
188 if (ASumm.Title > 0) and (cboNewTitle.ItemIndex < 0)
189 then cboNewTitle.SetExactByIEN(ASumm.Title, ASumm.TitleName);
190 cboAuthor.InitLongList(ASumm.DictatorName);
191 if ASumm.Dictator > 0 then cboAuthor.SelectByIEN(ASumm.Dictator);
192 cboUrgency.Items.Assign(LoadDCUrgencies);
193 cboUrgency.SelectByID('R');
194 if Asumm.Attending = 0 then
195 begin
196 ASumm.Attending := FLastCosigner;
197 ASumm.AttendingName := FLastCosignerName;
198 end;
199 cboAttending.InitLongList(ASumm.AttendingName);
200 if ASumm.Attending > 0 then cboAttending.SelectByIEN(ASumm.Attending);
201 calSumm.FMDateTime := ASumm.DictDateTime;
202 if FShowAdmissions then ShowAdmissionList;
203 FAddend := ASumm.Addend;
204 FDocType := ASumm.DocType;
205 FLastCosigner := ASumm.LastCosigner;
206 FLastCosignerName := ASumm.LastCosignerName;
207 FEditIEN := 0;
208 // restrict edit of title if addendum
209 if FDocType = TYP_ADDENDUM then
210 begin
211// lblNewTitle.Caption := 'Addendum to:'; <-- original line. //kt 7/15/2007
212 lblNewTitle.Caption := DKLangConstW('fDCSummProps_Addendum_to'); //kt added 7/15/2007
213// cboNewTitle.Caption := 'Addendum to:'; <-- original line. //kt 7/15/2007
214 cboNewTitle.Caption := DKLangConstW('fDCSummProps_Addendum_to'); //kt added 7/15/2007
215 cboNewTitle.Enabled := False;
216 cboNewTitle.Color := clBtnFace;
217 end;
218 Result := ShowModal = idOK; // display the form
219 if Result then with ASumm do
220 begin
221 if FDocType <> TYP_ADDENDUM then
222 begin
223 Title := cboNewTitle.ItemIEN;
224 TitleName := PrintNameForTitle(Title);
225 end;
226 Urgency := cboUrgency.ItemID;
227 DictDateTime := calSumm.FMDateTime;
228 Dictator := cboAuthor.ItemIEN;
229 DictatorName := Piece(cboAuthor.Items[cboAuthor.ItemIndex], U, 2);
230 Attending := cboAttending.ItemIEN;
231 AttendingName := Piece(cboAttending.Items[cboAttending.ItemIndex], U, 2);
232 if Attending = Dictator then Cosigner := 0 else
233 begin
234 Cosigner := cboAttending.ItemIEN;
235 CosignerName := Piece(cboAttending.Items[cboAttending.ItemIndex], U, 2);
236 // The LastCosigner fields are used to default the cosigner in subsequent notes.
237 // These fields are not reset with new notes & not passed into TIU.
238 LastCosigner := Cosigner;
239 LastCosignerName := CosignerName;
240 end;
241 Transcriptionist := cboTranscriptionist.ItemIEN;
242 if FShowAdmissions then
243 begin
244 AdmitDateTime := StrToFMDateTime(FAdmitDateTime);
245 DischargeDateTime := StrToFMDateTime(GetDischargeDate(Patient.DFN, FAdmitDateTime));
246 if DischargeDateTime <= 0 then DischargeDateTime := FMNow;
247 Location := FLocation;
248 LocationName := FLocationName;
249 VisitStr := IntToStr(Location) + ';' + FloatToStr(AdmitDateTime) + ';H' ;
250 end;
251 EditIEN := FEditIEN;
252 if FEditIEN > 0 then
253 begin
254 x := GetTIUListItem(FEditIEN);
255 ListBoxItem := x;
256 if Lines = nil then Lines := TStringList.Create;
257 Lines.Assign(EditLines);
258 end
259 else
260 begin
261 ListBoxItem := '';
262 end;
263 end;
264 // The following fields in TEditDCSummRec are not set:
265 // DocType, NeedCPT, Lines (unless editing an existing summary)
266 end;
267 finally
268 EditLines.Free;
269 frmDCSummProperties.Release;
270 end;
271end;
272
273{ Form events }
274
275procedure TfrmDCSummProperties.FormShow(Sender: TObject);
276begin
277 SetFormPosition(Self);
278 //if cboNewTitle.Text = '' then PostMessage(Handle, UM_DELAYEVENT, 0, 0);
279end;
280
281procedure TfrmDCSummProperties.UMDelayEvent(var Message: TMessage);
282{ let the window finish displaying before dropping list box, otherwise listbox drop
283 in the design position rather then new windows position (ORCtrls bug?) }
284begin
285(* Screen.Cursor := crArrow;
286 FFixCursor := TRUE;
287 cboNewTitle.DroppedDown := True;
288 lblDateTime.Visible := False;
289 lblAuthor.Visible := False;
290 lblCosigner.Visible := False;*)
291end;
292
293{ General calls }
294
295procedure TfrmDCSummProperties.SetCosignerRequired;
296{ called initially & whenever title or author changes }
297begin
298(* if FDocType = TYP_ADDENDUM then
299 begin
300 lblCosigner.Visible := AskCosignerForDocument(FAddend, cboAuthor.ItemIEN)
301 end else
302 begin
303 if cboNewTitle.ItemIEN = 0
304 then lblCosigner.Visible := AskCosignerForTitle(FDocType, cboAuthor.ItemIEN)
305 else lblCosigner.Visible := AskCosignerForTitle(cboNewTitle.ItemIEN, cboAuthor.ItemIEN);
306 end;*)
307 lblCosigner.Visible := True;
308 cboAttending.Visible := lblCosigner.Visible;
309end;
310
311procedure TfrmDCSummProperties.ShowAdmissionList;
312var
313 i, Status: integer;
314 x: string;
315begin
316 with lstAdmissions do
317 begin
318 ListAdmitAll(Items, Patient.DFN);
319 if Items.Count > 0 then
320 begin
321 for i := 0 to Items.Count-1 do
322 begin
323 x := Items[i];
324// SetPiece(x, '^', 8, FormatFMDateTimeStr('mmm dd,yyyy hh:nn', Piece(Items[i],U,1))); <-- original line. //kt 7/15/2007
325 SetPiece(x, '^', 8, FormatFMDateTimeStr(DKLangConstW('fDCSummProps_mmm_ddyyyy__hhnn'), Piece(Items[i],U,1))); //kt added 7/15/2007
326 Status := StrToIntDef(Piece(Items[i],U,7),0);
327 case Status of
328// 0: x := x + '^None on file'; <-- original line. //kt 7/15/2007
329 0: x := x + '^'+DKLangConstW('fDCSummProps_None_on_file'); //kt added 7/15/2007
330// 1: x := x + '^Completed'; <-- original line. //kt 7/15/2007
331 1: x := x + '^'+DKLangConstW('fDCSummProps_Completed'); //kt added 7/15/2007
332// 2: x := x + '^Unsigned'; <-- original line. //kt 7/15/2007
333 2: x := x + '^'+DKLangConstW('fDCSummProps_Unsigned'); //kt added 7/15/2007
334 end;
335 Items[i] := x;
336 end;
337 end
338 else
339// FAdmitDateTime := '-1^No admissions were found for this patient.'; <-- original line. //kt 7/15/2007
340 FAdmitDateTime := '-1^'+DKLangConstW('fDCSummProps_No_admissions_were_found_for_this_patient'); //kt added 7/15/2007
341 end;
342end;
343
344{ cboNewTitle events }
345
346procedure TfrmDCSummProperties.cboNewTitleNeedData(Sender: TObject; const StartFrom: string;
347 Direction, InsertAt: Integer);
348begin
349 cboNewTitle.ForDataUse(SubSetOfDCSummTitles(StartFrom, Direction, FIDNoteTitlesOnly));
350end;
351
352procedure TfrmDCSummProperties.cboNewTitleEnter(Sender: TObject);
353begin
354 FLastTitle := 0;
355end;
356
357procedure TfrmDCSummProperties.cboNewTitleMouseClick(Sender: TObject);
358begin
359 with cboNewTitle do
360 if (ItemIEN > 0) and (ItemIEN = FLastTitle) then Exit
361 else if ItemIEN = 0 then
362 begin
363 if FLastTitle > 0 then SelectByIEN(FLastTitle)
364 else ItemIndex := -1;
365 Exit;
366 end;
367 SetCosignerRequired;
368 if FShowAdmissions and (not pnlAdmissions.Visible) then
369 begin
370 Height := Height + pnlAdmissions.Height + pnlLabels.Height;
371 pnlAdmissions.Visible := True;
372 pnlLabels.Visible := True;
373 end;
374 FLastTitle := cboNewTitle.ItemIEN;
375end;
376
377procedure TfrmDCSummProperties.cboNewTitleExit(Sender: TObject);
378begin
379 if cboNewTitle.ItemIEN <> FLastTitle then cboNewTitleMouseClick(Self);
380end;
381
382{ cboAuthor & cboAttending events }
383
384procedure TfrmDCSummProperties.cboAuthorNeedData(Sender: TObject; const StartFrom: String;
385 Direction, InsertAt: Integer);
386begin
387 (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
388end;
389
390procedure TfrmDCSummProperties.cboAttendingNeedData(Sender: TObject; const StartFrom: String;
391 Direction, InsertAt: Integer);
392begin // changed in v15.2, per BRX-1100-10981
393// (Sender as TORComboBox).ForDataUse(SubSetOfPersons(StartFrom, Direction));
394 (Sender as TORComboBox).ForDataUse(SubSetOfProviders(StartFrom, Direction));
395end;
396
397procedure TfrmDCSummProperties.cboAuthorEnter(Sender: TObject);
398begin
399 FLastAuthor := 0;
400end;
401
402procedure TfrmDCSummProperties.cboAuthorMouseClick(Sender: TObject);
403begin
404 SetCosignerRequired;
405 FLastAuthor := cboAuthor.ItemIEN;
406end;
407
408procedure TfrmDCSummProperties.cboAuthorExit(Sender: TObject);
409begin
410 if cboAuthor.ItemIEN <> FLastAuthor then cboAuthorMouseClick(Self);
411end;
412
413procedure TfrmDCSummProperties.cboAttendingExit(Sender: TObject);
414{ make sure FCosign fields stay up to date in case SetCosigner gets called again }
415begin
416 with cboAttending do if Text = '' then ItemIndex := -1;
417 FCosignIEN := cboAttending.ItemIEN;
418 FCosignName := Piece(cboAttending.Items[cboAttending.ItemIndex], U, 2);
419end;
420
421{ Command Button events }
422
423procedure TfrmDCSummProperties.cmdOKClick(Sender: TObject);
424var
425 ErrMsg, x, WhyNot: string;
426begin
427 SetupVars; //kt added 7/15/2007 to replace constants with vars.
428 cmdOK.SetFocus; // make sure cbo exit events fire
429 Application.ProcessMessages;
430 SetCosignerRequired;
431 ErrMsg := '';
432 if cboNewTitle.ItemIEN = 0 then
433 ErrMsg := ErrMsg + TX_REQ_TITLE
434 else if FIDNoteTitlesOnly and (not CanTitleBeIDChild(cboNewTitle.ItemIEN, WhyNot)) then
435 ErrMsg := ErrMsg + CRLF + WhyNot;
436 if cboAuthor.ItemIEN = 0 then ErrMsg := ErrMsg + TX_REQ_AUTHOR;
437 if not calSumm.IsValid then ErrMsg := ErrMsg + TX_REQ_REFDATE;
438 if calSumm.IsValid and (calSumm.FMDateTime > FMNow) then ErrMsg := ErrMsg + TX_NO_FUTURE;
439 if cboAttending.Visible and (cboAttending.ItemIEN = 0) then ErrMsg := ErrMsg + TX_REQ_COSIGNER;
440 //if cboAttending.ItemIEN = User.DUZ then ErrMsg := TX_COS_SELF;
441 if (cboAttending.ItemIEN > 0) and not IsUserAProvider(cboAttending.ItemIEN, FMNow) then
442 //if (cboAttending.ItemIEN > 0) and not CanCosign(cboNewTitle.ItemIEN, FDocType, cboAttending.ItemIEN) then
443 ErrMsg := cboAttending.Text + TX_COS_AUTH;
444 if pnlAdmissions.Visible then
445 with lstAdmissions do
446 begin
447 if ItemIndex < 0 then
448 ErrMsg := TX_NO_ADMISSION
449 else if (Piece(x, U, 7) = '1') then
450 begin
451 x := Items[ItemIndex];
452 FVisitStr := Piece(x, U, 2) + ';' + Piece(x, U, 1) + ';H';
453 if (OneNotePerVisit(cboNewTitle.ItemIEN, Patient.DFN, FVisitStr)) then
454 begin
455 FEditIEN := 0;
456 InfoBox(TX_NO_MORE_SUMMS, TC_NO_EDIT, MB_OK);
457 lstAdmissions.ItemIndex := -1;
458 end;
459 end
460 else
461 begin
462 x := Items[ItemIndex];
463 FAdmitDateTime := Piece(x,U,1);
464 FLocation := StrToIntDef(Piece(x, U, 2), 0);
465 if (MakeFMDateTime(FAdmitDateTime)= -1) or (FLocation = 0) then
466 ErrMsg := TX_BAD_ADMISSION
467 else
468 FLocationName := ExternalName(FLocation, 44);
469 end;
470 end;
471
472 if ShowMsgOn(Length(ErrMsg) > 0, ErrMsg, TC_REQ_FIELDS)
473 then Exit
474 else ModalResult := mrOK;
475end;
476
477procedure TfrmDCSummProperties.cmdCancelClick(Sender: TObject);
478begin
479 ModalResult := mrCancel;
480 Close;
481end;
482
483procedure TfrmDCSummProperties.cboNewTitleDropDownClose(Sender: TObject);
484begin
485(* if FFixCursor then
486 begin
487 Screen.Cursor := crDefault;
488 FFixCursor := FALSE;
489 end;
490 lblDateTime.Visible := True;
491 lblAuthor.Visible := True;
492 lblCosigner.Visible := True;*)
493end;
494
495procedure TfrmDCSummProperties.lstAdmissionsChange(Sender: TObject);
496var
497 x: string;
498 AnEditSumm: TEditDCSummRec;
499 ActionSts: TActionRec;
500begin
501 SetupVars; //kt added 7/15/2007 to replace constants with vars.
502 if lstAdmissions.ItemIndex < 0 then Exit;
503 x := lstAdmissions.Items[lstAdmissions.ItemIndex];
504 if (StrToIntDef(Piece(x, U, 7), 0) = 2) then
505 begin
506 { Prompt for edit first - proceed as below if yes, else proceed as if '1'}
507 if InfoBox(TX_EDIT_EXISTING, TC_EDIT_EXISTING, MB_YESNO) = MRYES then
508 begin
509 FillChar(AnEditSumm, SizeOf(AnEditSumm), 0);
510 FEditIEN := StrToInt(Piece(x,U,6));
511// ActOnDCDocument(ActionSts, FEditIEN, 'EDIT RECORD'); <-- original line. //kt 7/15/2007
512 ActOnDCDocument(ActionSts, FEditIEN, DKLangConstW('fDCSummProps_EDIT_RECORD')); //kt added 7/15/2007
513 if not ActionSts.Success then
514 begin
515 InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
516 lstAdmissions.ItemIndex := -1;
517 Exit;
518 end;
519 GetDCSummForEdit(AnEditSumm, FEditIEN);
520 EditLines.Assign(AnEditSumm.Lines);
521 cboNewTitle.InitLongList(AnEditSumm.TitleName);
522 ListDCSummTitlesShort(cboNewTitle.Items);
523 if AnEditSumm.Title > 0 then cboNewTitle.SelectByIEN(AnEditSumm.Title);
524 cboAuthor.InitLongList(AnEditSumm.DictatorName);
525 if AnEditSumm.Dictator > 0 then cboAuthor.SelectByIEN(AnEditSumm.Dictator);
526 cboUrgency.Items.Assign(LoadDCUrgencies);
527 cboUrgency.SelectByID('R');
528 cboAttending.InitLongList(AnEditSumm.AttendingName);
529 if AnEditSumm.Attending > 0 then cboAttending.SelectByIEN(AnEditSumm.Attending);
530 calSumm.FMDateTime := AnEditSumm.DictDateTime;
531 end
532 else // if user answers NO to edit existing document, can new one be created?
533 begin
534 FVisitStr := Piece(x, U, 2) + ';' + Piece(x, U, 1) + ';H';
535 if (OneNotePerVisit(cboNewTitle.ItemIEN, Patient.DFN, FVisitStr)) then
536 begin
537 FEditIEN := 0;
538 InfoBox(TX_NO_MORE_SUMMS, TC_NO_EDIT, MB_OK);
539 lstAdmissions.ItemIndex := -1;
540 end;
541 end;
542 end
543 else if Piece(x, U, 7) = '1' then
544 begin
545 FVisitStr := Piece(x, U, 2) + ';' + Piece(x, U, 1) + ';H';
546 if (OneNotePerVisit(cboNewTitle.ItemIEN, Patient.DFN, FVisitStr)) then
547 begin
548 FEditIEN := 0;
549 InfoBox(TX_NO_MORE_SUMMS, TC_NO_EDIT, MB_OK);
550 lstAdmissions.ItemIndex := -1;
551 end;
552 end
553 else
554 begin
555 FEditIEN := 0;
556(* cboNewTitle.ItemIndex := -1;
557 cboAttending.ItemIndex := -1;
558 calSumm.FMDateTime := FMNow;*)
559 end;
560end;
561
562procedure TfrmDCSummProperties.cboNewTitleDblClick(Sender: TObject);
563begin
564 cmdOKClick(Self);
565end;
566
567procedure TfrmDCSummProperties.FormClose(Sender: TObject;
568 var Action: TCloseAction);
569begin
570 SaveUserBounds(Self);
571end;
572
573end.
Note: See TracBrowser for help on using the repository browser.