From 4af492babeb7967b5ed74717f5e86b809077bed8 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期六, 21 十二月 2024 15:54:37 +0800
Subject: [PATCH] gx
---
app.js | 144 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 122 insertions(+), 22 deletions(-)
diff --git a/app.js b/app.js
index 42e03c7..cda3bb2 100644
--- a/app.js
+++ b/app.js
@@ -281,21 +281,24 @@
app.get('/getpatientInfo',async(req,res)=>{
// 使用req.query访问查询字符串参数
const patientId = req.query.patientId;
- const mode={"action":'getpatientInfo',"patientId":patientId}
- console.log(patientId,'-----------------')
+ const clientCode = req.query.clientCode;
+ const mode={"action":'getpatientInfo',"patientId":patientId,}
+ console.log(patientId,'-----------------',clientCode)
logHttps(mode)
- if(patientId){
+ if(patientId&&clientCode){
// 输出传入的patientid值
console.log('Patient ID:',patientId)
- let query = `SELECT * FROM patient_info WHERE code = '${patientId}'`
+ let query = `SELECT * FROM patient_info WHERE patient_name_py LIKE '${patientId}' AND client_code = '${clientCode}'`
+ console.log(query)
try {
const [rows] = await pool.promise().query(query);
if (rows.length > 0) {
- const user = rows[0];
- const response = {
- result:[ {
+ // const user = rows[0];
+ let users=[]
+ rows.forEach(user=>{
+ users.push({
patientId: user.code,
- name: user.patient_name,
+ fullName: user.patient_name,
gender: user.patient_gender,
age: getAgeFromIdCard(user.patient_identity_no),
birthday:'',
@@ -310,15 +313,15 @@
examDoctor:'',
examDept:"",
diagnosisDoctor:''
- }],
- };
- res.json(response);
+ })
+ })
+ res.json(users);
} else {
const response = {
retCode: "0",
msg: "没有找到患者,请先检查患者code"
};
- res.json(response);
+ res.json([]);
}
} catch (err) {
console.error(err);
@@ -330,29 +333,126 @@
res.status(400).json({ retCode: "-1", msg: "Invalid request parameters333" });
}
-
- console
})
/**
* PostCheckExam 病人信息及检测结果以JSON的形式回传至服务器
*/
-app.post('/PostCheckExam',async(req,res)=>{
- // 查看body参数
- const body=req.body
-
- if(mode){
+app.post('/PostCheckExam',(req,res)=>{
+ try {
+ const mode={
+ action:'PostCheckExam',
+ params:'jjjj'
+ }
logHttps(mode)
- }else{
- logHttps(mode)
+ // 查看body参数
+ const body=req.body
+ console.log(body)
+ const data={
+ id:0,
+ code:body.examId,
+ patient_code :body.patientId,
+ client_code:'',
+ exam_id:body.examId,
+ SBPLB:body.SBPLB,
+ MBPLB:body.MBPLB,
+ DBPLB:body.DBPLB,
+ PPLB:body.PPLB,
+ SBPRB:body.SBPRB,
+ MBPRB:body.MBPRB,
+ DBPRB:body.DBPRB,
+ PPRB:body.PPRB,
+ SBPLA:body.SBPLA,
+ MBPLA:body.MBPLA,
+ DBPLA:body.DBPLA,
+ SBPRA:body.SBPRA,
+ MBPRA:body.MBPRA,
+ DBPRA:body.DBPRA,
+ ABIL:body.ABIL,
+ ABIR:body.ABIR,
+ BAIL:body.BAIL,
+ BAIR:body.BAIR,
+ PWVL:body.PWVL,
+ PWVR:body.PWVR,
+ TBIL:body.TBIL,
+ TBIR:body.TBIR,
+ SBPLAPTA:body.SBPLAPTA,
+ DBPLAPTA:body.DBPLAPTA,
+ MBPLAPTA:body.MBPLAPTA,
+ PPLAPTA:body.PPLAPTA,
+ SBPRAPTA:body.SBPRAPTA,
+ DBPRAPTA:body.DBPRAPTA,
+ MBPRAPTA:body.MBPRAPTA,
+ PPRAPTA:body.PPRAPTA,
+ SBPLAFA:body.SBPLAFA,
+ DBPLAFA:body.DBPLAFA,
+ MBPLAFA:body.MBPLAFA,
+ PPLAFA:body.PPLAFA,
+ SBPRAFA:body.SBPRAFA,
+ DBPRAFA:body.DBPRAFA,
+ MBPRAFA:body.MBPRAFA,
+ PPRAFA:body.PPRAFA,
+ index_LB:body.indexLB,
+ index_RB:body.indexRB,
+ index_LAPTA:body.indexLAPTA,
+ index_RAPTA:body.indexRAPTA,
+ index_LAFA:body.indexLAFA,
+ index_RAFA:body.indexRAFA,
+ image:body.image,
+ request_doctor:body.requestDoctor,
+ request_department:body.requestDepartment,
+ request_date:body.requestDate,
+ exam_department:body.examDepartment,
+ diagnostician_doctor:body.diagnosticianDoctor,
+ check_date:body.checkDate,
+ check_result:body.checkResult,
+ diagnosis:body.diagnosis,
+ exam_type_id:body.examTypeId,
+ exam_type_name:body.examTypeName,
+ operator_doctor:body.operatorDoctor,
+ abi_advice:body.abiAdvice,
+ pwv_result:body.pwvResult
+ }
+ const { query, params } = createInsertQuery('patient_result_from_doppler_blood_flow_device', data);
+ pool.query(query, params, (error, results) => {
+ if (error) {
+ console.error('Error inserting data:', error);
+ return res.status(500).json({Status:'error', Msg: '数据库错误'+error });
+ }
+
+ res.json({ Status:'SUCCESS',Msg: '插入成功'+ results.insertId });
+ });
}
- res.status(400).json({ retCode: "-1", msg: "kankan" });
+ catch(err){
+ console.log(err)
+ res.status(400).json({ retCode: "-1", msg: "请求出错了" });
+ }
+
})
+
// 启动服务器
app.listen(port, async () => {
console.log(`Server running at http://localhost:${port}/`);
});
+/**
+ *
+ * @param {表名称} tableName
+ * @param {表列内容} data
+ * @returns
+ */
+const createInsertQuery=(tableName, data) =>{
+ const columns = Object.keys(data).map(key => `\`${key}\``).join(', ');
+ const placeholders = Object.keys(data).map(() => '?').join(', ');
+
+ const query = `INSERT INTO \`${tableName}\` (${columns}) VALUES (${placeholders})`;
+
+ // 返回查询字符串和参数数组
+ return {
+ query,
+ params: Object.values(data)
+ };
+}
/**
*
--
Gitblit v1.8.0