From 6022cfd5cd15b8917ccfd5a635cd49ba47f14ce1 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 24 七月 2025 15:43:02 +0800
Subject: [PATCH] gx大连INBODY人体成分分析仪

---
 app.js |   85 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/app.js b/app.js
index 7ce52c2..397b688 100644
--- a/app.js
+++ b/app.js
@@ -13,6 +13,7 @@
 const thirdPartyApi = require(path.resolve(__dirname, 'thirdPartyApi'));
 
 const app = express();
+app.use(bodyParser.json())
 const port = 3000;
 
 // 设置 JSON 请求体的最大大小为 5MB
@@ -414,6 +415,77 @@
 
     
 })
+// 假设这里有一个模拟的用户数据存储
+const usersData = [
+    {
+        USER_ID: 'test1',
+        USER_NAME: 'name1',
+        USER_GENDER: 'M',
+        USER_BIRTHDAY: '19821201',
+        USER_AGE: '36',
+        USER_HEIGHT: '178.5',
+        ORDER_DATE: '20191025'
+    }
+];
+// 大连新的InBody 人体成分分析仪患者注册
+app.post('/getuserinfo',async (req, res) => {
+    logger.info(`人体成分分析仪患者注册请求body=${JSON.stringify(req.body)}`)
+     // 从请求体中获取用户信息
+     // 这里假设请求体包含 USER_ID 和 ORDER_DATE 字段
+    const { USER_ID, ORDER_DATE } = req.body;
+     // 检查请求参数是否有效
+     if (!USER_ID || !ORDER_DATE) {
+        return res.status(400).json({
+            IsResult: false,
+            INBODY_USER_INFO: [],
+            ErrorMsg: 'USER_ID or ORDER_DATE is missing'
+        });
+    }
+     // 在模拟数据中查找匹配的用户信息
+     const userInfo = usersData.find(user => user.USER_ID === USER_ID && user.ORDER_DATE === ORDER_DATE);
+     const pathParams = { clientCode:'CLIENT9195181802236kHJF',patientHemoCode:USER_ID}
+     const data = await thirdPartyApi.fetchThirdPartyData('/patient/info/queryInAndOuts', 'POST', {}, null,  {},pathParams);
+        console.log('查询InAndOuts数据',data)
+        if(data.code===200&&data?.message==='SUCCESS'&&data?.data){
+            const list= data.data.list;
+            if(list.length>0){
+
+                console.log(list[0])
+                const mode=list[0]
+                const user={
+                    USER_ID: mode.code,
+                    USER_NAME: mode.patientName,
+                    USER_GENDER: mode.patientGender===0? 'M':'F',
+                    USER_BIRTHDAY: '',
+                    USER_AGE: mode.age,
+                    USER_HEIGHT: mode.patientHeight,
+                    ORDER_DATE: getCurrentDateFormatted()
+                }
+                res.json({
+                    IsResult: true,
+                    INBODY_USER_INFO: [user],
+                    ErrorMsg: ''
+                });
+
+                logger.info(`请求患者成功:${mode.patientName}`)
+            }
+            else{
+                res.json({
+                    IsResult: false,
+                    INBODY_USER_INFO: [],
+                    ErrorMsg: 'User not found'
+                });
+                logger.info(`请求患者失败:没有找到用户`)
+            }
+        }else{
+            res.json({
+                IsResult: false,
+                INBODY_USER_INFO: [],
+                ErrorMsg: 'User not found'
+            });
+            logger.info(`请求患者失败:没有找到用户`)
+        }
+})
 
 // 启动服务器
 app.listen(port, async () => {
@@ -531,4 +603,15 @@
     }
     
    
-}
\ No newline at end of file
+}
+function getCurrentDateFormatted() {
+    const date = new Date();
+
+    const year = date.getFullYear(); // 获取年份,如 2025
+
+    const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份(0-11),需要 +1,然后补零
+
+    const day = String(date.getDate()).padStart(2, '0'); // 获取日期,并补零
+
+    return `${year}${month}${day}`;
+}

--
Gitblit v1.8.0