248 lines
6.8 KiB
C++
248 lines
6.8 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include <QMainWindow>
|
|
#include <QString>
|
|
|
|
#include "utils/logger.h"
|
|
|
|
namespace core {
|
|
class HisCore;
|
|
}
|
|
|
|
class QTabWidget;
|
|
class QStackedWidget;
|
|
class QListWidget;
|
|
class QTextEdit;
|
|
class QLabel;
|
|
class QTableWidget;
|
|
class QTreeWidget;
|
|
class QTreeWidgetItem;
|
|
class QPushButton;
|
|
class QLineEdit;
|
|
class QComboBox;
|
|
|
|
class MainWindow : public QMainWindow {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainWindow(core::HisCore& core, QWidget* parent = nullptr);
|
|
~MainWindow() override;
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent* event) override;
|
|
|
|
// 视角枚举
|
|
enum class ViewRole {
|
|
Admin, // 管理视角 - 所有都可以看到
|
|
Patient, // 病人视角 - 只能看到医生
|
|
Medical // 医护视角
|
|
};
|
|
|
|
private:
|
|
core::HisCore& core_;
|
|
|
|
QString dataFolder_; // Store data folder path for saving
|
|
ViewRole currentRole_; // 当前视角
|
|
|
|
QTabWidget* tabWidget_;
|
|
QStackedWidget* contentStack_;
|
|
QListWidget* navList_;
|
|
|
|
QWidget* dashboardTab_;
|
|
QWidget* wardsTab_;
|
|
QWidget* patientsTab_;
|
|
QWidget* doctorsTab_;
|
|
QWidget* medicinesTab_;
|
|
QWidget* checksTab_;
|
|
QWidget* departmentsTab_;
|
|
|
|
QLabel* summaryLabel_;
|
|
|
|
// Dashboard stat cards
|
|
QWidget* wardStatCard_;
|
|
QWidget* patientStatCard_;
|
|
QWidget* doctorStatCard_;
|
|
QWidget* medicineStatCard_;
|
|
QWidget* checkStatCard_;
|
|
|
|
// Ward widgets
|
|
QTreeWidget* wardTreeView_;
|
|
QLineEdit* wardSearchBox_;
|
|
|
|
QTableWidget* wardTable_;
|
|
QLineEdit* patientSearchBox_;
|
|
QTableWidget* patientTable_;
|
|
QLineEdit* doctorSearchBox_;
|
|
QTableWidget* doctorTable_;
|
|
QLineEdit* medicineSearchBox_;
|
|
QTableWidget* medicineTable_;
|
|
QLineEdit* checkSearchBox_;
|
|
QTableWidget* checkTable_;
|
|
QTextEdit* patientCaseDetail_;
|
|
|
|
// Department widgets
|
|
QLineEdit* departmentSearchBox_;
|
|
QTableWidget* departmentTable_;
|
|
|
|
// Save button
|
|
QPushButton* saveButton_;
|
|
|
|
// 视角选择
|
|
QComboBox* roleComboBox_;
|
|
|
|
// Ward control buttons
|
|
QPushButton* wardAddButton_;
|
|
QPushButton* wardEditButton_;
|
|
QPushButton* wardDeleteButton_;
|
|
QPushButton* wardAddBedButton_;
|
|
QPushButton* wardDeleteBedButton_;
|
|
QPushButton* wardOccupancyButton_;
|
|
|
|
// Patient control buttons
|
|
QPushButton* patientAddButton_;
|
|
QPushButton* patientEditButton_;
|
|
QPushButton* patientRemoveButton_;
|
|
QPushButton* patientViewCaseButton_;
|
|
QPushButton* patientAdmitButton_;
|
|
QPushButton* patientDischargeButton_;
|
|
QPushButton* patientPaymentButton_; // 缴费按钮
|
|
QPushButton* patientAddDiagnosisButton_;
|
|
QPushButton* patientAddSurgeryRecordButton_; // Add surgery record
|
|
QPushButton* patientAddMedicineRecordButton_; // Add medicine record
|
|
QPushButton* patientAddAdmissionRecordButton_; // Add admission record
|
|
QPushButton* patientRegistrationButton_; // Registration (挂号)
|
|
|
|
// Doctor control buttons
|
|
QPushButton* doctorAddButton_;
|
|
QPushButton* doctorEditButton_;
|
|
QPushButton* doctorRemoveButton_;
|
|
|
|
// Medicine control buttons
|
|
QPushButton* medicineAddButton_;
|
|
QPushButton* medicineUpdateButton_;
|
|
QPushButton* medicineRemoveButton_;
|
|
QPushButton* medicineIncreaseStockButton_;
|
|
QPushButton* medicineDecreaseStockButton_;
|
|
|
|
// Check control buttons
|
|
QPushButton* checkAddButton_;
|
|
QPushButton* checkUpdateButton_;
|
|
QPushButton* checkRemoveButton_;
|
|
QPushButton* patientAddCheckRecordButton_; // Add check record
|
|
|
|
// Department control buttons
|
|
QPushButton* departmentAddButton_;
|
|
QPushButton* departmentEditButton_;
|
|
QPushButton* departmentRemoveButton_;
|
|
|
|
// Logger and Log Tab
|
|
Logger logger_;
|
|
QWidget* logsTab_;
|
|
QTextEdit* logDisplay_;
|
|
QPushButton* logRefreshButton_;
|
|
QPushButton* logClearButton_;
|
|
QPushButton* logExportButton_;
|
|
|
|
void setupUI();
|
|
void setupDashboardTab();
|
|
void setupWardsTab();
|
|
void setupPatientsTab();
|
|
void setupDoctorsTab();
|
|
void setupMedicinesTab();
|
|
void setupChecksTab();
|
|
void setupDepartmentsTab();
|
|
void setupLogsTab();
|
|
|
|
void refreshDashboard();
|
|
void refreshWardTable();
|
|
void refreshPatientTable();
|
|
void refreshDoctorTable();
|
|
void refreshMedicineTable();
|
|
void refreshCheckTable();
|
|
void refreshDepartmentTable();
|
|
|
|
void updatePatientCaseDetail();
|
|
|
|
// Cell change handlers to sync edits back to core
|
|
void onPatientCellChanged(int row, int column);
|
|
void onDoctorCellChanged(int row, int column);
|
|
void onMedicineCellChanged(int row, int column);
|
|
|
|
bool loadDataFromFiles();
|
|
|
|
private slots:
|
|
void handleReloadAction();
|
|
void handleSaveData();
|
|
void onWardItemDoubleClicked(QTreeWidgetItem* item, int column);
|
|
void onRoleChanged(int index);
|
|
void updateUIForRole();
|
|
|
|
// Search/Filter slots
|
|
void onWardSearch(const QString& text);
|
|
void onPatientSearch(const QString& text);
|
|
void onDoctorSearch(const QString& text);
|
|
void onMedicineSearch(const QString& text);
|
|
void onCheckSearch(const QString& text);
|
|
void onDepartmentSearch(const QString& text);
|
|
|
|
// Ward slots
|
|
void handleAddWard();
|
|
void handleEditWard();
|
|
void handleDeleteWard();
|
|
void handleAddBed();
|
|
void handleDeleteBed();
|
|
void handleWardOccupancy();
|
|
|
|
// Patient slots
|
|
void handleAddPatient();
|
|
void handleEditPatient();
|
|
void handleRemovePatient();
|
|
void handleViewPatientCase();
|
|
void handleAdmitPatient();
|
|
void handleDischargePatient();
|
|
void handlePatientPayment(); // 缴费处理函数
|
|
void handleAddDiagnosisRecord();
|
|
void handleAddSurgeryRecord(); // Add surgery record
|
|
void handleAddMedicineRecord(); // Add medicine record with pharmacy stock reduction
|
|
void handleAddAdmissionRecord(); // Add admission record
|
|
void handleRegistration(); // Registration (挂号)
|
|
|
|
// Doctor slots
|
|
void handleAddDoctor();
|
|
void handleEditDoctor();
|
|
void handleRemoveDoctor();
|
|
|
|
// Medicine slots
|
|
void handleAddMedicine();
|
|
void handleUpdateMedicine();
|
|
void handleRemoveMedicine();
|
|
void handleIncreaseMedicineStock();
|
|
void handleDecreaseMedicineStock();
|
|
|
|
// Check slots
|
|
void handleAddCheck();
|
|
void handleUpdateCheck();
|
|
void handleRemoveCheck();
|
|
void handleAddCheckRecord(); // Add check record
|
|
|
|
// Department slots
|
|
void handleAddDepartment();
|
|
void handleEditDepartment();
|
|
void handleRemoveDepartment();
|
|
void handleViewDepartmentDetail(); // 新增:查看科室详情
|
|
void onDepartmentItemDoubleClicked(int row, int column); // 新增:双击科室行
|
|
|
|
// Log slots
|
|
void refreshLogDisplay();
|
|
void clearLogs();
|
|
void exportLogs();
|
|
|
|
// Helper methods for logging
|
|
void logOperation(LogEntryType type, const std::string& operation,
|
|
const std::string& details, const std::string& objectId = "");
|
|
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|