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

📄 ufrmcellmarrow.pas

📁 一个简单得医院图像管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit ufrmCellMarrow;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxControls, cxContainer, cxEdit, cxImage, cxDBEdit, dbcgrids,
  ExtCtrls, StdCtrls, ComCtrls, Grids, DBGrids, ImgList, ToolWin,uCellMarrowPatient,
  uPubFun,uCellMarrowPicture,uDictionary,DateUtils, DB,ADODB,IniFiles,ufrmPictureInputPath,
  ExtDlgs,jpeg,ufrmCellMarrowQuery,uCellMarrowTemplet,OleCtrls, CELL50Lib_TLB;

type
  TfrmCellMarrowMain = class(TForm)
    ToolBar1: TToolBar;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton1: TToolButton;
    ToolButton11: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton14: TToolButton;
    ToolButton13: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    ToolButton12: TToolButton;
    ImageList1: TImageList;
    pgcPatient: TPageControl;
    TabSheet1: TTabSheet;
    dbgLiveMarrow: TDBGrid;
    TabSheet2: TTabSheet;
    GroupBox4: TGroupBox;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label19: TLabel;
    Label14: TLabel;
    edtCaseCode: TEdit;
    edtName: TEdit;
    edtSicknessBed: TEdit;
    cboDepartment: TComboBox;
    cboSex: TComboBox;
    cboDiagnosis: TComboBox;
    cboSicknessSection: TComboBox;
    edtBirthdayCount: TEdit;
    cboBirthdayUnit: TComboBox;
    cboOutOrIn: TComboBox;
    cboSampleSource: TComboBox;
    GroupBox5: TGroupBox;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label20: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label13: TLabel;
    Label4: TLabel;
    cboSendDoctor: TComboBox;
    cboTestDoctor: TComboBox;
    dtpReportDate: TDateTimePicker;
    dtpSendDate: TDateTimePicker;
    edtTestNo: TEdit;
    dtpTestDate: TDateTimePicker;
    memReport: TMemo;
    ImageList2: TImageList;
    Panel2: TPanel;
    dbcLiveMarrow: TDBCtrlGrid;
    dbiLiveMarrow: TcxDBImage;
    ToolBar2: TToolBar;
    ToolButton17: TToolButton;
    ToolButton18: TToolButton;
    ToolButton19: TToolButton;
    ToolButton20: TToolButton;
    ToolButton21: TToolButton;
    pnlPrintedInf: TPanel;
    Panel3: TPanel;
    Label2: TLabel;
    memAdvice: TMemo;
    Panel1: TPanel;
    Label1: TLabel;
    memTestResult: TMemo;
    dsPatient: TDataSource;
    dsPicture: TDataSource;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton13Click(Sender: TObject);
    procedure ToolButton17Click(Sender: TObject);
    procedure ToolButton18Click(Sender: TObject);
    procedure ToolButton19Click(Sender: TObject);
    procedure ToolButton20Click(Sender: TObject);
    procedure ToolButton21Click(Sender: TObject);
    procedure cboDepartmentExit(Sender: TObject);
    procedure cboSicknessSectionExit(Sender: TObject);
    procedure cboDiagnosisExit(Sender: TObject);
    procedure cboTestDoctorExit(Sender: TObject);
    procedure cboSendDoctorExit(Sender: TObject);
    procedure dbiLiveMarrowDblClick(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton12Click(Sender: TObject);
    procedure dbgLiveMarrowKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure dbgLiveMarrowMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure memTestResultDblClick(Sender: TObject);
    procedure memAdviceDblClick(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
  private
    FPatient:TCellMarrowPatient;
    FPicture:TCellMarrowPicture;
    FBlank:Boolean;

    //模板
    FAdvice:TCellAdviceTemplet;
    FTestResult:TCellTestResult;

    //以下为字典对象
    FTestDoctor:TDictionary;
    FSicknessSection:TDictionary;
    FDiagnostic:TDictionary;
    FDepartment:TDictionary;
    FSendDoctor:TDictionary;

    //字典加载到COMBOX中
    procedure LoadDictionaryToCombox;
   //根据名称寻找对应字典
    procedure LookUpByName(cobItem:TComboBox;Dictionary:TDictionary);

   //加载当天数据
   procedure LoadTodayData;
   //加载其他时间数据
   procedure LoadDataByCondition(sCondition:string);
   //选择图片数据
   procedure SelectPicture;
   
   //初始化报告信息
   procedure InitialReport;
   //显示报告信息
   procedure ReadReport;
   //绑定数据
   procedure BindDataSource;
   //写数据
   procedure WriteReport;
   //添加报告
   procedure AddReport;
   //删除报告
   procedure DeleteReport;
   //保存报告
   procedure SaveReport;

   //移动报告
   procedure MoveFirst;
   procedure MoveNext;
   procedure MovePriview;
   procedure MoveLast;

   //图片处理
   procedure AddPicture;
   procedure DeletePicture;
   procedure SetPicturePrinted;
   procedure SetPictureUnprinted;
   procedure SetInitPath;

   //加载数据到模板
   procedure LoadReportInfToTemplet(Cell:TCell);

  public

  end;

var
  frmCellMarrowMain: TfrmCellMarrowMain;

implementation

uses uPictureZoom, ufrmLiveMarrowAdviceTemplet, ufrmCellMarrowPrint,
  ufrmLiveMarrowPrint;

{$R *.dfm}

{ TfrmCellMarrowMain }

procedure TfrmCellMarrowMain.AddPicture;
var
  i:Integer;
  IniFile:TIniFile;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1) then Exit;
  if FPicture.Query.Active=False then Exit;
  IniFile:=TIniFile.Create('.\startpath.ini');
try
  OpenPictureDialog1.InitialDir:=IniFile.ReadString('startpath','CellMarrow','.\');
  if OpenPictureDialog1.Execute then
  begin
    with FPicture do
     begin
       for i:=0 to OpenPictureDialog1.Files.Count-1 do
       begin
         Query.Append;
         Query.FieldByName('ID').AsInteger:=GetMaxID;
         Query.FieldByName('PatientID').AsInteger:=FPatient.PatientID;
         Query.FieldByName('Printed').AsInteger:=0;
         TBlobField(Query.FieldByName('Picture')).LoadFromFile(OpenPictureDialog1.Files[i]);
         Query.Post;
       end;
      end;
   end;
finally
  IniFile.Free;
end;
end;
procedure TfrmCellMarrowMain.AddReport;
begin
  if FPatient.Query.Active=False then Exit;
  FPatient.Query.Append;
  WriteReport;
  FPatient.Query.Post;
  ReadReport;
end;

procedure TfrmCellMarrowMain.BindDataSource;
begin
  dsPatient.DataSet:=FPatient.Query;
  dsPicture.DataSet:=FPicture.Query;

  dbgLiveMarrow.Columns[0].FieldName:='TestDate';
  dbgLiveMarrow.Columns[1].FieldName:='TestNumber';
  dbgLiveMarrow.Columns[2].FieldName:='PatientName';
  dbgLiveMarrow.DataSource:=dsPatient;


  dbcLiveMarrow.DataSource:=dsPicture;
  with dbiLiveMarrow.DataBinding do
  begin
    DataField:='Picture';
    DataSource:=dsPicture;
  end;

end;

procedure TfrmCellMarrowMain.DeletePicture;
begin
  if TBasoUtils.SysMessage('确实要删除该图片吗?',YESNO+QUST)=NO then Exit;
  if (FPicture.Query.Active=False)or(FPicture.Query.RecordCount<1) then Exit;
  FPicture.Query.Delete;
  pnlPrintedInf.Caption:=FPicture.GetPrintedPicture;
end;

procedure TfrmCellMarrowMain.DeleteReport;
begin
  if TBasoUtils.SysMessage('真的删除该报告吗?',YESNO+QUST)=No then Exit;
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
   FPicture.DeleteCurrentAllPicture;
   FPatient.Query.Delete;
   ReadReport;
end;

procedure TfrmCellMarrowMain.InitialReport;
var
  i:Integer;
begin
  for i:=0 to Self.ComponentCount-1 do
  begin
    if Self.Components[i] is TComboBox then
    begin
      TComboBox(Self.Components[i]).Text:='';
    end;
    if Self.Components[i] is TEdit then
    begin
      TEdit(Self.Components[i]).Text:='';
    end;
    if Self.Components[i] is TMemo then
    begin
      TMemo(Self.Components[i]).Text:='';
    end;
    if Self.Components[i] is TDateTimePicker then
    begin
      TDateTimePicker(Self.Components[i]).Date:=Today;
    end;
  end;
  //默认为住院
  cboOutOrIn.ItemIndex:=1;
end;
procedure TfrmCellMarrowMain.LoadDataByCondition(sCondition: string);
var
  PatientIDS:TStrings;
begin
  FPatient.QueryPatient(sCondition);
  PatientIDS:=TStringList.Create;
try
  FPatient.GetAllPatientID(PatientIDS);
  FPicture.QueryByPatientIDS(PatientIDS);
finally
  PatientIDS.Free;
end;
end;

procedure TfrmCellMarrowMain.LoadDictionaryToCombox;
begin
  FDepartment.LoadAllDictionNames(cboDepartment.Items);
  FSicknessSection.LoadAllDictionNames(cboSicknessSection.Items);
  FDiagnostic.LoadAllDictionNames(cboDiagnosis.Items);
  FTestDoctor.LoadAllDictionNames(cboTestDoctor.Items);
  FSendDoctor.LoadAllDictionNames(cboSendDoctor.Items);

end;

procedure TfrmCellMarrowMain.LoadTodayData;
var
  sConditon:string;
  PatientIDS:TStrings;
begin
  sConditon:='TestDate=#%s#';
  sConditon:=Format(sConditon,[DateToStr(DateOf(Today))]);
  FPatient.QueryPatient(sConditon);
  PatientIDS:=TStringList.Create;
try
  FPatient.GetAllPatientID(PatientIDS);
  FPicture.QueryByPatientIDS(PatientIDS);
finally
  PatientIDS.Free;
end;

end;

procedure TfrmCellMarrowMain.LookUpByName(cobItem: TComboBox;
  Dictionary: TDictionary);
var
  tem:string;
begin
  if cobItem.Items.IndexOf(Trim(cobItem.Text))>-1 then Exit;
  tem:=Trim(Dictionary.FindNameByCode(Trim(cobItem.Text)));
  if tem='' then Exit;
  cobItem.Text:=tem;
end;

procedure TfrmCellMarrowMain.MoveFirst;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
  FPatient.Query.First;
  ReadReport;
end;

procedure TfrmCellMarrowMain.MoveLast;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
  FPatient.Query.Last;
  ReadReport;
end;

procedure TfrmCellMarrowMain.MoveNext;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
  FPatient.Query.Next;
  if FPatient.Query.Eof then FPatient.Query.First;
  ReadReport;
end;

procedure TfrmCellMarrowMain.MovePriview;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
  FPatient.Query.Prior;
  if FPatient.Query.bof then FPatient.Query.Last;
  ReadReport
end;

procedure TfrmCellMarrowMain.ReadReport;
begin
  //选择图片
  SelectPicture;
  //初始化报告
  InitialReport;
  //图片处理
  pnlPrintedInf.Caption:=FPicture.GetPrintedPicture;
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1) then
  begin
  FBlank:=true;
  Exit;
  end;
  with FPatient do
  begin
    cboOutOrIn.ItemIndex:=cboOutOrIn.Items.IndexOf(TBasoUtils.GetDataFromField(Query,'OutOrIn','    '));
    edtCaseCode.Text:=TBasoUtils.GetDataFromField(Query,'PatientCode','');
    edtName.Text:=TBasoUtils.GetDataFromField(Query,'PatientName','');
    cboSex.Text:=TBasoUtils.GetDataFromField(Query,'sex','');
    edtBirthdayCount.Text:=TBasoUtils.GetDataFromField(Query,'Birthday','');
    cboBirthdayUnit.Text:=TBasoUtils.GetDataFromField(Query,'BirthdayUnit','');
    cboDepartment.Text:=TBasoUtils.GetDataFromField(Query,'Department','');
    cboSicknessSection.Text:=TBasoUtils.GetDataFromField(Query,'SickSection','');
    edtSicknessBed.Text:=TBasoUtils.GetDataFromField(Query,'BedCode','');
    cboDiagnosis.Text:=TBasoUtils.GetDataFromField(Query,'Diagnositic','');
    edtTestNo.Text:=TBasoUtils.GetDataFromField(Query,'TestNumber','');
    cboSampleSource.Text:=TBasoUtils.GetDataFromField(Query,'SampleSource','');
    cboSendDoctor.Text:=TBasoUtils.GetDataFromField(Query,'SendDoctor','');
    cboTestDoctor.Text:=TBasoUtils.GetDataFromField(Query,'TestDoctor','');
    dtpTestDate.Date:=TBasoUtils.GetDataFromField(Query,'TestDate',Today);
    dtpSendDate.Date:=TBasoUtils.GetDataFromField(Query,'SendDate',Today);
    dtpReportDate.Date:=TBasoUtils.GetDataFromField(Query,'ReportDate',Today);
    memReport.Text:=TBasoUtils.GetDataFromField(Query,'ReportMemo','');
    memAdvice.Text:=TBasoUtils.GetDataFromField(Query,'Advice','');
    memTestResult.Text:=TBasoUtils.GetDataFromField(Query,'TestResult','');

    FBlank:=False;
  end;

end;
procedure TfrmCellMarrowMain.SaveReport;
begin
  if (FPatient.Query.Active=False)or(FPatient.Query.RecordCount<1)then Exit;
  if FPatient.Query.State=dsBrowse then FPatient.Query.Edit;
  WriteReport;
  FPatient.Query.Post;

⌨️ 快捷键说明

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