📄 templatemanager.pas
字号:
Exit;
Break;
end;
end;
if MessageDlg('Your note is about to be replaced with the template you selected. Do you wish to continue?', mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Exit;
with TemplateRichEdit do
begin
Lines.BeginUpdate;
with PPatientRecord(MainForm.PatientListView.ItemFocused.Data)^ do
begin
ReplaceText('<AGE>', inttostr(AgeInYears(Birthday)), 0, [stWholeWord], False);
ReplaceText('<ALLERGIES>', Allergies, 0, [stWholeWord], False);
ReplaceText('<CAD>', AgetoStr(PayDate, Now), 0, [stWholeWord], False);
ReplaceText('<COMMAND>', Command, 0, [stWholeWord], False);
ReplaceText('<DATE>', FormatDateTime('d mmm yy', Now), 0, [stWholeWord], False);
ReplaceText('<FIRSTNAME>', Firstname, 0, [stWholeWord], False);
ReplaceText('<LASTNAME>', Lastname, 0, [stWholeWord], False);
ReplaceText('<RANK>', Rank, 0, [stWholeWord], False);
ReplaceText('<RATE>', Rate, 0, [stWholeWord], False);
ReplaceText('<SERVICE>', Service, 0, [stWholeWord], False);
ReplaceText('<SSN>', SSN, 0, [stWholeWord], False);
ReplaceText('<TIME>', FormatDateTime('hhnn', Now), 0, [stWholeWord], False);
if IsMale then
begin
ReplaceText('<HESHE>', 'he', 0, [stWholeWord], True);
ReplaceText('<HIMHER>', 'him', 0, [stWholeWord], True);
ReplaceText('<HISHER>', 'his', 0, [stWholeWord], True);
ReplaceText('<SEX>', 'male', 0, [stWholeWord], True);
end
else
begin
ReplaceText('<HESHE>', 'she', 0, [stWholeWord], True);
ReplaceText('<HIMHER>', 'her', 0, [stWholeWord], True);
ReplaceText('<HISHER>', 'her', 0, [stWholeWord], True);
ReplaceText('<SEX>', 'female', 0, [stWholeWord], True);
end;
end; //with PatientRecord
Lines.EndUpdate;
end; //with NoteRichedit
new(NoteRecordPtr);
with NoteRecordPtr^ do
begin
try
PatientID:=PPatientRecord(MainForm.PatientListView.ItemFocused.Data)^.PatientID;
except
ShowMessage('An error occurred in the TemplateManager while trying to grab MainForm.PatientID');
end;
Description:=PTemplateRecord(TemplatesListView.ItemFocused.Data)^.Description;
NoteDateTime:=Now;
NoteStringStream:=TStringStream.Create('');
NoteStringStream.Position:=0;
TemplateRichEdit.Lines.SaveToStream(NoteStringStream);
DictationPending:=False;
PleaseReview:=False;
Author:=MainForm.SQLConnection.Params.Values['User_Name'];
NewNote:=True;
Modded:=True;
OpenforEditing:=True;
with PatientExplorerForm do
begin
try
with NotesListView.Items.Insert(0) do
begin
Caption:=FormatDateTime('dd mmm yy', NoteDateTime);
SubItems.Add(Description);
Data:=TObject(NoteRecordPtr);
end;
except
ShowMessage('An error occurred in the TemplateManager while trying to insert a note into the PatientExplorer');
end;
try
NotesListView.Selected:=NotesListView.TopItem;
NotesListView.ItemFocused:=NotesListView.TopItem;
NotesListViewClick(Sender);
except
ShowMessage('An error occurred in the TemplateManager while trying to select the first note in PatientExplorer');
end;
end;
end;
//the following prevents confirmation dialog from popping up in onclose event
DescriptionEdit.Modified:=False;
TemplateRichEdit.Modified:=False;
Close;
end;
{-----------------------------------------------------
Form stuff
------------------------------------------------------}
procedure TTemplateManagerForm.FormShow(Sender: TObject);
begin
RefreshTemplatesDBClick(Sender);
end;
procedure TTemplateManagerForm.FormCreate(Sender: TObject);
var fIni: TRegIniFile;
begin
TemplateRichEdit.OnDblClick := EditNoteClick;
GetFontNames;
SelectionChange(Self);
CurrText.Name := DefFontData.Name;
CurrText.Size := -MulDiv(DefFontData.Height, 72, Screen.PixelsPerInch);
PreviousItem:=nil;
fIni:=TRegIniFile.Create('');
with fIni do
begin
RootKey:=HKEY_CURRENT_USER;
//Set so new users get a full list of patients the first time they use the software
ShowOnlyMyTemplatesCheckBox.Checked:=ReadBool('Software\PatientRunner', 'ShowOnlyMyTemplates', False);
Free;
end;
end;
procedure TTemplateManagerForm.FormClose(Sender: TObject;
var Action: TCloseAction);
var i: integer;
begin
//if not FImport then
//begin
for i:=0 to TemplatesListView.Items.Count-1 do
begin
if PTemplateRecord(TemplatesListView.Items[i].Data)^.Modded or DescriptionEdit.Modified or TemplateRichEdit.Modified then
begin
if MessageDlg('At least one template has been modified. Exit without saving changes?', mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
begin
Action:=caNone;
Exit;
end;
Break;
end;
end;
//end;
TemplatesListView.Items.BeginUpdate;
CleanUpTemplatesListView;
TemplatesListView.Items.EndUpdate;
end;
procedure TTemplateManagerForm.FormDestroy(Sender: TObject);
var fIni: TRegIniFile;
begin
fIni:=TRegIniFile.Create('');
with fIni do
begin
RootKey:=HKEY_CURRENT_USER;
WriteBool('Software\PatientRunner', 'ShowOnlyMyTemplates', ShowOnlyMyTemplatesCheckBox.Checked);
Free;
end;
end;
{----------------------------------------------
rich edit stuff
-----------------------------------------------}
function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
FontType: Integer; Data: Pointer): Integer; stdcall;
begin
TStrings(Data).Add(LogFont.lfFaceName);
Result := 1;
end;
procedure TTemplateManagerForm.GetFontNames;
var
DC: HDC;
begin
DC := GetDC(0);
EnumFonts(DC, nil, @EnumFontsProc, Pointer(FontName.Items));
ReleaseDC(0, DC);
FontName.Sorted := True;
end;
function TTemplateManagerForm.CurrText: TTextAttributes;
begin
if TemplateRichEdit.SelLength > 0 then
Result := TemplateRichEdit.SelAttributes
else
Result := TemplateRichEdit.DefAttributes;
end;
procedure TTemplateManagerForm.SelectionChange(Sender: TObject);
begin
with TemplateRichEdit.Paragraph do
try
FUpdating := True;
//FirstInd.Left := Trunc(FirstIndent*RulerAdj)-4+GutterWid;
//LeftInd.Left := Trunc((LeftIndent+FirstIndent)*RulerAdj)-4+GutterWid;
//RightInd.Left := Ruler.ClientWidth-6-Trunc((RightIndent+GutterWid)*RulerAdj);
BoldButton.Down := fsBold in TemplateRichEdit.SelAttributes.Style;
ItalicButton.Down := fsItalic in TemplateRichEdit.SelAttributes.Style;
UnderlineButton.Down := fsUnderline in TemplateRichEdit.SelAttributes.Style;
BulletsButton.Down := Boolean(Numbering);
FontSize.Text := IntToStr(TemplateRichEdit.SelAttributes.Size);
FontName.Text := TemplateRichEdit.SelAttributes.Name;
case Ord(Alignment) of
0: LeftAlign.Down := True;
1: RightAlign.Down := True;
2: CenterAlign.Down := True;
end;
//UpdateCursorPos; for status bar
finally
FUpdating := False;
end;
end;
procedure TTemplateManagerForm.FontClick(Sender: TObject);
begin
FontDialog.Font.Assign(TemplateRichEdit.SelAttributes);
if FontDialog.Execute then
CurrText.Assign(FontDialog.Font);
SelectionChange(Self);
TemplateRichEdit.SetFocus;
end;
procedure TTemplateManagerForm.UndoClick(Sender: TObject);
begin
with TemplateRichEdit do
if HandleAllocated then SendMessage(Handle, EM_UNDO, 0, 0);
end;
procedure TTemplateManagerForm.CutClick(Sender: TObject);
begin
TemplateRichEdit.CutToClipboard;
end;
procedure TTemplateManagerForm.CopyClick(Sender: TObject);
begin
TemplateRichEdit.CopyToClipboard;
end;
procedure TTemplateManagerForm.PasteClick(Sender: TObject);
begin
TemplateRichEdit.PasteFromClipboard;
end;
procedure TTemplateManagerForm.FontNameChange(Sender: TObject);
begin
if FUpdating then Exit;
CurrText.Name := FontName.Items[FontName.ItemIndex];
end;
procedure TTemplateManagerForm.FontSizeChange(Sender: TObject);
begin
if FUpdating then Exit;
CurrText.Size := StrToInt(FontSize.Text);
end;
procedure TTemplateManagerForm.BoldButtonClick(Sender: TObject);
begin
if FUpdating then Exit;
if BoldButton.Down then
CurrText.Style := CurrText.Style + [fsBold]
else
CurrText.Style := CurrText.Style - [fsBold];
end;
procedure TTemplateManagerForm.ItalicButtonClick(Sender: TObject);
begin
if FUpdating then Exit;
if ItalicButton.Down then
CurrText.Style := CurrText.Style + [fsItalic]
else
CurrText.Style := CurrText.Style - [fsItalic];
end;
procedure TTemplateManagerForm.UnderlineButtonClick(Sender: TObject);
begin
if FUpdating then Exit;
if UnderlineButton.Down then
CurrText.Style := CurrText.Style + [fsUnderline]
else
CurrText.Style := CurrText.Style - [fsUnderline];
end;
procedure TTemplateManagerForm.AlignButtonClick(Sender: TObject);
begin
if FUpdating then Exit;
TemplateRichEdit.Paragraph.Alignment := TAlignment(TControl(Sender).Tag);
end;
procedure TTemplateManagerForm.BulletsButtonClick(Sender: TObject);
begin
if FUpdating then Exit;
TemplateRichEdit.Paragraph.Numbering := TNumberingStyle(BulletsButton.Down);
end;
procedure TTemplateManagerForm.CancelButtonClick(Sender: TObject);
begin
if FImport then
begin
if MessageDlg('Exit without importing a template?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
Close;
end
else
Close;
end;
procedure TTemplateManagerForm.SetImport(const Value: boolean);
begin
FImport := Value;
end;
procedure TTemplateManagerForm.SpellingButtonClick(Sender: TObject);
begin
AddictSpell31.CheckWinControl( TemplateRichEdit, ctAll );
end;
procedure TTemplateManagerForm.SpellingOptions1Click(Sender: TObject);
begin
AddictSpell31.Setup;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -