📄 encounterreportgenerator.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 EncounterReportGenerator;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBXpress, FMTBcd, DB, SqlExpr, ExtCtrls, QuickRpt, QRCtrls,
StdCtrls, ComCtrls;
type
TEncounterReportGeneratorForm = class(TForm)
EncounterReportBtn: TButton;
LateCalendar: TMonthCalendar;
EarlyCalendar: TMonthCalendar;
Label1: TLabel;
Label2: TLabel;
DelinquentDictationReportBtn: TButton;
procedure EncounterReportBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DelinquentDictationReportBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
EncounterReportGeneratorForm: TEncounterReportGeneratorForm;
implementation
{$R *.dfm}
uses Main, Encounters, DelinquentDictations;
{SELECT owners.ownerid, flyers.flyerid,
owners.name, flyers.flyername, flyers.active,
flyers.enddate, flyers.url,
Count(*) as Hits
FROM owners
INNER JOIN flyers ON owners.ownerid = flyers.ownerid
Inner Join Hits On flyers.flyerID = hits.flyerid
WHERE owners.ownerid=1
Group by owners.ownerid, flyers.flyerid,
owners.name, flyers.flyername, flyers.active,
flyers.enddate, flyers.url;}
//left join -> all notes will be displayed even if there is no diagnosis
{select notes.description, diagnoses.diagnosis
from notes
left join diagnoses
on notes.patientid=diagnoses.patientid;}
procedure TEncounterReportGeneratorForm.EncounterReportBtnClick(Sender: TObject);
begin
//The end result of this SQL query is that all the notes for the user during
//a specified time period will be printed in a report. The notes will be
//ordered by date. The patient's name, birthday and first diagnosis will be
//listed. If no diagnosis is available, no note will be displayed in the
//report.
with EncountersReport.EncounterSQLQuery do
begin
SQL.Clear;
Params.Clear;
//this code below prints out a line with name, date and note description for each diagnosis.
//for example, if there are 6 diagnoses there will be 6 lines.
SQL.Add('select notes.description, notes.notedatetime, diagnoses.diagnosis, patients.lastname, patients.firstname, patients.birthday');
SQL.Add('from notes');
//returns rows from both tables where there is a match
SQL.Add('inner join patients on notes.patientid=patients.patientid');
//returns rows from the first table (notes) even if there are no matches (diagnoses)in the second
SQL.Add('left join diagnoses on notes.patientid=diagnoses.patientid');
SQL.Add('where notes.notedatetime between '''+FormatDateTime('yyyy/mm/dd', EarlyCalendar.Date)+''' and '''+FormatDateTime('yyyy/mm/dd', LateCalendar.Date)+'''');
//SQL.Add('and diagnoses.resolved=0');
//SQL.Add('and notes.author='''+MainForm.SQLConnection.Params.Values['User_Name']+'''');
SQL.Add('and notes.author=''rgmarietta''');
SQL.Add('order by notes.notedatetime desc');
//showmessage(sql.text);
Active:=True;
end;
EncountersReport.QRLabel1.Caption:='Patient Encounter Report for '+MainForm.SQLConnection.Params.Values['User_Name']+' from '+FormatDateTime('dd mmm yy', EarlyCalendar.Date)+' to '+FormatDateTime('dd mmm yy', LateCalendar.Date);
EncountersReport.Preview;
end;
procedure TEncounterReportGeneratorForm.DelinquentDictationReportBtnClick(
Sender: TObject);
begin
//The end result of this SQL query is that all the notes with the DictationPending
//flag set created by the user will be returned in report format. The report
//will include the patient's name, note description and note date. The report
//will be ordered by date.
with DelinquentDictationsReport.EncounterSQLQuery do
begin
SQL.Clear;
Params.Clear;
SQL.Add('select notes.description, notes.notedatetime, notes.dictationpending, patients.lastname, patients.firstname');
SQL.Add('from notes');
SQL.Add('inner join patients on notes.patientid=patients.patientid');
SQL.Add('where notes.dictationpending=1');
SQL.Add('and notes.notedatetime between '''+FormatDateTime('yyyy/mm/dd', EarlyCalendar.Date)+''' and '''+FormatDateTime('yyyy/mm/dd', LateCalendar.Date)+'''');
SQL.Add('and notes.author='''+MainForm.SQLConnection.Params.Values['User_Name']+'''');
//SQL.Add('and notes.author=''rgmarietta''');
SQL.Add('order by notes.notedatetime desc');
//showmessage(sql.text);
Active:=True;
end;
DelinquentDictationsReport.QRLabel1.Caption:='Delinquent Dictation Report for '+MainForm.SQLConnection.Params.Values['User_Name']+' from '+FormatDateTime('dd mmm yy', EarlyCalendar.Date)+' to '+FormatDateTime('dd mmm yy', LateCalendar.Date);
DelinquentDictationsReport.Preview;
end;
procedure TEncounterReportGeneratorForm.FormCreate(Sender: TObject);
begin
LateCalendar.Date:=Now;
EarlyCalendar.Date:=(Now-90); //Today - 1 year
//EarlyCalendar.Date:=(Now-365); //Today - 1 year (365 days)
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -