From 7c37eb24f9864d9949e2052abf393d30817c26ed Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期六, 19 七月 2025 14:54:07 +0800
Subject: [PATCH] ID1825-优化card组件

---
 src/store/type/bedsideAuxiliaryScreen.type.ts |  299 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 294 insertions(+), 5 deletions(-)

diff --git a/src/store/type/bedsideAuxiliaryScreen.type.ts b/src/store/type/bedsideAuxiliaryScreen.type.ts
index 7d1f409..8757549 100644
--- a/src/store/type/bedsideAuxiliaryScreen.type.ts
+++ b/src/store/type/bedsideAuxiliaryScreen.type.ts
@@ -1,3 +1,20 @@
+import { tryConvertToInt } from "@/utils/utils";
+import cache from '@/utils/cache';
+export interface IotInfo {
+  属性历史列表: any[];
+  床号: string;
+  状态列表: IotInfoStatus[];
+  设备唯一编号: string;
+  设备序列号: string;
+}
+
+export interface IotInfoStatus {
+  是否为警告标记: number;
+  状态名称: string;
+  状态类型: string;
+  状态颜色: string;
+}
+
 export interface ConsumablesCollection {
   抗凝剂: string[];
   护理包: string[];
@@ -8,10 +25,204 @@
   透析模式: string[];
 }
 
