📄 medicationeditor.pas
字号:
{ *************************************************************************** }
{ }
{ PatientRunner }
{ }
{ Copyright (c) 2002-2005 IgD Software, LLC }
{ }
{ This file may be distributed and/or modified under the terms of the GNU }
{ General Public License (GPL) version 2 as published by the Free Software }
{ Foundation and appearing at http://www.gnu.org/licenses/gpl.html. }
{ }
{ *************************************************************************** }
unit MedicationEditor;
interface
uses
SysUtils, Classes, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, DB, FMTBcd, SqlExpr;
type
TMedicationEditorForm = class(TForm)
OKButton: TButton;
CancelButton: TButton;
Label1: TLabel;
Label3: TLabel;
PrescriptionEdit: TEdit;
EndDatePicker: TDateTimePicker;
StartDatePicker: TDateTimePicker;
Label2: TLabel;
DiscontinuedCheckBox: TCheckBox;
SQLQuery: TSQLQuery;
procedure CancelButtonClick(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
FNewRecord: boolean;
procedure SetNewRecord(const Value: boolean);
{ Private declarations }
public
//If NewRecord is true then perform INSERT SQL query
//if not then perform REPLACE SQL query
property NewRecord: boolean read FNewRecord write SetNewRecord;
end;
var
MedicationEditorForm: TMedicationEditorForm;
implementation
uses Main, PatientExplorer;
{$R *.dfm}
procedure TMedicationEditorForm.CancelButtonClick(Sender: TObject);
begin
if MessageDlg('Exit without saving changes?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
Close;
end;
procedure TMedicationEditorForm.OKButtonClick(Sender: TObject);
begin
PrescriptionEdit.Text:=TrimRight(PrescriptionEdit.Text);
if PrescriptionEdit.Text='' then
begin
MessageDlg('You must enter a valid prescription to save this record!', mtError, [mbOk], 0);
Exit;
end;
DateSeparator := '/';
ShortDateFormat := 'yyyy/mm/dd';
LongTimeFormat:='hh:nn:ss';
with SQLQuery do
begin
SQL.Clear;
Params.Clear;
if FNewRecord then
begin
SQL.Text:='insert into medications (prescription, startdate, enddate, patientid, discontinued, author) values (:prescription, :startdate, :enddate, :patientid, :resolved, :author)';
Params[0].AsString:=PrescriptionEdit.Text;
Params[1].AsString:=DatetoStr(StartDatePicker.Date);
Params[2].AsString:=DatetoStr(EndDatePicker.Date);
Params[3].AsString:=InttoStr(PPatientRecord(MainForm.PatientListView.Selected.Data)^.PatientID);
Params[4].AsString:=IntToStr(Integer(DiscontinuedCheckBox.Checked));
Params[5].AsString:=MainForm.SQLConnection.Params.Values['User_Name'];
ExecSQL;
PatientExplorerForm.RefreshMedsDBClick(Sender);
PatientExplorerForm.MedicationsListView.Selected:=PatientExplorerForm.MedicationsListView.TopItem;
PatientExplorerForm.MedicationsListView.ItemFocused:=PatientExplorerForm.MedicationsListView.TopItem;
end
else
begin
with PMedicationRecord(PatientExplorerForm.MedicationsListView.ItemFocused.Data)^ do
begin
Prescription:=PrescriptionEdit.Text;
StartDate:=StartDatePicker.Date;
EndDate:=EndDatePicker.Date;
Discontinued:=DiscontinuedCheckBox.Checked;
end;
SQL.Text:='update medications set prescription=:prescription, startdate=:startdate, enddate=:enddate, discontinued=:discontinued where medicationid=:medicationid';
Params[0].AsString:=PrescriptionEdit.Text;
Params[1].AsString:=DatetoStr(StartDatePicker.Date);
Params[2].AsString:=DatetoStr(EndDatePicker.Date);
Params[3].AsString:=IntToStr(Integer(DiscontinuedCheckBox.Checked));
Params[4].AsString:=InttoStr(PMedicationRecord(PatientExplorerForm.MedicationsListView.ItemFocused.Data)^.MedicationID);
ExecSql;
PatientExplorerForm.RefreshMedsDBClick(Sender);
end;
end;
Close;
end;
procedure TMedicationEditorForm.SetNewRecord(const Value: boolean);
begin
FNewRecord := Value;
end;
procedure TMedicationEditorForm.FormShow(Sender: TObject);
begin
ActiveControl:=PrescriptionEdit;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -