⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patientao.pas

📁 某大型医院护士站
💻 PAS
字号:
unit PatientAO;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, Grids, Wwdbigrd, Wwdbgrid;

type
  TfrmPatientAtOnce = class(TForm)
    PatientAtOnceGrid: TwwDBGrid;
    Panel2: TPanel;
    btnEmergencySend: TBitBtn;
    BitBtn6: TBitBtn;
    Panel1: TPanel;
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    procedure btnEmergencySendClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPatientAtOnce: TfrmPatientAtOnce;

implementation

uses Datamodule;

{$R *.DFM}


procedure TfrmPatientAtOnce.btnEmergencySendClick(Sender: TObject);
Var
  SelectCount ,i :integer;
  Curr :TDateTime;
  Is_Send :Boolean;
begin
  Is_Send := False;

  SelectCount := PatientAtOnceGrid.SelectedList.Count;
  if (SelectCount = 0) OR (DM.qryPatientAtOnce.RecordCount = 0) then
     Raise Exception.Create('没有选中医嘱!');

  DM.SetSystemTime;
  Curr := Now;
  if Application.MessageBox('是否对选中的医嘱进行紧急发药?',
        '提示', MB_OKCANCEL) = IDCANCEL then SysUtils.Abort
  else
    begin

      with DM.Ins_Aomsg do
      begin
        Close;
        SQL.Clear;
        SQL.Add('INSERT INTO CONFIRMLOG (DEPTNUM ,MSGTIME ,EXCUPLACE ,MSGTYPE , ');
        SQL.Add('WARDID ,ISPRN_PO ,ISPRN_NPO ,ISPCNFM_PO ,ISPCNFM_NPO) ');
        SQL.Add('SELECT A.DEPTNUM ,A.MSGTIME ,A.EXCUPLACE ,''02'' ,');
        SQL.Add('A.WARDID ,0 ,0 ,0 ,0 ');
        SQL.Add('FROM MSGDETAIL A ,EXCUTEPOS B  ');
        SQL.Add('WHERE A.WARDID = :P_WARDID AND A.MSGTIME = :P_AOMSG ');
        SQL.Add('AND A.EXCUPLACE = B.EXCUPLACE AND B.ISRNWRITE = 0 ');
        SQL.Add('GROUP BY A.WARDID ,A.DEPTNUM ,A.MSGTIME ,A.EXCUPLACE ');
      end;

      for i:= 0 to SelectCount - 1 do
      begin
         DM.qryPatientAtOnce.GotoBookmark(PatientAtOnceGrid.SelectedList.items[i]);
         DM.qryPatientAtOnce.Freebookmark(PatientAtOnceGrid.SelectedList.items[i]);
         try
           if DM.ProjHisadt.InTransaction then
             DM.ProjHisadt.Commit;
           DM.ProjHisadt.StartTransaction;

           DM.spEmergency.Params[0].AsString :=
                         DM.qryPatientAtOnceserialid.Value;
           DM.spEmergency.Params[1].AsString   := DM.currOperatorno;
           DM.spEmergency.Params[2].AsDateTime := Curr;
           DM.spEmergency.ExecProc;

           DM.ProjHisadt.Commit;
           Is_Send := True;
         except
           if DM.ProjHisadt.InTransaction then
              DM.ProjHisadt.Rollback;
           PatientAtOnceGrid.SelectedList.Clear;
           Exception.Create('紧急发送有错误,请认真核对医嘱内容! ');
         end;

      end;
      PatientAtOnceGrid.SelectedList.Clear;
      { Clear selected record list since they are all deleted}

      end;  //end for

 // Insert the Atonce Message
      if Is_Send then
      with DM.Ins_Aomsg do
      begin
        Close;
        ParamByName('P_WARDID').AsString  := DM.currWardid;
        ParamByName('P_AOMSG').AsDateTime := Curr;
        ExecSQL;
      end;

  //  Refresh GridData
      with DM.qryPatientAtOnce do
      begin
        DisableControls;
        Active := False;
        Params[0].AsInteger := DM.tblPatientSubInid.Value;
        Params[1].AsInteger := DM.tblPatientSubTimes.Value;
        Params[2].AsInteger := DM.tblPatientSubSqid.Value;
        Params[3].AsString  := DM.currWardid;
        Active := True;
        EnableControls;
      end;
 end;

procedure TfrmPatientAtOnce.BitBtn1Click(Sender: TObject);
begin
  PatientAtOnceGrid.SelectAll;
end;

procedure TfrmPatientAtOnce.BitBtn6Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmPatientAtOnce.BitBtn3Click(Sender: TObject);
begin
  with DM.qryPatientAtOnce do
  begin
    First;
    while not EOF do
    begin
      if DM.qryPatientAtOnceorderkind.Value = 0 then
         PatientAtOnceGrid.SelectRecord
      else
         PatientAtOnceGrid.UnselectRecord;
      Next;
    end;
  end;
end;

procedure TfrmPatientAtOnce.BitBtn4Click(Sender: TObject);
begin
  with DM.qryPatientAtOnce do
  begin
    First;
    while not EOF do
    begin
      if DM.qryPatientAtOnceorderkind.Value = 1 then
         PatientAtOnceGrid.SelectRecord
      else
         PatientAtOnceGrid.UnselectRecord;
      Next;
    end;
  end;
end;

procedure TfrmPatientAtOnce.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  DM.qryPatientAtonce.Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -