91 lines
2.5 KiB
C++
91 lines
2.5 KiB
C++
#ifndef WARD_H
|
||
#define WARD_H
|
||
|
||
#include <string>
|
||
#include <vector>
|
||
#include <algorithm>
|
||
|
||
enum class WardType {
|
||
Normal,
|
||
Special,
|
||
ICU
|
||
};
|
||
|
||
enum class BedStatus {
|
||
Free,
|
||
Occupied
|
||
};
|
||
|
||
// -------------------- Bed --------------------
|
||
class Bed {
|
||
public:
|
||
std::string BedID; // 床位唯一标识
|
||
std::string WardID; // 所属病房
|
||
BedStatus Status;
|
||
std::string PatientID; // 当前占用患者ID,如果空闲则为空字符串
|
||
|
||
Bed();
|
||
Bed(const std::string& bedID, const std::string& wardID);
|
||
bool isFree() const;
|
||
|
||
void assignPatient(const std::string& patientID);
|
||
void release();
|
||
|
||
// Generate UUID for new bed
|
||
static std::string generateUniqueId();
|
||
|
||
// JSON bridge (C++17 JsonValue)
|
||
class JsonValue toJson() const;
|
||
static Bed fromJson(const class JsonValue& v);
|
||
};
|
||
|
||
// -------------------- Ward --------------------
|
||
class Ward {
|
||
public:
|
||
std::string WardID; // 病房唯一标识
|
||
std::string DepartmentID; // 所属科室ID(来自 .tex:病房需要关联科室)
|
||
WardType Type; // 病房类型
|
||
int MaxBeds; // 最大床位数
|
||
std::vector<Bed> Beds; // 床位列表
|
||
|
||
Ward();
|
||
Ward(const std::string& wardID,
|
||
const std::string& departmentID,
|
||
WardType type,
|
||
int maxBeds);
|
||
|
||
// 查找第一个空闲床位:成功写入 outBedID 并返回 true;否则返回 false
|
||
bool getFreeBedID(std::string& outBedID) const;
|
||
|
||
// 住院分配:为患者分配“一个空闲床”,成功写入 outBedID 并返回 true;失败返回 false
|
||
bool admitPatient(const std::string& patientID, std::string& outBedID);
|
||
|
||
// 释放指定床位(出院/床位回收)
|
||
// 释放指定床位
|
||
bool releaseBed(const std::string& bedID);
|
||
|
||
// 释放“指定患者占用”的床位(便于 discharge 直接按 patientID 回收)
|
||
bool releasePatient(const std::string& patientID);
|
||
|
||
// 增减床位操作
|
||
bool addBed(const std::string& bedID);
|
||
bool removeBed(const std::string& bedID);
|
||
|
||
// 获取当前空闲床位数
|
||
int freeBedCount() const;
|
||
|
||
int occupiedBedCount() const;
|
||
|
||
// 当前床位使用率:occupied / MaxBeds(MaxBeds==0 时返回 0)
|
||
double occupancyRate() const;
|
||
|
||
// Generate UUID for new ward
|
||
static std::string generateUniqueId();
|
||
|
||
// JSON bridge (C++17 JsonValue)
|
||
class JsonValue toJson() const;
|
||
static Ward fromJson(const class JsonValue& v);
|
||
};
|
||
|
||
#endif
|