-export interface DeviceData {
+enum EPushType {
+  SPHYGMOMANOMETR = "床旁血压计",
+  CENTRAL_MONITORING = "中央监控大屏信息",
+}
+
+type PushType = "床旁血压计" | "中央监控大屏信息";
+
+export interface DialysisStatus {
+  clientCode: string;
+  deviceHospitalCode: string;
+  iot_传输时间: number | null;
+  iot_当前脱水量: number | null;
+  iot_脱水目标量: number | null;
+  iot_脱水速率: number | null;
+  iot_跨膜压: number | null;
+  iot_透析时间: number | null;
+  iot_静脉压: number | null;
+  sortOrder: number | null;
+  txTime: number | null;
+  上次透后称重: number | null;
+  体重增加: number | null;
+  体重增长率: number | null;
+  分区编号: string;
+  处方脱水量: number | null;
+  实时ktv: string;
+  实时ktv计算结果列表: null | string[];
+  实时脱水量: number | null;
+  干体重: number | null;
+  年龄: number | null;
+  异常检验指标: AnomalyIndex[] | null;
+  当前血温: number | null;
+  性别: string;
+  患者头像: string;
+  患者姓名: string;
+  患者来源: 0 | 1;
+  患者编号: string;
+  患者透析号: string;
+  患者门诊住院号: string;
+  抗凝剂列表: Anticoagulant[] | null;
+  护理包列表: string[] | null;
+  报警_脱水量设定不一致: boolean;
+  最后一条血压: number | null;
+  最近平均脱水量: string;
+  最近最大脱水量: string;
+  最近最大脱水量日期: string;
+  此次脱水量: number | null;
+  监测血压是否低于百分之30: boolean;
+  监测血压是否高于百分之30: boolean;
+  监测记录列表: any[];
+  穿刺针列表: PunctureNeedle[] | null;
+  第一条血压: number | null;
+  管路列表: Piping[] | null;
+  置换方式: string;
+  脉搏列表: any[] | null;
+  血压低值列表: any[] | null;
+  血管通路列表: VascularAccess[] | null;
+  设备分区位置: any;
+  设备分区类型: number | null;
+  设备号: string;
+  设备名称: string;
+  设备序列号: string;
+  设备状态列表: IotInfoStatus[] | null;
+  设备编号: string;
+  超滤速度过快: boolean;
+  跨膜压列表: any[] | null;
+  跨膜压是否大于200: boolean;
+  跨膜压是否小于0: boolean;
+  透前称重: number | null;
+  透前脉搏: number | null;
+  透前血压_伸缩压: number | null;
+  透前血压_舒张压: number | null;
+  透析单医嘱列表: number | null;
+  透析单编号: string | null;
+  透析器: string;
+  透析器列表: Dialyzer[] | null;
+  透析处方是否已确认: number;
+  透析处方的时长: number | null;
+  透析处方的时长_分钟: string;
+  透析处方的时长_小时: string;
+  透析开始时间: number | null;
+  透析方案: string;
+  透析液列表: any[];
+  透析状态: string; // '0.0'这种格式的,得格式化一下
+  透析结束时间: string | null;
+}
+
+export interface VascularAccess {
+  位置: string;
+  类型: string;
+}
+
+export interface Dialyzer extends Anticoagulant {}
+
+export interface Piping extends Anticoagulant {}
+
+export interface PunctureNeedle extends Anticoagulant {}
+
+export interface Anticoagulant {
+  name: string;
+  单位: string;
+  数量: number | null;
+}
+
+export interface AnomalyIndex {
+  单位: string;
+  参考值: string;
+  结果标记: string;
+  项目名称: string;
+  项目结果: string;
+}
+
+export interface SseMsgData {
+  IOT信息: IotInfo | null;
+  使用耗材字典: ConsumablesCollection | null; // 当透析状态为治疗中时该字段为null
+  倒计时: "";
+  推送类型: PushType;
+  透析状态: DialysisStatus | null;
+}
+
+export interface BedsideAuxiliaryScreen {
   devicdeNo: string | number;
+  recordCode: string;
+  patientCode: string;
   patientName: string;
+  patientPhone: string;
+  age: string;
+  gender: string;
+  patForm: PatForm;
+  patFormNumber: string;
+  treatmentStatus: MedStatus;
   consumablesCollection: ConsumablesCollection;
+  pageType: PageType;
+  notSignedIn: NotSignedIn;
+}
+
+export enum EPageType {
+  NOT_INIT = 0, // 未初始化(没有设备编号)
+  LOADING = 1, // 加载中
+  UNPLANNED_SCHEDULE = 2, // 未排班
+  NOT_SIGNED_IN = 3, // 未签到
+  SIGNED_IN = 4, // 已签到
+  DURING_DIALYSIS = 5, // 透析中
+  SPHYGMOMANOMETER = 6, // 床旁血压计
+}
+
+export type PageType =
+  | EPageType.NOT_INIT
+  | EPageType.LOADING
+  | EPageType.UNPLANNED_SCHEDULE
+  | EPageType.NOT_SIGNED_IN
+  | EPageType.SIGNED_IN
+  | EPageType.DURING_DIALYSIS
+  | EPageType.SPHYGMOMANOMETER;
+
+export enum EMedStatus {
+  /** 未签到 */
+  NOT_CHECKED_IN = 0,
+  /** 已签到 */
+  SIGNED_IN = 1,
+  /** 透析中 */
+  DURING_DIALYSIS = 2,
+  /** 已结束 */
+  END = 2.5,
+  /** 已检查 */
+  CHECKED = 3,
+  /** 已归档 */
+  ARCHIVED = 4,
+}
+
+export type MedStatus =
+  | EMedStatus.NOT_CHECKED_IN
+  | EMedStatus.SIGNED_IN
+  | EMedStatus.DURING_DIALYSIS
+  | EMedStatus.END
+  | EMedStatus.CHECKED
+  | EMedStatus.ARCHIVED;
+
+export enum EPatForm {
+  OUTPATIENT_SERVICE = 0,
+  BE_IN_HOSPITAL = 1,
+}
+
+export type PatForm = EPatForm.BE_IN_HOSPITAL | EPatForm.OUTPATIENT_SERVICE;
+
+export interface NotSignedIn {
+  dialysisMode: string;
+  dialyzerList: Dialyzer[];
+  pipingList: Piping[];
+  dialysateList: any[];
+  anticoagulant: {
+    name: string;
+    unit: string;
+    firstAndAddition: string;
+    total: string;
+  }[];
+  carePackage: any[];
+  punctureNeedle: PunctureNeedle[];
+  vascularAccess: VascularAccess[];
 }
 
 export const defaultconsumablesCollection = (): ConsumablesCollection => {
@@ -26,10 +237,88 @@
   };
 };
 
