62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
#ifndef MEDICINE_H
|
|
#define MEDICINE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
|
|
class JsonValue;
|
|
|
|
class Medicine {
|
|
public:
|
|
// 与 Patient / Doctor 保持一致的公开字段
|
|
std::string MedicineID; // 唯一主键
|
|
std::string GenericName; // 通用名
|
|
std::string BrandName; // 商品名
|
|
std::vector<std::string> Aliases; // 别名(可能多个)
|
|
int StockQuantity; // 当前库存数量
|
|
std::string DepartmentID; // 所属科室ID
|
|
double UnitPrice; // 单价
|
|
|
|
// 构造函数
|
|
Medicine();
|
|
Medicine(const std::string& id, const std::string& generic, const std::string& brand,
|
|
const std::vector<std::string>& aliasList, int stock, const std::string& dept, double price);
|
|
|
|
// 与 Patient 类似的业务方法
|
|
bool updateBasicInfo(const std::string& generic,
|
|
const std::string& brand,
|
|
const std::vector<std::string>& aliasList,
|
|
int stock,
|
|
const std::string& dept,
|
|
double price);
|
|
|
|
bool nameMatches(const std::string& keyword) const;
|
|
|
|
// Generate UUID for new medicine
|
|
static std::string generateUniqueId();
|
|
|
|
// JSON 桥接接口
|
|
JsonValue toJson() const;
|
|
static Medicine fromJson(const JsonValue& v);
|
|
|
|
// 兼容旧代码
|
|
std::string getMedicineID() const;
|
|
void setMedicineID(const std::string& id);
|
|
std::string getGenericName() const;
|
|
void setGenericName(const std::string& name);
|
|
std::string getBrandName() const;
|
|
void setBrandName(const std::string& name);
|
|
std::vector<std::string> getAliases() const;
|
|
void setAliases(const std::vector<std::string>& aliasList);
|
|
void addAlias(const std::string& alias);
|
|
int getStockQuantity() const;
|
|
void setStockQuantity(int stock);
|
|
bool decreaseStock(int amount);
|
|
std::string getDepartmentID() const;
|
|
void setDepartmentID(const std::string& dept);
|
|
double getUnitPrice() const;
|
|
void setUnitPrice(double price);
|
|
};
|
|
|
|
#endif |