From 733cffd38e00b9cb80063251afb1890937586527 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期四, 31 七月 2025 14:48:52 +0800
Subject: [PATCH] Merge branch 'ID2716-血流量取值bug' into test

---
 src/store/type/bedsideAuxiliaryScreen.type.ts |  225 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 160 insertions(+), 65 deletions(-)

diff --git a/src/store/type/bedsideAuxiliaryScreen.type.ts b/src/store/type/bedsideAuxiliaryScreen.type.ts
index e6c18f8..86e2156 100644
--- a/src/store/type/bedsideAuxiliaryScreen.type.ts
+++ b/src/store/type/bedsideAuxiliaryScreen.type.ts
@@ -1,5 +1,5 @@
-import { tryConvertToInt } from "@/utils/utils";
-import cache from "@/utils/cache";
+import { tryConvertToInt, deepClone } from "@/utils/utils";
+import { Local } from "@/utils/storage";
 export interface IotInfo {
   属性历史列表: any[];
   床号: string;
@@ -32,6 +32,11 @@
 
 type PushType = "床旁血压计" | "中央监控大屏信息";
 
+export interface KtvItem {
+  时间: string;
+  ktv: string;
+}
+
 export interface DialysisStatus {
   clientCode: string;
   deviceHospitalCode: string;
@@ -39,9 +44,11 @@
   iot_当前脱水量: number | null;
   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;
@@ -50,7 +57,10 @@
   分区编号: string;
   处方脱水量: number | null;
   实时ktv: string;
-  实时ktv计算结果列表: null | string[];
+  实时ktv计算结果列表: null | {
+    realTimeKtvCalcDetailResultInfo: KtvItem[];
+    透析单编号: string;
+  };
   实时脱水量: number | null;
   干体重: number | null;
   年龄: number | null;
@@ -109,6 +119,10 @@
   透析液列表: any[];
   透析状态: string; // '0.0'这种格式的,得格式化一下
   透析结束时间: number | null;
+  透析处方备注: string;
+  最近最大脱水量透析时长: string;
+  透析龄: number | null;
+  iot_血液流速: number | null;
 }
 
 export interface VascularAccess {
@@ -147,15 +161,30 @@
   项目结果: string;
 }
 
+export interface Countdown {
+  当前服务器时间?: string;
+  提醒文本?: string;
+  提醒文本字典?: any[];
+  设定提醒倒计时?: number;
+}
+
 export interface SseMsgData {
   IOT信息: IotInfo | null;
   使用耗材字典: ConsumablesCollection | null; // 当透析状态为治疗中时该字段为null
-  倒计时: "";
+  倒计时: Countdown | null;
   推送类型: PushType;
   透析状态: DialysisStatus | null;
+  床旁血压结果?: any;
+}
+
+export interface Sphygmomanometer {
+  sbp: number | null; // 高压
+  dbp: number | null; // 低压
+  pulseRate: number | null; // 心率
 }
 
 export interface BedsideAuxiliaryScreen {
+  deviceCode: string;
   devicdeNo: string | number;
   recordCode: string;
   patientCode: string;
@@ -171,7 +200,16 @@
   notSignedIn: NotSignedIn;
   signedIn: SignedIn;
   underTreatment: UnderTreatment;
+  sphygmomanometer: Sphygmomanometer;
 }
+
+export const defaultSphygmomanometer = () :Sphygmomanometer => {
+  return {
+    sbp: null,
+    dbp: null,
+    pulseRate: null,
+  }
+} 
 
 export enum EPageType {
   NOT_INIT = 0, // 未初始化(没有设备编号)
@@ -271,6 +309,7 @@
   weightAfterLastDialysis: number | null; // 上次透后称重
   weightIncrease: number | null; // 体重增加
   weightIncreaseRate: number | null; // 体重增长率
+  maximumDehydrationDuration: string;
 }
 
 export const defaultSignedIn = (): SignedIn => {
@@ -285,8 +324,9 @@
     dryWeight: null, // 干体重
     preDialysisWeight: null, // 透前称重
     weightAfterLastDialysis: null, // 上次透后称重
-    weightIncrease: null, // 体重增加  
+    weightIncrease: null, // 体重增加
     weightIncreaseRate: null, // 体重增长率
+    maximumDehydrationDuration: '',
   };
 };
 
