ucellmarrowpatient.pas

来自「一个简单得医院图像管理系统」· PAS 代码 · 共 114 行

PAS
114
字号
unit uCellMarrowPatient;

interface
uses Windows, Messages, SysUtils, Variants, Classes,uPublicConnection,uPubFun,
     DB,ADODB;
type
 TCellMarrowPatient=class(TObject)
 private
    FQuery:TADOQuery;
    function GetPatientID: Integer;
    function GetPatientCount: Integer;
    function GetIsValidPatient: Boolean;

  public
    constructor Create;
    destructor Destroy;override;
    //根据条件查询病人档案
    function QueryPatient(sCondition:string):Boolean;
    //获得当前病人的所有ID号
    procedure GetAllPatientID(PatientIDS:TStrings);
    property PatientCount:Integer read GetPatientCount;
    property Query:TADOQuery read FQuery;
    property PatientID:Integer read GetPatientID;
    property IsValidPatient:Boolean read GetIsValidPatient;

  end;

implementation

{ TCellMarrowPatient }

constructor TCellMarrowPatient.Create;
begin
  inherited;
  FQuery:=TADOQuery.Create(nil);
  FQuery.Connection:=GlobalConnection.Connection;

end;

destructor TCellMarrowPatient.Destroy;
begin
  if FQuery.Active then FQuery.Active:=False;
  FreeAndNil(FQuery);
  inherited;
end;

procedure TCellMarrowPatient.GetAllPatientID(PatientIDS: TStrings);
var
  sOriginBookMark:string;
  sPatientID:Integer;
  tem:string;
  i:Integer;
begin
  if Assigned(PatientIDS)=False then Exit;
  PatientIDS.Clear;
  if PatientCount<1 then Exit;
try
  sOriginBookMark:=FQuery.Bookmark;
  FQuery.DisableControls;
  FQuery.First;
  for i:=1 to PatientCount do
  begin
    sPatientID:=TBasoUtils.GetDataFromField(FQuery,'PatientID',-1);
    tem:=IntToStr(sPatientID);
    if PatientIDS.IndexOf(tem)=-1 then PatientIDS.Add(tem);
    FQuery.Next;
  end;
finally
  FQuery.Bookmark := sOriginBookMark;
  FQuery.EnableControls;
end;
end;
function TCellMarrowPatient.GetIsValidPatient: Boolean;
begin
  Result:=(Self.PatientID>0);
end;

function TCellMarrowPatient.GetPatientCount: Integer;
begin
  result:=-1;
  if FQuery.Active=False then Exit;
  Result:=FQuery.RecordCount;
end;

function TCellMarrowPatient.GetPatientID: Integer;
begin
  Result:=-1;
  if (FQuery.Active=False)or(FQuery.RecordCount<1) then Exit;
  Result:=FQuery.FieldByName('PatientID').AsInteger;
end;

function TCellMarrowPatient.QueryPatient(sCondition: string): Boolean;
var
  sSQL:string;
begin
  sSQL:='select* from CELL_MARROW_PATIENT';
  sCondition:=Trim(sCondition);

  if sCondition<>'' then
  sSQL:=sSQL+' where '+sCondition;

  if FQuery.Active then FQuery.Active:=False;
  FQuery.SQL.Text:=sSQL;
  
try
  FQuery.Active:=True;
finally
  result:=FQuery.Active;
end;

end;

end.

⌨️ 快捷键说明

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