312 lines
13 KiB
C#
312 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Sarand.Win.Forms.Controls;
|
|
using Sarand.Win.Forms.Utils;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.App;
|
|
using Sarand.PatientMgr.Core.Bus;
|
|
using Sarand.PatientMgr.Core.App;
|
|
using Sarand.PatientMgr.Win.Forms.Base;
|
|
using Sarand.Core.Dbas.Base;
|
|
using Sarand.Core.Security;
|
|
using Sarand.PatientMgr.Win.Forms.App;
|
|
|
|
namespace Sarand.PatientMgr.Win.Forms.Config
|
|
{
|
|
//=======================================================================
|
|
public partial class SpmPanel_Config_Menu : SacsHtmlPanel
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Configuration.
|
|
public new class Config : SacsHtmlPanel.Config
|
|
{
|
|
public SpmForm_Config ConfigForm { get; set; }
|
|
public SpmForm AdmissionListForm { get; set; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private Config config = null;
|
|
private bool appCmdInProgress = false;
|
|
private static String AppCmd_AdmClose = "AdmClose";
|
|
private static String AppCmd_AdmRefresh = "AdmRefresh";
|
|
private static String AppCmd_AdmSecurity = "AdmSecurity";
|
|
private static String AppCmd_AdmCodeTypes = "AdmCodeTypes";
|
|
private static String AppCmd_AdmExport = "AdmExport";
|
|
private static String AppCmd_AdmStatistics = "AdmStatistics";
|
|
private static String AppCmd_AdmDatabase = "AdmDatabase";
|
|
private static String AppCmd_Departments = "Departments";
|
|
private static String AppCmd_Operations = "Operations";
|
|
private static String AppCmd_Employees = "Employees";
|
|
private static String AppCmd_Patients = "Patients";
|
|
private static String AppCmd_Procedures = "Procedures";
|
|
private static String AppCmd_EmployeeRoles = "EmployeeRoles";
|
|
private static String AppCmd_FacilityTemplates = "FacilityTemplates";
|
|
private static String AppCmd_PatientSearch = "PatientSearch";
|
|
private static String AppCmd_WaitingList = "WaitingList";
|
|
private static String AppCmd_RequiredActions = "RequiredActions";
|
|
private static String AppCmd_CancelTimeLimit = "CancelTimeLimit";
|
|
private static String AppCmd_CancelOther = "CancelOther";
|
|
private static String AppCmd_Deletions = "Deletions";
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
private SpmPanel_Config_Menu () : this(new Config()) { }
|
|
public SpmPanel_Config_Menu (Config config) : base(config)
|
|
{
|
|
this.config = config;
|
|
InitializeComponent();
|
|
}
|
|
protected override void Dispose (bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
if (components != null) components.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public bool HasActiveProcess { get { return appCmdInProgress; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// I n i t i a l i s a t i o n
|
|
//-------------------------------------------------------------------
|
|
protected override void OnCreateControl ()
|
|
{
|
|
base.OnCreateControl();
|
|
if (this.IsDesignerHosted()) return;
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// R e f r e s h P a n e l
|
|
//-------------------------------------------------------------------
|
|
public void RefreshPanel ()
|
|
{
|
|
List<String> body = new List<string>();
|
|
body.Add("<div class='Title'>Sarand<br/>Patient Manager</div>");
|
|
|
|
// Institution.
|
|
SpmInstitution institution = config.ConfigForm.InstitutionMgr.GetInstitution();
|
|
if (institution != null)
|
|
{
|
|
body.Add("<div class='Caption'>Institution</div>");
|
|
body.Add("<div class='Institution'>" + institution.Name + "</div>");
|
|
institution.Dispose(); institution = null;
|
|
}
|
|
|
|
if (config.ConfigForm != null)
|
|
{
|
|
// Configuration options:
|
|
body.Add("<div class='Caption'>Configuration</div>");
|
|
body.Add(BuildMenuOpt(AppCmd_Departments, "Departments"));
|
|
body.Add(BuildMenuOpt(AppCmd_FacilityTemplates, "Session templates"));
|
|
body.Add(BuildMenuOpt(AppCmd_Operations, "Operations"));
|
|
body.Add(BuildMenuOpt(AppCmd_Procedures, "Procedures"));
|
|
body.Add(BuildMenuOpt(AppCmd_Patients, "Patients"));
|
|
body.Add(BuildMenuOpt(AppCmd_Employees, "Employees"));
|
|
body.Add(BuildMenuOpt(AppCmd_EmployeeRoles, "Employee roles"));
|
|
|
|
// Application options.
|
|
body.Add("<div class='Caption'>Application</div>");
|
|
body.Add(BuildMenuOpt(AppCmd_AdmRefresh, "Refresh", false));
|
|
if (config.ConfigForm.SecurityProfile.Admin.CanManageSecurity())
|
|
body.Add(BuildMenuOpt(AppCmd_AdmSecurity, "Security", false));
|
|
body.Add(BuildMenuOpt(AppCmd_AdmExport, "Export", false));
|
|
body.Add(BuildMenuOpt(AppCmd_AdmStatistics, "Statistics", false));
|
|
if (config.ConfigForm.SecurityProfile.Admin.CanManageDatabase())
|
|
{
|
|
ISacsDatabase database = SpmGlobals.Application.GetDatabase(config.ConfigForm.SessionContext);
|
|
if (database != null && database.DbmsType == DbmsType.Access)
|
|
body.Add(BuildMenuOpt(AppCmd_AdmDatabase, "Db housekeeping", false));
|
|
}
|
|
if (config.ConfigForm.SecurityProfile.Admin.CanManageConfig() && config.ConfigForm.CodeTypeConsole != null)
|
|
body.Add(BuildMenuOpt(AppCmd_AdmCodeTypes, "Codes", false));
|
|
}
|
|
else if (config.AdmissionListForm != null)
|
|
{
|
|
// Admission Lists options.
|
|
body.Add("<div class='Caption'>Admission Lists</div>");
|
|
body.Add(BuildMenuOpt(AppCmd_PatientSearch, "Patient Search"));
|
|
body.Add(BuildMenuOpt(AppCmd_WaitingList, "Waiting List"));
|
|
body.Add(BuildMenuOpt(AppCmd_RequiredActions, "Required Actions"));
|
|
body.Add(BuildMenuOpt(AppCmd_CancelTimeLimit, "Cancellations - 28 day"));
|
|
body.Add(BuildMenuOpt(AppCmd_CancelOther, "Cancellations - other"));
|
|
body.Add(BuildMenuOpt(AppCmd_Deletions, "Deletions"));
|
|
|
|
// Action options:
|
|
body.Add("<div class='Caption'>Actions</div>");
|
|
foreach (SacsCommand item in new List<SacsCommand>()) //config.AdmissionListForm.GetMenuItems())
|
|
body.Add(BuildMenuOpt(item.CommandId, item.Caption, false));
|
|
}
|
|
body.Add(BuildMenuOpt(AppCmd_AdmClose, "Close", false));
|
|
|
|
if (DocumentPopulated)
|
|
{
|
|
SetDocumentBody(body.Concat("\n"));
|
|
}
|
|
else
|
|
{
|
|
List<String> html = new List<string>();
|
|
html.Add("<html><head>" + GetMenuStyle() + GetMenuScript() + "</head><body>");
|
|
html.AddRange(body);
|
|
html.Add("</body></html>");
|
|
|
|
SetDocumentHtml(html.Concat("\n"));
|
|
DocumentPopulated = true;
|
|
}
|
|
}
|
|
private String BuildMenuOpt (String command, String display, bool panelOption = true)
|
|
{
|
|
// Is this the currently selected option:
|
|
bool currentOption = false;
|
|
if (panelOption)
|
|
{
|
|
if (config.ConfigForm != null) currentOption = GetConfigPanelType(command) == config.ConfigForm.PanelType;
|
|
else if (config.AdmissionListForm != null) currentOption = false; // GetAdmissionsPanelType(command) == config.AdmissionListForm.PanelType;
|
|
}
|
|
// Build the menu option:
|
|
String option = "";
|
|
option += currentOption ? "<b>" : "<a class='Mnu' href='" + AppHrefPrefix + command + "'>";
|
|
option += display;
|
|
option += currentOption ? "</b>" : "</a>";
|
|
option += "<br>";
|
|
return option;
|
|
}
|
|
private String GetMenuStyle ()
|
|
{
|
|
List<String> style = new List<string>();
|
|
style.Add("<style>" + SacsResourceConsole.GetTextResource(SacsResourceConsole.TextResource.SaBaseCss) + "</style>");
|
|
style.Add("<style>");
|
|
style.Add("*{font-size:14px;font-family:'sans-serif';color:#303080;background-color:#A0D0A0;scrollbar-base-color:#A0D0A0;}");
|
|
style.Add("body{padding:4;margin:0;background-color:#A0D0A0;overflow-y:auto;}");
|
|
style.Add("p{font-size:14px;margin-top:15px;margin-bottom:5px;}");
|
|
style.Add("td{font-size:14px;vertical-align:top;}");
|
|
style.Add(".Title{margin:4px 0;padding-left:32px;font-weight:bold;font-size:20px;background-image:url('" + GetImageUri(SpmResourceConsole.GetImageResource(SpmResourceConsole.ImageResource.PatientMgr_Icon_gif), "png") + "');background-position:left top;background-repeat:no-repeat;}");
|
|
style.Add(".Caption{margin-top:5px;margin-bottom:5px;padding:3px;font-size:16px;font-weight:bold;text-align:center;color:#E0E0FF;background-color:#6060E0;}");
|
|
style.Add(".Institution{margin-top:2px;margin-bottom:2px;font-weight:bold;font-size:14px;text-align:center;}");
|
|
style.Add(".SuperScript{font-size:66%;position:relative;top:-5px;}");
|
|
style.Add(".Body{text-align:left;padding-left:5%;}");
|
|
style.Add("A:link,A:visited,A:active{line-height:150%;font-weight:normal;text-decoration:none;padding:3px;}");
|
|
style.Add("A.Mnu:link,A.Mnu:visited,A.Mnu:active{font-size:13px;text-align:center;}");
|
|
style.Add("A:hover,A.Mnu:hover{font-weight:bold;padding-left:0px;padding-right:0px;}");
|
|
style.Add("</style>");
|
|
return style.Concat("\n");
|
|
}
|
|
private String GetMenuScript ()
|
|
{
|
|
List<String> script = new List<string>();
|
|
return script.Concat("\n");
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a n e l E v e n t s
|
|
//-------------------------------------------------------------------
|
|
protected override void OnAppAction (string action)
|
|
{
|
|
Logger.Debug("OnAppAction Action: " + action);
|
|
bool optionProcessed = false;
|
|
if (action.EqualsCI(AppCmd_AdmClose))
|
|
{
|
|
if (config.ConfigForm != null) config.ConfigForm.Close();
|
|
else if (config.AdmissionListForm != null) config.AdmissionListForm.Close();
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmRefresh))
|
|
{
|
|
if (config.ConfigForm != null) config.ConfigForm.RefreshView();
|
|
//else if (config.AdmissionListForm != null) config.AdmissionListForm.RefreshView();
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmSecurity))
|
|
{
|
|
SaSecurityConsole securityConsole = config.ConfigForm?.SecurityConsole ?? config.AdmissionListForm?.SecurityConsole ?? null;
|
|
SpmSecurityProfile securityProfile = config.ConfigForm?.SecurityProfile ?? config.AdmissionListForm?.SecurityProfile ?? null;
|
|
if (securityConsole == null || securityProfile == null) return;
|
|
securityConsole.ManageSecurity(securityProfile.Admin.CanManageSecurity(), SpmGlobals_Win.UserContext.DbUpdateInfo);
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmCodeTypes))
|
|
{
|
|
// ToDo Code Types options.
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmExport))
|
|
{
|
|
// ToDo Export options.
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmStatistics))
|
|
{
|
|
// ToDo Export options.
|
|
optionProcessed = true;
|
|
}
|
|
else if (action.EqualsCI(AppCmd_AdmDatabase))
|
|
{
|
|
// No longer required - database now SQL rather than Access.
|
|
// Unless SQL database housekeeping could be invoked.
|
|
optionProcessed = true;
|
|
}
|
|
else if (config.ConfigForm != null)
|
|
{
|
|
// Flag to avoid other commands during length processing:
|
|
appCmdInProgress = true;
|
|
SpmForm_Config.ConfigPanelType panelType = GetConfigPanelType (action);
|
|
if (panelType != SpmForm_Config.ConfigPanelType.Unknown)
|
|
{
|
|
config.ConfigForm.PanelType = panelType;
|
|
RefreshPanel();
|
|
}
|
|
optionProcessed = true;
|
|
}
|
|
else if (config.AdmissionListForm != null)
|
|
{
|
|
// Flag to avoid other commands during length processing (eg. multiple deletions):
|
|
appCmdInProgress = true;
|
|
// ToDo Admission List actions.
|
|
/*
|
|
SwmDlgAdmissionLists::eSwmAdmissionsPanel ePanel = SwmPanelMenu::PanelForAdmissionsCmd (sCmd);
|
|
if (ePanel != SwmDlgAdmissionLists::ePanelUnknown)
|
|
{
|
|
pDlgAdmLists->SetAdmissionsPanel(ePanel);
|
|
Refresh();
|
|
optionProcessed = true;
|
|
}
|
|
else
|
|
{
|
|
bOptionProcessed = pDlgAdmLists->DoMenuOption(String(sCmd).AsLong());
|
|
SetFocus();
|
|
}
|
|
*/
|
|
optionProcessed = true;
|
|
}
|
|
appCmdInProgress = false;
|
|
//base.OnAppAction(action);
|
|
}
|
|
private SpmForm_Config.ConfigPanelType GetConfigPanelType (String command)
|
|
{
|
|
if (config.ConfigForm == null) return SpmForm_Config.ConfigPanelType.Unknown;
|
|
if (command.EqualsCI(AppCmd_Departments)) return SpmForm_Config.ConfigPanelType.Departments;
|
|
if (command.EqualsCI(AppCmd_Operations)) return SpmForm_Config.ConfigPanelType.Operations;
|
|
if (command.EqualsCI(AppCmd_Employees)) return SpmForm_Config.ConfigPanelType.Employees;
|
|
if (command.EqualsCI(AppCmd_Patients)) return SpmForm_Config.ConfigPanelType.Patients;
|
|
if (command.EqualsCI(AppCmd_Procedures)) return SpmForm_Config.ConfigPanelType.Procedures;
|
|
if (command.EqualsCI(AppCmd_EmployeeRoles)) return SpmForm_Config.ConfigPanelType.EmployeeRoles;
|
|
if (command.EqualsCI(AppCmd_FacilityTemplates)) return SpmForm_Config.ConfigPanelType.FacilityTemplates;
|
|
return SpmForm_Config.ConfigPanelType.Unknown;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|