@@ -300,7 +340,9 @@
   maximumDehydrationDuration: string; // 最大脱水量那天的时长
   prescriptionRemarks: string; // 透析处方备注
   abnormalItems: AnomalyIndex[]; // 异常指标列表
-  prescriptionDialysisDuration: string; // 透析处方的时长(单位:小时)
+  prescriptionDialysisDurationHour: string; // 透析处方的时长(小时部分)
+  prescriptionDialysisDurationMin: string; // 透析处方的时长(分钟部分)
+  prescriptionDialysisDuration: number | null; // 透析处方的时长(单位:小时)
   dialysisStartTime: number | null; // 透析开始时间(时间戳)
   dialysisEndTime: number | null; // 透析结束时间(时间戳)
   dialysisDuration: number | null; // 已透析时长(单位:分钟)
@@ -313,13 +355,14 @@
   ktv: string; // 实时ktv
   monitoringRecord: MonitoringRecord[]; // 监测记录列表
   doctorAdvice: any[]; // 透析单医嘱列表
-  bloodFlow: string; // 血流量
-  bloodVolumeMonitoring: string; // 血容量监测
-  dialysisFluidFlowRate: string; // 透析液流速
-  ktvList: string[]; // 实时ktv计算结果列表
+  bloodFlow: number | null; // 血流量
+  bloodVolumeMonitoring: number | null; // 血容量监测
+  dialysisFluidFlowRate: number | null; // 透析液流量
+  ktvList: KtvItem[]; // 实时ktv计算结果列表
+  dialysisAge: number | null, // 透析龄
 }
 