-export const defaultDeviceData = (): DeviceData => {
+export const defalutNotSignedIn = (): NotSignedIn => {
   return {
-    devicdeNo: "",
-    patientName: "",
-    consumablesCollection: defaultconsumablesCollection(),
+    dialysisMode: "", // 透析模式
+    dialyzerList: [], // 透析器列表
+    pipingList: [], // 一次性使用管路列表
+    dialysateList: [], // 透析液列表
+    anticoagulant: [], // 抗凝剂列表
+    carePackage: [], // 一次性使用透析护理包列表
+    punctureNeedle: [], // 穿刺针列表
+    vascularAccess: [], // 血管通路列表
   };
 };
+
+export const defaultDeviceData = (): BedsideAuxiliaryScreen => {
+  const pageType = cache.get('devcieCode') ? EPageType.LOADING : EPatForm.OUTPATIENT_SERVICE;
+  return {
+    devicdeNo: "", // 设备号
+    recordCode: "", // 透析单code
+    patientCode: "", // 患者code
+    patientName: "", // 患者姓名
+    patientPhone: "", // 患者头像
+    age: "", // 年龄
+    gender: "", // 性别
+    patForm: EPatForm.OUTPATIENT_SERVICE, // 患者来源
+    patFormNumber: "", // 住院门诊号
+    // @ts-ignore
+    pageType, // 当前要展示的页面
+    treatmentStatus: EMedStatus.NOT_CHECKED_IN, // 透析状态
+    consumablesCollection: defaultconsumablesCollection(), // 未排班时需要的数据
+    notSignedIn: defalutNotSignedIn(), // 未签到时需要的数据
+  };
+};
+
+export const formatDeviceData = (
+  seeMsg: SseMsgData
+): BedsideAuxiliaryScreen => {
+  const result = defaultDeviceData();
+
+  // 默认床号(设备号)
+  result.devicdeNo = seeMsg.IOT信息?.床号;
+
+  if (seeMsg.推送类型 === EPushType.SPHYGMOMANOMETR) {
+    result.pageType = EPageType.SPHYGMOMANOMETER;
+  } else if (seeMsg.推送类型 === EPushType.CENTRAL_MONITORING) {
+    // 判断是否存在透析状态,如果不存在就是没有排班
+    if (seeMsg.透析状态 === null || !seeMsg.透析状态) {
+      result.pageType = EPageType.UNPLANNED_SCHEDULE;
+      result.consumablesCollection =
+        seeMsg?.使用耗材字典 || defaultconsumablesCollection();
+    } else {
+
+      const treatmentStatus = tryConvertToInt(seeMsg.透析状态?.透析状态) as  MedStatus;
+
+      // 这里就是有排班的
+      result.treatmentStatus = treatmentStatus;
+      result.recordCode = seeMsg.透析状态?.透析单编号;
+      result.patientCode = seeMsg.透析状态?.患者编号;
+      result.patientName = seeMsg.透析状态?.患者姓名;
+      result.patientPhone = seeMsg.透析状态?.患者头像;
+      result.age = seeMsg.透析状态?.年龄 + '';
+      result.gender = seeMsg.透析状态?.性别 + '';
+      result.patForm = seeMsg.透析状态?.患者来源;
+      result.patFormNumber = seeMsg.透析状态?.患者门诊住院号;
+
+      switch(treatmentStatus) {
+        case EMedStatus.NOT_CHECKED_IN:
+          result.pageType = EPageType.NOT_SIGNED_IN;
+          const notSignedIn = {
+            dialysisMode: seeMsg.透析状态?.透析方案,
+            dialyzerList: seeMsg.透析状态?.透析器列表,
+            pipingList: seeMsg.透析状态?.管路列表,
+            dialysateList: seeMsg.透析状态?.透析液列表,
+            carePackage: seeMsg.透析状态?.护理包列表,
+            punctureNeedle: seeMsg.透析状态?.穿刺针列表,
+            vascularAccess: seeMsg.透析状态?.血管通路列表,
+            anticoagulant: [],
+          }
+          result.notSignedIn = notSignedIn;
+          break
+      }
+
+    }
+  }
+  return result;
+};

--
Gitblit v1.8.0