From 021a413995329400ce9e940f8a563536585ed46b Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 19 十二月 2024 17:12:41 +0800
Subject: [PATCH] 34

---
 app.js |   51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/app.js b/app.js
index eafc44d..0243744 100644
--- a/app.js
+++ b/app.js
@@ -116,6 +116,49 @@
         res.status(400).json({ retCode: "-1", msg: "Invalid request parameters" });
     }
 });
+app.post('/webuserPatientId',async(req,res)=>{
+    const mode=req.body
+    logHttps(mode)
+    const patientId = req.query.patientId;
+    if (patientId) {
+        let query = `SELECT * FROM patient_info WHERE code = '${xid}'`
+        try {
+            const [rows] = await pool.promise().query(query);
+            if (rows.length > 0) {
+                const user = rows[0];
+                const response = {
+                    retCode: "1",
+                    uinfo: {
+                        title: user.client_code,
+                        cardID: user.code,
+                        userNum: user.patient_no,
+                        name: user.patient_name,
+                        sex: user.patient_gender === 0 ? '男' : '女',
+                        age: getAgeFromIdCard(user.patient_identity_no),
+                        headimgurl: user.patient_avatar_icon,
+                        imgBaseData: '',
+                        remark: ''
+                    },
+                    dbinfo: {}, // 如果没有需要更新的数据库信息,可以保持空
+                    msg: "success"
+                };
+                res.json(response);
+            } else {
+                const response = {
+                    retCode: "0",
+                    msg: "没有找到患者,请先检查患者code"
+                };
+                res.json(response);
+            }
+        } catch (err) {
+            console.error(err);
+            res.status(500).json({ retCode: "-1", msg: "Database error" });
+        }
+    } else {
+        // 如果请求参数不符合预期,则返回错误信息
+        res.status(400).json({ retCode: "-1", msg: "Invalid request parameters" });
+    }
+})
 
 // 定义人脸识别  用base64图片文件换患者信息
 app.post('/faceuser', async (req, res) => {
@@ -237,8 +280,9 @@
  */
 app.get('/getpatientInfo',async(req,res)=>{
     // 使用req.query访问查询字符串参数
-  const patientId = req.query.patientid;
+  const patientId = req.query.patientId;
   const mode={"action":'getpatientInfo',"patientId":patientId}
+  console.log(patientId,'-----------------')
   logHttps(mode)
   if(patientId){
     // 输出传入的patientid值
@@ -249,7 +293,6 @@
         if (rows.length > 0) {
             const user = rows[0];
             const response = {
-                code: "1",
                 result:[ {
                     patientId: user.code,
                     fullName: user.patient_name,
@@ -267,7 +310,6 @@
                     examDept:"",
                     diagnosisDoctor:''
                 }],
-                msg: "success"
             };
             res.json(response);
         } else {
@@ -284,7 +326,7 @@
 
   }else{
     // 如果请求参数不符合预期,则返回错误信息
-    res.status(400).json({ retCode: "-1", msg: "Invalid request parameters" });
+    res.status(400).json({ retCode: "-1", msg: "Invalid request parameters333" });
   }
 
   
@@ -298,7 +340,6 @@
     if(mode){
         logHttps(mode)
     }else{
-        mode.action='hahhaha'
         logHttps(mode)
     }
     res.status(400).json({ retCode: "-1", msg: "kankan" });

--
Gitblit v1.8.0