-interface MonitoringRecord {
+export interface MonitoringRecord {
   伸缩压: string; // 血压伸缩压
   舒张压: string; // 血压舒张压
   脉搏: string; // 脉搏
@@ -336,7 +379,8 @@
     maximumDehydrationDuration: "",
     prescriptionRemarks: "",
     abnormalItems: [],
-    prescriptionDialysisDuration: "",
+    prescriptionDialysisDurationHour: "",
+    prescriptionDialysisDurationMin: "",
     dialysisStartTime: null,
     dialysisEndTime: null,
     dialysisDuration: null,
@@ -349,18 +393,21 @@
     ktv: "",
     monitoringRecord: [],
     doctorAdvice: [],
-    bloodFlow: "",
-    bloodVolumeMonitoring: "",
-    dialysisFluidFlowRate: "",
+    bloodFlow: null,
+    bloodVolumeMonitoring: null,
+    dialysisFluidFlowRate: null,
     ktvList: [],
+    prescriptionDialysisDuration: null, // 透析处方的时长(单位:小时)
+    dialysisAge: null,
   };
 };
 
 export const defaultDeviceData = (): BedsideAuxiliaryScreen => {
-  const pageType = cache.get("devcieCode")
+  const pageType = Local.get("devcieCode")
     ? EPageType.LOADING
     : EPatForm.OUTPATIENT_SERVICE;
   return {
+    deviceCode: "", // 设备code
     devicdeNo: "", // 设备号
     recordCode: "", // 透析单code
     patientCode: "", // 患者code
@@ -377,25 +424,38 @@
     notSignedIn: defalutNotSignedIn(), // 未签到时需要的数据
     signedIn: defaultSignedIn(), // 已签到时需要的数据
     underTreatment: defaultUnderTreatment(), // 治疗中需要的数据
+    sphygmomanometer: defaultSphygmomanometer(), // 血压计传过来的数据
   };
 };
 
 export const formatDeviceData = (
+  data: BedsideAuxiliaryScreen,
   seeMsg: SseMsgData
 ): BedsideAuxiliaryScreen => {
-  const result = defaultDeviceData();
+
+  const result = deepClone(data);
+
 
   // 默认床号(设备号)
   result.devicdeNo = seeMsg.IOT信息?.床号;
+  result.deviceCode = seeMsg.IOT信息?.设备唯一编号;
 
   if (seeMsg.推送类型 === EPushType.SPHYGMOMANOMETR) {
     result.pageType = EPageType.SPHYGMOMANOMETER;
+
+    const sphygmomanometer = defaultSphygmomanometer();
+    sphygmomanometer.sbp = seeMsg?.床旁血压结果?.sbp;
+    sphygmomanometer.pulseRate = seeMsg?.床旁血压结果?.pulseRate;
+    sphygmomanometer.dbp = seeMsg?.床旁血压结果?.dbp;
+
+    result.sphygmomanometer = sphygmomanometer;
+
   } else if (seeMsg.推送类型 === EPushType.CENTRAL_MONITORING) {
     // 判断是否存在透析状态,如果不存在就是没有排班
     if (seeMsg.透析状态 === null || !seeMsg.透析状态) {
       result.pageType = EPageType.UNPLANNED_SCHEDULE;
       result.consumablesCollection =
-        seeMsg?.使用耗材字典 || defaultconsumablesCollection();
+        seeMsg?.使用耗材字典 ?? defaultconsumablesCollection();
     } else {
       const treatmentStatus = tryConvertToInt(
         seeMsg.透析状态?.透析状态
@@ -416,14 +476,14 @@
       if (treatmentStatus === EMedStatus.NOT_CHECKED_IN) {
         result.pageType = EPageType.NOT_SIGNED_IN;
         const notSignedIn = defalutNotSignedIn();
-        notSignedIn.dialysisMode = seeMsg.透析状态?.透析方案 || "";
-        notSignedIn.dialyzerList = seeMsg.透析状态?.透析器列表 || [];
-        notSignedIn.pipingList = seeMsg.透析状态?.管路列表 || [];
-        notSignedIn.dialysateList = seeMsg.透析状态?.透析液列表 || [];
-        notSignedIn.carePackage = seeMsg.透析状态?.护理包列表 || [];
-        notSignedIn.punctureNeedle = seeMsg.透析状态?.穿刺针列表 || [];
-        notSignedIn.vascularAccess = seeMsg.透析状态?.血管通路列表 || [];
-        notSignedIn.anticoagulant = seeMsg.透析状态?.抗凝剂列表 || [];
+        notSignedIn.dialysisMode = seeMsg.透析状态?.透析方案 ?? "";
+        notSignedIn.dialyzerList = seeMsg.透析状态?.透析器列表 ?? [];
+        notSignedIn.pipingList = seeMsg.透析状态?.管路列表 ?? [];
+        notSignedIn.dialysateList = seeMsg.透析状态?.透析液列表 ?? [];
+        notSignedIn.carePackage = seeMsg.透析状态?.护理包列表 ?? [];
+        notSignedIn.punctureNeedle = seeMsg.透析状态?.穿刺针列表 ?? [];
+        notSignedIn.vascularAccess = seeMsg.透析状态?.血管通路列表 ?? [];
+        notSignedIn.anticoagulant = seeMsg.透析状态?.抗凝剂列表 ?? [];
 
         result.notSignedIn = notSignedIn;
       }
@@ -431,21 +491,24 @@
       else if (treatmentStatus === EMedStatus.SIGNED_IN) {
         result.pageType = EPageType.SIGNED_IN;
         const signedIn = defaultSignedIn();
-        signedIn.abnormalItems = seeMsg.透析状态?.异常检验指标 || [];
-        signedIn.dialysisPlan = seeMsg.透析状态?.透析方案 || "";
+        signedIn.abnormalItems = seeMsg.透析状态?.异常检验指标 ?? [];
+        signedIn.dialysisPlan = seeMsg.透析状态?.透析方案 ?? "";
         signedIn.prescriptionDehydrationVolume =
-          seeMsg.透析状态?.处方脱水量 || null;
-        signedIn.dialyzer = seeMsg.透析状态?.透析器 || "";
-        signedIn.averageDehydrationRate = seeMsg.透析状态?.最近平均脱水量 || "";
+          seeMsg.透析状态?.处方脱水量 ?? null;
+        signedIn.dialyzer = seeMsg.透析状态?.透析器 ?? "";
+        signedIn.averageDehydrationRate = seeMsg.透析状态?.最近平均脱水量 ?? "";
         signedIn.maximumDehydrationCapacity =
-          seeMsg.透析状态?.最近最大脱水量 || "";
+          seeMsg.透析状态?.最近最大脱水量 ?? "";
         signedIn.maximumDehydrationCapacityDate =
-          seeMsg.透析状态?.最近最大脱水量日期 || "";
-        signedIn.dryWeight = seeMsg.透析状态?.干体重 || null;
-        signedIn.preDialysisWeight = seeMsg.透析状态?.透前称重 || null;
-        signedIn.weightAfterLastDialysis = seeMsg.透析状态?.上次透后称重 || null;
-        signedIn.weightIncrease = seeMsg.透析状态?.体重增加 || null;
-        signedIn.weightIncreaseRate = seeMsg.透析状态?.体重增长率 || null;
+          seeMsg.透析状态?.最近最大脱水量日期 ?? "";
+        signedIn.dryWeight = seeMsg.透析状态?.干体重 ?? null;
+        signedIn.preDialysisWeight = seeMsg.透析状态?.透前称重 ?? null;
+        signedIn.weightAfterLastDialysis =
+          seeMsg.透析状态?.上次透后称重 ?? null;
+        signedIn.weightIncrease = seeMsg.透析状态?.体重增加 ?? null;
+        signedIn.weightIncreaseRate = seeMsg.透析状态?.体重增长率 ?? null;
+        signedIn.maximumDehydrationDuration =
+          seeMsg.透析状态?.最近最大脱水量透析时长 ?? "";
 
         result.signedIn = signedIn;
       }
@@ -453,42 +516,64 @@
       else {
         result.pageType = EPageType.DURING_DIALYSIS;
         const underTreatment = defaultUnderTreatment();
-        underTreatment.substituteMode = seeMsg.透析状态?.置换方式 || "";
-        underTreatment.dialysisPlan = seeMsg.透析状态?.透析方案 || "";
-        underTreatment.dialyzer = seeMsg.透析状态?.透析器 || "";
+        underTreatment.substituteMode = seeMsg.透析状态?.置换方式 ?? "";
+        underTreatment.dialysisPlan = seeMsg.透析状态?.透析方案 ?? "";
+        underTreatment.dialyzer = seeMsg.透析状态?.透析器 ?? "";
         underTreatment.averageDehydrationRate =
-          seeMsg.透析状态?.最近平均脱水量 || "";
+          seeMsg.透析状态?.最近平均脱水量 ?? "";
         underTreatment.maximumDehydrationCapacity =
-          seeMsg.透析状态?.最近最大脱水量 || "";
+          seeMsg.透析状态?.最近最大脱水量 ?? "";
         underTreatment.maximumDehydrationCapacityDate =
-          seeMsg.透析状态?.最近最大脱水量日期 || "";
-        underTreatment.maximumDehydrationDuration = "";
-        underTreatment.prescriptionRemarks = seeMsg.透析状态?.处方备注 || "";
-        underTreatment.abnormalItems = seeMsg.透析状态?.异常检验指标 || [];
+          seeMsg.透析状态?.最近最大脱水量日期 ?? "";
+        underTreatment.maximumDehydrationDuration =
+          seeMsg.透析状态?.最近最大脱水量透析时长 ?? "";
+        underTreatment.prescriptionRemarks =
+          seeMsg.透析状态?.透析处方备注 ?? "";
+        underTreatment.abnormalItems = seeMsg.透析状态?.异常检验指标 ?? [];
         underTreatment.prescriptionDialysisDuration =
-          seeMsg.透析状态?.透析处方的时长_小时 || "";
+          seeMsg.透析状态?.透析处方的时长 ?? null;
+        underTreatment.prescriptionDialysisDurationHour =
+          seeMsg.透析状态?.透析处方的时长_小时 ?? "";
+        underTreatment.prescriptionDialysisDurationMin =
+          seeMsg.透析状态?.透析处方的时长_分钟 ?? "";
         underTreatment.dialysisStartTime =
-          seeMsg.透析状态?.透析开始时间 || null;
-        underTreatment.dialysisEndTime = seeMsg.透析状态?.透析结束时间 || null;
-        underTreatment.dialysisDuration = seeMsg.透析状态?.iot_透析时间 || null;
+          seeMsg.透析状态?.透析开始时间 ?? null;
+        underTreatment.dialysisEndTime = seeMsg.透析状态?.透析结束时间 ?? null;
+        underTreatment.dialysisDuration = seeMsg.透析状态?.iot_透析时间 ?? null;
         underTreatment.prescriptionDehydrationVolume =
-          seeMsg.透析状态?.处方脱水量 || null;
+          seeMsg.透析状态?.iot_脱水目标量 ?? null;
         underTreatment.currentDehydrationVolume =
-          seeMsg.透析状态?.实时脱水量 || null;
+          seeMsg.透析状态?.iot_当前脱水量 ?? null;
         underTreatment.currentUltrafiltrationRate =
-          seeMsg.透析状态?.iot_脱水速率 || null;
+          seeMsg.透析状态?.iot_脱水速率 ?? null;
         underTreatment.currentBloodTemperature =
-          seeMsg.透析状态?.当前血温 || null;
-        underTreatment.venousPressure = seeMsg.透析状态?.iot_静脉压 || null;
-        underTreatment.transmembranePressure =
-          seeMsg.透析状态?.iot_跨膜压 || null;
-        underTreatment.ktv = seeMsg.透析状态?.实时ktv || "";
-        underTreatment.monitoringRecord = seeMsg.透析状态?.监测记录列表 || [];
-        underTreatment.doctorAdvice = seeMsg.透析状态?.透析单医嘱列表 || [];
-        underTreatment.bloodFlow = "";
-        underTreatment.dialysisFluidFlowRate = "";
-        underTreatment.bloodVolumeMonitoring = "";
-        underTreatment.ktvList = seeMsg.透析状态?.实时ktv计算结果列表 || [];
+          seeMsg.透析状态?.当前血温 ?? null;
+          // 血压取监测记录的最后一条数据
+          if (seeMsg.透析状态?.监测记录列表 && seeMsg.透析状态?.监测记录列表.length > 0) {
+            const lastItem = seeMsg.透析状态?.监测记录列表[seeMsg.透析状态?.监测记录列表.length -1];
+            underTreatment.venousPressure = lastItem?.伸缩压 ?? null;
+            underTreatment.transmembranePressure = lastItem?.舒张压 ?? null;
+          } else {
+            underTreatment.venousPressure = null;
+            underTreatment.transmembranePressure = null;
+          }
+        // underTreatment.venousPressure = seeMsg.透析状态?.iot_静脉压 ?? null;
+        // underTreatment.transmembranePressure =
+        //   seeMsg.透析状态?.iot_跨膜压 ?? null;
+        underTreatment.ktv = seeMsg.透析状态?.实时ktv ?? "";
+        underTreatment.monitoringRecord = seeMsg.透析状态?.监测记录列表 ?? [];
+        underTreatment.doctorAdvice = seeMsg.透析状态?.透析单医嘱列表 ?? [];
+        // underTreatment.bloodFlow = seeMsg.透析状态?.iot_血流量 ?? null;
+        underTreatment.bloodFlow = seeMsg.透析状态?.iot_血液流速 ?? null;
+        underTreatment.dialysisFluidFlowRate =
+          seeMsg.透析状态?.iot_血流量 ?? null;
+        underTreatment.bloodVolumeMonitoring =  null;
+        underTreatment.ktvList =
+          seeMsg.透析状态?.实时ktv计算结果列表
+            ?.realTimeKtvCalcDetailResultInfo ?? [];
+        underTreatment.dialysisAge = seeMsg.透析状态?.透析龄 ?? null;
+
+        result.underTreatment = underTreatment;
       }
     }
   }
@@ -542,3 +627,13 @@
     return "";
   }
 };
+
+export const formatSubstituteMode = (mode: string) => {
+  let result = "";
+  if (mode === "前置换") {
+    result = "前";
+  } else if (mode === "后置换") {
+    result = "后";
+  }
+  return result;
+};

--
Gitblit v1.8.0