<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>注册登录页</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <center>
        <h1>天生自然健康智能医疗系统欢迎你</h1>
        <h2><a href="register.jsp">注册</a></h2>
        <h2><a href="log.html">登录</a></h2>
    </center>
</body>
</html>

<%-- 
    Document   : register
    Created on : 2018-10-5, 19:42:13
    Author     : acer
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="db.ActionDB"%>
<%@page import="db.DBConnection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>用户注册页</title>
    </head>
     <%    request.setCharacterEncoding("UTF-8");    %>
    <body>
        <form id='test_form' action='registerTwo.jsp' method='' omsubmit='return checkForm()'>
            选择省份:<select name="province" size="1" id="province">
                <option value="北京市">北京市</option>
                <option value="重庆市">重庆市</option>
                <option value="香港特别行政区">香港特别行政区</option>
                <option value="安徽省">安徽省</option>
                <option value="河南省">河南省</option>
                <option value="湖北省">湖北省</option>
                <option value="陕西省">陕西省</option>
                <option value="青海省">青海省</option>
                <option value="台湾省">台湾省</option>
                <option value="黑龙江省">黑龙江省</option>
                <option value="山东省">山东省</option>
                <option value="海南省">海南省</option>
                <option value="贵州省">贵州省</option>
                <option value="吉林省">吉林省</option>
                <option value="福建省">福建省</option>
                <option value="上海市">上海市</option>
                <option value="浙江省">浙江省</option>
                <option value="四川省">四川省</option>
                <option value="云南省">云南省</option>
                <option value="新疆维吾尔自治区">新疆维吾尔自治区</option>
                <option value="河北省">河北省</option>
                <option value="江苏省">江苏省</option>
                <option value="江西省">江西省</option>
                <option value="广东省">广东省</option>
                <option value="辽宁省">辽宁省</option>
                <option value="湖南省">湖南省</option>
                <option value="甘肃省">甘肃省</option>
                <option value="内蒙古自治区">内蒙古自治区</option>
                <option value="广西壮族自治区">广西壮族自治区</option>
                <option value="西藏自治区">西藏自治区</option>
                <option value="澳门特别行政区">澳门特别行政区</option>
                <option value="天津市">天津市</option>
                <option value="山西省">山西省</option>
                <option value="宁夏回族自治区">宁夏回族自治区</option>
            </select>     
            <input type="submit" name="Submit" value="下一步" /> 
        </form>
    </body>
</html>

 

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>用户登录页</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <center>
        <form action="userpage.jsp" method="post">
            <table width="250" cellspacing="0" cellpadding="0">
                <tr>
                    <td>账号:</td>
                    <td>      <input name="username" type="text" id="username" />    </td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td>      <input name="password" type="password" id="password" />    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" name="Submit" value="登录" />
                        <input name="reset" type="reset" id="reset" value="重置" />
                    </td>
                </tr>
            </table>
        </form>
    </center>
</body>
</html>

<%-- 
    Document   : userpage
    Created on : 2018-10-6, 19:25:05
    Author     : acer
--%>

<%@page import="java.io.IOException"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>个人首页</title>
    </head>
    <style>a{text-decoration:none}</style>
    <%    request.setCharacterEncoding("UTF-8");    %>
    <body>
        <%
            String username = request.getParameter("username");
            String password = request.getParameter("password");
            String[] userInfo = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\log.py", username, password};
            try {
                Process pr = Runtime.getRuntime().exec(userInfo);
                BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                List<String> allList = new ArrayList<>();
                String line;
                while ((line = in.readLine()) != null) {
                    allList.add(line);
                }
                Iterator<String> iter = allList.iterator();
                int length = allList.size();
                String[] str_back = new String[length];
                for (int i = 0; i < str_back.length; i++) {
                    str_back[i] = iter.next();
                }
                if (str_back.length > 1) {
        %>
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr>
                <td width="163"><div align="center">系统功能区</div></td>
                <td width="520"><div align="center">系统公告区</div></td>
                <td width="189"><div align="">用户个人信息</div></td>
            </tr>
            <tr>
                <td rowspan="3"><div align="center"><a href="ALzhenduan.jsp?userid=<%=str_back[0]%>&username=<%=str_back[1]%>&province=<%=str_back[6]%>&administ=<%=str_back[7]%>">智能诊断</a></div></td>
                <td rowspan="15">
                    <%
                        String[] info = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\getSysInfo.py"};
                        Process pro = Runtime.getRuntime().exec(info);
                        BufferedReader inn = new BufferedReader(new InputStreamReader(pro.getInputStream()));
                        List<String> list = new ArrayList<>();
                        String li;
                        while ((li = inn.readLine()) != null) {
                            list.add(li);
                        }
                        Iterator<String> itor = list.iterator();
                        int len = list.size();
                        String[] back = new String[len];
                        for (int i = 0; i < back.length; i++) {
                            back[i] = itor.next();
                        }
                        for (int i = 0; i < back.length; i++) {
                            if (i % 2 == 0) {
                    %>
                    <h2><%=back[i]%></h2>
                    <%
                    } else {
                    %>
                    <p><%=back[i]%></p>
                    <%
                            }

                        }
                    %>                                                            
                </td>
                <td>用户ID:<%=str_back[0]%></td>
            </tr>
            <tr>
                <td>账号:<%=str_back[1]%></td>
            </tr>
            <tr>
                <td>密码:<%=str_back[2]%></td>
            </tr>
            <tr>
                <td rowspan="3"><div align="center"><a href="getInfo.jsp?province=<%=str_back[6]%>&administ=<%=str_back[7]%>">智能分诊</a></div></td>
                <td>性别:<%=str_back[3]%></td>
            </tr>
            <tr>
                <td>年龄:<%=str_back[4]%></td>
            </tr>
            <tr>
                <td>邮箱:<%=str_back[5]%></td>
            </tr>
            <tr>
                <td rowspan="3"><div align="center"><a href="ALSelectHistory.jsp?userid=<%=str_back[0]%>&username=<%=str_back[1]%>&province=<%=str_back[6]%>&administ=<%=str_back[7]%>">智能复诊</a></div></td>
                <td>省份:<%=str_back[6]%></td>
            </tr>
            <tr>
                <td>地区:<%=str_back[7]%></td>
            </tr>
            <tr>
                <td>病史:<%=str_back[8]%></td>
            </tr>           
            <tr>
                <td rowspan="3"><div align="center"><a href="modificationInfo.jsp?userid=<%=str_back[0]%>&username=<%=str_back[1]%>&password=<%=str_back[2]%>&sex=<%=str_back[3]%>&age=<%=str_back[4]%>&email=<%=str_back[5]%>&province=<%=str_back[6]%>&administer=<%=str_back[7]%>&illhistory=<%=str_back[8]%>&hight=<%=str_back[9]%>&weight=<%=str_back[10]%>&blootype=<%=str_back[11]%>">修改个人信息</a></div></td>
                <td>身高(cm):<%=str_back[9]%>
                </td>
            </tr>
            <tr>
                <td>体重(kg):<%=str_back[10]%></td>
            </tr>
            <tr>
                <td>血型:<%=str_back[11]%></td>
            </tr>
            <tr>
                <td><div align="center"><a href="printHistory.jsp?userid=<%=str_back[0]%>">诊断记录</a></div></td>
                <td><p align="left">&nbsp;</p>      <div align="left">&nbsp;</div>      <div align="left">&nbsp;</div></td>
            </tr>
        </table>
        <%
            }
            if (str_back.length <= 1) {
        %>
        <h2><font color="RED">Sorry,本次登录失败...</font></h2>
        <h3>请按这里重新<a href="index.html">登录</a></h3>
        <%
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        %>
    </body>
</html>

 

#系统核心事务逻辑处理代码
import sys
import os
import cx_Oracle
import numpy as np
import pandas as pd
import tensorflow as tf

conn=cx_Oracle.connect('doctor/admin@localhost:1521/tszr')
cursor = conn.cursor()

def showSurgest():
    sql = 'select distinct SURGERY from menzhen'
    cursor.execute(sql)
    rows = cursor.fetchall()
    surgery = []
    for row in rows:
        surgery.append(row[0])
    for i in range(len(surgery)):
        print(surgery[i])

def showSujects(surgest):
    sql = "select distinct SURGERYCHEST from menzhen where SURGERY='%s'" % surgest
    cursor.execute(sql)
    rows = cursor.fetchall()
    sujects = []
    for row in rows:
        sujects.append(row[0])
    for i in range(len(sujects)):
        print(sujects[i])

def showQuestion(sujects):
    sql = "select QUESTION from QUESTTB where ILLSUBJECT='%s'" % sujects
    cursor.execute(sql)
    rows = cursor.fetchall()
    question = ""
    for row in rows:
        question += row[0]
    question = question.split(',')
    return question

def getQuestion(sujects):
    quest = showQuestion(sujects)
    for i in range(len(quest)):
        print('你是否'+quest[i]+'')

def getTrainData(sujects):
    sql = "select feature1,feature2,feature3,feature4,feature5,trainLable from menzhen where surgeryChest='%s'" % (sujects)
    cursor.execute(sql)
    rows = cursor.fetchall() #得到所有数据集 
    trainDataSet = []
    for row in rows:
        oneLine = []
        oneLine.append(row[0])
        oneLine.append(row[1])
        oneLine.append(row[2])
        oneLine.append(row[3])
        oneLine.append(row[4])
        oneLine.append(row[5])
        trainDataSet.append(oneLine)
    trainData = []
    trainLabel = []
    for i in range(len(trainDataSet)):
        trainData.append(trainDataSet[i][:-1])
        trainLabel.append(trainDataSet[i][-1])
    X = trainData
    Y_ = trainLabel
    Y_ = np.reshape(Y_,(-1,1))
    return X,Y_

def countWeights(X,Y_):
    #定义神经网络参数
    CLASS_NUM = 1
    DEEP_OUT = 5
    bias1 = 5
    DEEP_TWO = 1
    Bias2 = 1
    LEARN_RACE = 0.0001
    #定义神经网络
    #定义训练数据x,y_
    x = tf.placeholder(tf.float32, shape=(None, 5))
    y_ = tf.placeholder(tf.float32, shape=(None, 1))
    #定义第一层(隐藏层)神经网络
    w1 = tf.Variable(tf.random_normal([5, 5], stddev=1, seed=1))
    bias1 = tf.Variable(tf.random_normal([5]))
    #定义输出层
    w2 = tf.Variable(tf.random_normal([5, 1], stddev=1, seed=1))
    bias2 = tf.Variable(tf.random_normal([1]))
    #神经网络前向传播过程
    #第一层神经网络层传播
    a = tf.matmul(x, w1)
    a=tf.nn.bias_add(a,bias1)
    a=tf.nn.relu(a)
    #第二层(输出层)神经网络层传播
    y = tf.matmul(a, w2)
    y=tf.nn.bias_add(y,bias2)
    #定义损失函数进行反向传播优化修改权值
    #使用均方误差损失函数
    loss_mse = tf.reduce_mean(tf.square(y - y_))
    #选择一个优化器
    #随机梯度下降优化算法
#     train_step = tf.train.GradientDescentOptimizer(LEARN_RACE).minimize(loss_mse)
    #移动动量优化算法
    train_step = tf.train.MomentumOptimizer(LEARN_RACE,0.9).minimize(loss_mse)
    #亚当优化算法
#     train_step = tf.train.AdamOptimizer(LEARN_RACE).minimize(loss_mse)
    #比较预测值与真实值
    correct_pred=tf.equal(y,y_)
    #计算每个batch的平均准确率
    accuracy=tf.reduce_mean(tf.cast(correct_pred,tf.float32))
    
    #神经网络的执行
    #定义算法执行参数
    STEPS = 1
    BATCH_SIZE = 8
    TRAIN_ROW = np.shape(X)[0]
    BATCH_NUM = int(TRAIN_ROW/BATCH_SIZE)
    with tf.Session() as sess:
        init = tf.global_variables_initializer()
        sess.run(init)
        for i in range(STEPS):
            for j in range(BATCH_NUM):
                start = (j * BATCH_SIZE) % np.shape(X)[0]
                end = start + BATCH_SIZE
                sess.run(train_step, feed_dict={x: X[start:end], y_: Y_[start:end]})
                if j % 200 == 0:
                    total_loss = sess.run(loss_mse, feed_dict={x: X, y_: Y_})
#                     print("After %d training step(s), accuracy on all data is %.4f%%" % (i,((1-total_loss)*100)))
        w = w2.eval(session=sess)
    weights = []
    for i in range(len(w)):
        weights.append(w[i][0])
    return weights

def getAnswer(a1,a2,a3,a4,a5):
    answers = []
    answers.append(int(a1))
    answers.append(int(a2))
    answers.append(int(a3))
    answers.append(int(a4))
    answers.append(int(a5))
    str_answers = []
    if(int(a1)==1):
        str_answers.append("正常")
    elif(int(a1)==2):
        str_answers.append("轻度")
    elif(int(a1)==3):
        str_answers.append("偏重")
    else:
        str_answers.append("严重")
    if(int(a2)==1):
        str_answers.append("正常")
    elif(int(a2)==2):
        str_answers.append("轻度")
    elif(int(a2)==3):
        str_answers.append("偏重")
    else:
        str_answers.append("严重")
    if(int(a3)==1):
        str_answers.append("正常")
    elif(int(a3)==2):
        str_answers.append("轻度")
    elif(int(a3)==3):
        str_answers.append("偏重")
    else:
        str_answers.append("严重")
    if(int(a4)==1):
        str_answers.append("正常")
    elif(int(a4)==2):
        str_answers.append("轻度")
    elif(int(a4)==3):
        str_answers.append("偏重")
    else:
        str_answers.append("严重")
    if(int(a5)==1):
        str_answers.append("正常")
    elif(int(a5)==2):
        str_answers.append("轻度")
    elif(int(a5)==3):
        str_answers.append("偏重")
    else:
        str_answers.append("严重")
    return answers,str_answers

def getResultName(sujects,weights,answers):
    result = 0.0
    for i in range(len(weights)):
        result += weights[i]*answers[i]
    if(int(abs(result))==0):
        result = 1
    if(int(abs(result))>3):
        result = 3
    result = int(abs(result))
    sql = "select ill_name from ill_result_tb where family='%s' and ill_id = %d" % (sujects,result)
    cursor.execute(sql)
    rows = cursor.fetchall()
    resultName = ""
    for row in rows:
        resultName=row[0]
    sql = "select ill_name from ill_result_tb where family='%s' and ill_id = %d" % (sujects,3)
    cursor.execute(sql)
    rows = cursor.fetchall()
    illName = ""
    for row in rows:
        illName=row[0]
    if(resultName=='疑似患病'):
        illName = '疑似患' + illName
    return resultName,illName

def getSugessiones(sujects,resultName):
    sql = "select prescription_1,prescription_2,prescription_3,prescription_4,prescription_5,prescription_6,prescription_7,prescription_8,prescription_9,prescription_10,prescription_11,prescription_12,prescription_13,prescription_14,prescription_15 from prescription where SURGERYCHEST='%s' and illName='%s'" % (sujects,resultName)
    cursor.execute(sql)
    rows = cursor.fetchall()
    prescriptionData = []
    for row in rows:
        one = []
        one.append(row[0])
        one.append(row[1])
        one.append(row[2])
        one.append(row[3])
        one.append(row[4])
        one.append(row[5])
        one.append(row[6])
        one.append(row[7])
        one.append(row[8])
        one.append(row[9])
        one.append(row[10])
        one.append(row[11])
        one.append(row[12])
        one.append(row[13])
        one.append(row[14])
        prescriptionData.append(one)
    prescriptionDataFrame = pd.DataFrame(prescriptionData)
    prescriptionDataSum = prescriptionDataFrame.sum(axis=0)
    prescriptionDataSumSorted=sorted(enumerate(prescriptionDataSum), key=lambda x:x[1], reverse=True)
    prescriptionDataSumSortedThirst = prescriptionDataSumSorted[:3]
    prescriptionIndex = []
    for i in range(len(prescriptionDataSumSortedThirst)):
        prescriptionIndex.append(prescriptionDataSumSortedThirst[i][0])
    sql = "select prescriptionInfo,health from prescriptionInfo where FAMILY='%s' and ill_name='%s'" % (sujects,resultName)
    cursor.execute(sql)
    rows = cursor.fetchall()
    prescriptionInfoData = []
    healthData = []
    for row in rows:
        prescriptionInfoData.append(row[0])
        healthData.append(row[1])
    prescriptionInfoResult = []
    for i in range(len(prescriptionIndex)):
        prescriptionInfoResult.append(prescriptionInfoData[prescriptionIndex[i]])
    healthResult = []
    for i in range(len(prescriptionIndex)):
        healthResult.append(healthData[prescriptionIndex[i]])
    return prescriptionInfoResult,healthResult

def getDoctors(sujects):
    sql = "select addraction,name,summary from doctors where family='%s'" % (sujects)
    cursor.execute(sql)
    rows = cursor.fetchall()
    doctorInfo = []
    for row in rows:
        doctorInfo.append(row[0])
        doctorInfo.append(row[1])
        doctorInfo.append(row[2])
    print("主治专家姓名:" + doctorInfo[1])
    print("主治专家简介:" + doctorInfo[2])
    print("主治专家所在医院:" + doctorInfo[0])
    return doctorInfo

def getInfo(argv,province,administ):
    sql = "select distinct surgery from menzhen"
    cursor.execute(sql)
    rows = cursor.fetchall()
    dipart = []
    for row in rows:
        dipart.append(row[0])
    ############################################
    sql = "select distinct surgery,surgerychest from menzhen"
    cursor.execute(sql)
    rows = cursor.fetchall()
    dipartmentSubj = []
    for row in rows:
        one = []
        one.append(row[0])
        one.append(row[1])
        dipartmentSubj.append(one)
    ###########################################################
    sql = "select illSubject,question from questtb"
    cursor.execute(sql)
    rows = cursor.fetchall()
    subjectQues = []
    for row in rows:
        one = []
        one.append(row[0])
        one.append(row[1])
        subjectQues.append(one)
    #############################################################
    if(len(argv)==1):
        print('很抱歉系统没有匹配到你症状所对应的门诊部门...')
    else:
        sym = ""
        for i in range(1,len(argv)):
            sym += argv[i]
        symptom = []
        symptom.extend(sym)
        subCount = []
        flat = False
        for j in range(len(subjectQues)):
            temp = []
            que = []
            que.extend(subjectQues[j][1])
            count = 0
            for i in range(len(symptom)):
                if(symptom[i]!="," or symptom[i]!=" "):
                    for k in range(len(que)):
                        if(symptom[i]==que[k]):
                            count = count + 1
                            flat = True
            temp.append(subjectQues[j][0])
            temp.append(count)
            subCount.append(temp)
        ############################################################
        if(flat):
            for i in range(len(subCount)):
                for j in range(len(dipartmentSubj)):
                    if(subCount[i][0]==dipartmentSubj[j][1]):
                        subCount[i].append(dipartmentSubj[j][0])
            symMaxCount = sorted(subCount,key=(lambda x:x[1]),reverse=True)           
            print("根据你输入的问题,经过大数据分析建议你选择以下的门诊部和对应的科:")
            print("门诊部门:"+symMaxCount[0][2])
            print("对应的科:"+symMaxCount[0][0])
            print("根据你的情况,系统推荐重点检查身体以下几项健康指标:")
            seeproject = getSeeProject(symMaxCount[0][0])
            print("推荐检查:",seeproject)
            print("===============================================================================================")
            print("根据你的情况,系统向你推荐以下在这一治疗领域专家:")
            doctorInfo = getDoctors(symMaxCount[0][0])
            print("===============================================================================================")
            print("根据你所处的位置,系统找到以下与你距离最近的医院:")
            getPAH(province,administ)
        else:
            print('很抱歉系统没有匹配到你症状所对应的门诊部门...')

def getPAH(province,administrative):
    sql = "select hostitalname from hostitalAdrrest where province='%s' and administrative='%s'" % (province,administrative)
    cursor.execute(sql)
    rows = cursor.fetchall()
    hostitalName = []
    for row in rows:
        hostitalName.append(row[0])
    for i in range(len(hostitalName)):
        print(hostitalName[i])
        
def getSeeProject(subject):
    sql = "select CHACKPRO from chackProject where FAMILY='%s'" % (subject)
    cursor.execute(sql)
    rows = cursor.fetchall()
    seeproject = []
    for row in rows:
        seeproject.append(rows[0])
    return seeproject[0][0]

# seeproject = getSeeProject("胸外科")
        
def addUser_SeeIll(userid,username,menzhenclass,menzhenke,feature1,feature2,feature3,feature4,feature5,menzhenresult,chufang,jianyi):
    sql = "insert into user_SeeIll(userid,username,menzhenclass,menzhenke,feature1,feature2,feature3,feature4,feature5,menzhenresult,chufang,jianyi) values ('%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (userid,username,menzhenclass,menzhenke,feature1,feature2,feature3,feature4,feature5,menzhenresult,chufang,jianyi)
    cursor.execute(sql)
    conn.commit()
    if(cursor.rowcount==1):
        print("新看病记录添加成功")
    else:
        print("新看病记录添加失败")
        
# addUser_SeeIll(2,'小善','外科','胃肠胆外科','严重','严重','严重','严重','严重','胃溃疡或胆囊炎','防己苍术泽泻各60克,升麻30克,研末,水泛为丸,每次9克,一日2次,饭前温开水吞服,可以常服。','饭后多吃榛子坚果') 
            
def zhenduan(a1,a2,a3,a4,a5,userid,username,surgest,subject,province,administ):
    answers,strAnswers = getAnswer(a1,a2,a3,a4,a5)
    X,Y_ = getTrainData(subject)
    weights = countWeights(X,Y_)
    resultName,illName = getResultName(subject,weights,answers)
    if(resultName=='疑似患病'):
        print(illName)
    else:
        print(resultName)
    prescriptionInfoResult,healthResult = getSugessiones(subject,resultName)
    chufang = ''
    for i in range(len(prescriptionInfoResult)):
        chufang = chufang + '诊断处方'+str(i+1)+''+prescriptionInfoResult[i]+''
        print('诊断处方'+str(i+1)+''+prescriptionInfoResult[i])
    jianyi = ''
    for i in range(len(healthResult)):
        jianyi = jianyi + '养生建议'+str(i+1)+''+healthResult[i]+''
        print('养生建议'+str(i+1)+''+healthResult[i])
    if(resultName != '正常'):
        print("根据你的情况,系统推荐重点检查身体以下几项健康指标:")
        seeproject = getSeeProject(subject)
        print("推荐检查:",seeproject)
        print("根据你的情况,系统向你推荐以下在这一治疗领域专家:")
        doctorInfo = getDoctors(subject)
        print("===============================================================================================")
        print("根据你所处的位置,系统找到以下与你距离最近的医院:")
        getPAH(province,administ)
    addUser_SeeIll(userid,username,surgest,subject,strAnswers[0],strAnswers[1],strAnswers[2],strAnswers[3],strAnswers[4],resultName,chufang,jianyi)

# showSurgest()
# showSujects('外科')
# getQuestion('胸外科')
# zhenduan(1,1,1,1,2,2,'小善','外科','胸外科','广东省','佛山市')
#############################################################################

def addUser(username,password,sex,age,email,province,area,illhistory,hight,weight,blootype):
    sql = "insert into user_tb(userid,username,password,sex,age,email,province,area,illhistory,hight,weight,blootype) values (user_Sequence.Nextval,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')" % (username,password,sex,age,email,province,area,illhistory,hight,weight,blootype)
    cursor.execute(sql)
    conn.commit()
    if(cursor.rowcount==1):
        print("注册成功")
    else:
        print("注册失败")

# addUser('小粒','321','女','20','12333@qq.com','广东省','茂名市','无','165','53','B') 

def userlog(username,password):
    #sql = "select userid from user_tb where username='%s' and password='%s'" % (username,password)
    sql = "select userid from usertable where username='%s' and password='%s'" % (username, password)
    cursor.execute(sql)
    rows = cursor.fetchall()
    ui = []
    for row in rows:
        ui.append(row[0])
    if(len(ui)==1):
        sql = "select userid,username,password,sex,age,province,area from usertable where username='%s' and password='%s'" % (username,password)
        cursor.execute(sql)
        rows = cursor.fetchall()
        for row in rows:
            print(row[0])
            print(row[1])
            print(row[2])
            print(row[3])
            print(row[4])
            print(row[5])
            print(row[6])
    else:
        print("登录失败")
        
# userlog("小明","123")

def updateUserInfo(userid,username,password,sex,age,email,province,area,illhistory,hight,weight,blootype):
    count = 0
    sql = "UPDATE user_tb set username='%s',password='%s',sex='%s',age='%s',email='%s',province='%s',area='%s',illhistory='%s',hight='%s',weight='%s',blootype='%s' where userid='%d'" % (username,password,sex,age,email,province,area,illhistory,hight,weight,blootype,userid)
    cursor.execute(sql)
    conn.commit()
    count += 1
    sql = "UPDATE user_SeeIll set username='%s' where userid='%d'" % (username,userid)
    cursor.execute(sql)
    conn.commit()
    count += 1
    if(count>=1):
        print("用户信息更新成功")
    else:
        print("用户信息更新失败")

# updateUserInfo(2,'小善','321','女','10','12@qq.com','广东省','茂名市','无','165','53','AB')

def printHistory(userid):
    sql = "select username,menzhenclass,menzhenke,feature1,feature2,feature3,feature4,feature5,menzhenresult,chufang,jianyi,kanbingriqi from user_SeeIll where userid='%d'" % userid
    cursor.execute(sql)
    rows = cursor.fetchall()
    mainInfo = []
    for row in rows:
        one = []
        one.append("用户姓名:"+row[0])
        one.append("门诊部门:"+row[1])
        one.append(row[2])
        one.append(row[3])
        one.append(row[4])
        one.append(row[5])
        one.append(row[6])
        one.append(row[7])
        one.append("诊断结果:"+row[8])
        one.append("病理处方:"+row[9])
        one.append("养生建议:"+row[10])
        one.append("就诊日期:"+str((row[11])))
        mainInfo.append(one)
    for i in range(len(mainInfo)):
        menzhenke = mainInfo[i][2]
        quest = showQuestion(menzhenke)
        mainInfo[i][2] = "病理部门:"+mainInfo[i][2]
        mainInfo[i][3] = "是否"+quest[0]+":"+mainInfo[i][3]
        mainInfo[i][4] = "是否"+quest[1]+":"+mainInfo[i][4]
        mainInfo[i][5] = "是否"+quest[2]+":"+mainInfo[i][5]
        mainInfo[i][6] = "是否"+quest[3]+":"+mainInfo[i][6]
        mainInfo[i][7] = "是否"+quest[4]+":"+mainInfo[i][7]
    for i in range(len(mainInfo)):
        print(""+str(i+1)+" 次诊断记录:")
        for j in range(len(mainInfo[i])):
            print(mainInfo[i][j])
        print("===============================================================================================")
        
# printHistory(1)

def getSysInfo():
    sql = 'select title,article from systemInformation'
    cursor.execute(sql)
    rows = cursor.fetchall()
    for row in rows:
        print(row[0])
        print(row[1])

 

<%-- 
    Document   : ALzhenduan
    Created on : 2018-10-8, 16:57:02
    Author     : acer
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>智能诊断页</title>
    </head>
    <%    request.setCharacterEncoding("UTF-8");    %>
    <body>
    <center><h2>智能诊断</h2></center>
    <hr>
    <%
        String userid = request.getParameter("userid");
        String username = request.getParameter("username");
        String province = request.getParameter("province");
        String administ = request.getParameter("administ");
    %>
    <form action="ALselectSubject.jsp" method="post">
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr><td><h3>就诊编号:<%=userid%></h3></td></tr>
            <tr><td><h3>用户账号:<%=username%></h3></td></tr>
            <tr><td><h3>请选择门诊部门:
                        <%
                            String[] userInfo = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\showSurgest.py"};
                            Process pr = Runtime.getRuntime().exec(userInfo);
                            BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                            List<String> allList = new ArrayList<>();
                            String line;
                            while ((line = in.readLine()) != null) {
                                allList.add(line);
                            }
                            Iterator<String> iter = allList.iterator();
                            int length = allList.size();
                            String[] str_back = new String[length];
                            for (int i = 0; i < str_back.length; i++) {
                                str_back[i] = iter.next();
                            }
                        %>
                        <select name="surgest" size="1" id="administ">
                            <%for (int i = 0; i < str_back.length; i++) {%>
                            <option value="<%=str_back[i]%>"><%=str_back[i]%></option>
                            <%}%>
                        </select>
                    </h3></td></tr>
            <tr><td><input type="hidden" name="userid" value="<%=userid%>"/>
                    <input type="hidden" name="username" value="<%=username%>"/>
                    <input type="hidden" name="province" value="<%=province%>"/>
                    <input type="hidden" name="administ" value="<%=administ%>"/>
                    <input type="submit" name="Submit" value="下一步" />
                </td></tr>
        </table>
    </form>
</body>
</html>

 

#选择科室
<%-- 
    Document   : ALselectSubject
    Created on : 2018-10-8, 18:55:23
    Author     : acer
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>智能诊断页</title>
    </head>
    <%    request.setCharacterEncoding("UTF-8");    %>
    <body>
    <center><h2>智能诊断</h2></center>
    <hr>
    <%
        String userid = request.getParameter("userid");
        String username = request.getParameter("username");
        String province = request.getParameter("province");
        String administ = request.getParameter("administ");
        String surgest = request.getParameter("surgest");
    %>
    <form action="getQuestion.jsp" method="post">
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr><td><h3>就诊编号:<%=userid%></h3></td></tr>
            <tr><td><h3>用户账号:<%=username%></h3></td></tr>
            <tr><td><h3>门诊部门:<%=surgest%></h3></td></tr>
            <tr><td><h3>请选择病理科室:
                        <%
                            String[] userInfo = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\showSujects.py",surgest};
                            Process pr = Runtime.getRuntime().exec(userInfo);
                            BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                            List<String> allList = new ArrayList<>();
                            String line;
                            while ((line = in.readLine()) != null) {
                                allList.add(line);
                            }
                            Iterator<String> iter = allList.iterator();
                            int length = allList.size();
                            String[] str_back = new String[length];
                            for (int i = 0; i < str_back.length; i++) {
                                str_back[i] = iter.next();
                            }
                        %>
                        <select name="subject" size="1" id="administ">
                            <%for (int i = 0; i < str_back.length; i++) {%>
                            <option value="<%=str_back[i]%>"><%=str_back[i]%></option>
                            <%}%>
                        </select>
                    </h3></td></tr>
            <tr><td><input type="hidden" name="userid" value="<%=userid%>"/>
                    <input type="hidden" name="username" value="<%=username%>"/>
                    <input type="hidden" name="province" value="<%=province%>"/>
                    <input type="hidden" name="administ" value="<%=administ%>"/>
                    <input type="hidden" name="surgest" value="<%=surgest%>"/>
                    <input type="submit" name="Submit" value="下一步" />                    
                </td></tr>
        </table>
    </form>
    <form action="ALzhenduan.jsp" method="post">
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr><td>
                    <input type="hidden" name="userid" value="<%=userid%>"/>
                    <input type="hidden" name="username" value="<%=username%>"/>
                    <input type="hidden" name="province" value="<%=province%>"/>
                    <input type="hidden" name="administ" value="<%=administ%>"/>
                    <input type="submit" name="Submit" value="上一步" /> 
                </td></tr>
        </table>
    </form>
</body>
</html>

 

 

#问诊
<%-- 
    Document   : getQuestion
    Created on : 2018-10-8, 21:23:06
    Author     : acer
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>智能诊断页</title>
    </head>
    <%    request.setCharacterEncoding("UTF-8");%>
    <body>
    <center><h2>智能诊断</h2></center>
    <hr>
    <%
        String userid = request.getParameter("userid");
        String username = request.getParameter("username");
        String province = request.getParameter("province");
        String administ = request.getParameter("administ");
        String surgest = request.getParameter("surgest");
        String subject = request.getParameter("subject");
    %>
    <form action="getAnswer.jsp" method="post">
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr><td><h3>就诊编号:<%=userid%></h3></td></tr>
            <tr><td><h3>用户账号:<%=username%></h3></td></tr>
            <tr><td><h3>门诊部门:<%=surgest%></h3></td></tr>
            <tr><td><h3>病理科室:<%=subject%></h3></td></tr>
            <tr><td><h3>请认真如实选择回答问题:
                        <%
                            String[] userInfo = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\getQuestion.py", subject};
                            Process pr = Runtime.getRuntime().exec(userInfo);
                            BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                            List<String> allList = new ArrayList<>();
                            String line;
                            while ((line = in.readLine()) != null) {
                                allList.add(line);
                            }
                            Iterator<String> iter = allList.iterator();
                            int length = allList.size();
                            String[] str_back = new String[length];
                            for (int i = 0; i < str_back.length; i++) {
                                str_back[i] = iter.next();
                            }
                        %>
                        <h3><%=str_back[0]%></h3>
                        <label><input name="one" type="radio" value="正常" />正常</label>
                        <label><input name="one" type="radio" value="轻度" />轻度</label>
                        <label><input name="one" type="radio" value="偏重" />偏重</label>
                        <label><input name="one" type="radio" value="严重" />严重</label>
                        <h3><%=str_back[1]%></h3>
                        <label><input name="two" type="radio" value="正常" />正常</label>
                        <label><input name="two" type="radio" value="轻度" />轻度</label>
                        <label><input name="two" type="radio" value="偏重" />偏重</label>
                        <label><input name="two" type="radio" value="严重" />严重</label>
                        <h3><%=str_back[2]%></h3>
                        <label><input name="three" type="radio" value="正常" />正常</label>
                        <label><input name="three" type="radio" value="轻度" />轻度</label>
                        <label><input name="three" type="radio" value="偏重" />偏重</label>
                        <label><input name="three" type="radio" value="严重" />严重</label>
                        <h3><%=str_back[3]%></h3>
                        <label><input name="force" type="radio" value="正常" />正常</label>
                        <label><input name="force" type="radio" value="轻度" />轻度</label>
                        <label><input name="force" type="radio" value="偏重" />偏重</label>
                        <label><input name="force" type="radio" value="严重" />严重</label>
                        <h3><%=str_back[4]%></h3>
                        <label><input name="five" type="radio" value="正常" />正常</label>
                        <label><input name="five" type="radio" value="轻度" />轻度</label>
                        <label><input name="five" type="radio" value="偏重" />偏重</label>
                        <label><input name="five" type="radio" value="严重" />严重</label>
                    </h3></td></tr>
            <tr><td><input type="hidden" name="userid" value="<%=userid%>"/>
                    <input type="hidden" name="username" value="<%=username%>"/>
                    <input type="hidden" name="province" value="<%=province%>"/>
                    <input type="hidden" name="administ" value="<%=administ%>"/>
                    <input type="hidden" name="surgest" value="<%=surgest%>"/>
                    <input type="hidden" name="subject" value="<%=subject%>"/>
                    <input type="hidden" name="q1" value="<%=str_back[0]%>"/>
                    <input type="hidden" name="q2" value="<%=str_back[1]%>"/>
                    <input type="hidden" name="q3" value="<%=str_back[2]%>"/>
                    <input type="hidden" name="q4" value="<%=str_back[3]%>"/>
                    <input type="hidden" name="q5" value="<%=str_back[4]%>"/>                  
                    <input type="submit" name="Submit" value="下一步" />                    
                </td></tr>
        </table>
    </form>
    <form action="ALselectSubject.jsp" method="post">
        <table width="874" cellspacing="0" cellpadding="0" border="1">
            <tr><td>
                    <input type="hidden" name="userid" value="<%=userid%>"/>
                    <input type="hidden" name="username" value="<%=username%>"/>
                    <input type="hidden" name="province" value="<%=province%>"/>
                    <input type="hidden" name="administ" value="<%=administ%>"/>
                    <input type="hidden" name="surgest" value="<%=surgest%>"/>                    
                    <input type="submit" name="Submit" value="上一步" /> 
                </td></tr>
        </table>
    </form>
</body>
</html>

 

<%-- 
    Document   : getAnswer
    Created on : 2018-10-8, 21:45:42
    Author     : acer
--%>

<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>智能诊断页</title>
    </head>
    <%    request.setCharacterEncoding("UTF-8");%>
    <body>
    <center><h2>智能诊断结果单</h2></center>
    <hr>
    <%
        String userid = request.getParameter("userid");
        String username = request.getParameter("username");
        String province = request.getParameter("province");
        String administ = request.getParameter("administ");
        String surgest = request.getParameter("surgest");
        String subject = request.getParameter("subject");
        String one = request.getParameter("one");
        String two = request.getParameter("two");
        String three = request.getParameter("three");
        String force = request.getParameter("force");
        String five = request.getParameter("five");
        String q1 = request.getParameter("q1");
        q1 = q1 + one;
        String q2 = request.getParameter("q2");
        q2 = q2 + two;
        String q3 = request.getParameter("q3");
        q3 = q3 + three;
        String q4 = request.getParameter("q4");
        q4 = q4 + force;
        String q5 = request.getParameter("q5");
        q5 = q5 + five;
        String qone = "";
        if (one.equals("正常")) {
            qone = "1";
        } else if (one.equals("轻度")) {
            qone = "2";
        } else if (one.equals("偏重")) {
            qone = "3";
        } else {
            qone = "4";
        }
        String qtow = "";
        if (two.equals("正常")) {
            qtow = "1";
        } else if (two.equals("轻度")) {
            qtow = "2";
        } else if (two.equals("偏重")) {
            qtow = "3";
        } else {
            qtow = "4";
        }
        String qthree = "";
        if (three.equals("正常")) {
            qthree = "1";
        } else if (three.equals("轻度")) {
            qthree = "2";
        } else if (three.equals("偏重")) {
            qthree = "3";
        } else {
            qthree = "4";
        }
        String qforce = "";
        if (force.equals("正常")) {
            qforce = "1";
        } else if (force.equals("轻度")) {
            qforce = "2";
        } else if (force.equals("偏重")) {
            qforce = "3";
        } else {
            qforce = "4";
        }
        String qfive = "";
        if (five.equals("正常")) {
            qfive = "1";
        } else if (five.equals("轻度")) {
            qfive = "2";
        } else if (five.equals("偏重")) {
            qfive = "3";
        } else {
            qfive = "4";
        }
    %>
    <table width="874" cellspacing="0" cellpadding="0" border="1">
        <tr><td><h3>就诊编号:<%=userid%></h3></td></tr>
        <tr><td><h3>用户账号:<%=username%></h3></td></tr>
        <tr><td><h3>门诊部门:<%=surgest%></h3></td></tr>
        <tr><td><h3>病理科室:<%=subject%></h3></td></tr>
        <tr><td><h3>问诊一:<%=q1%></h3></td></tr>
        <tr><td><h3>问诊二:<%=q2%></h3></td></tr>
        <tr><td><h3>问诊三:<%=q3%></h3></td></tr>
        <tr><td><h3>问诊四:<%=q4%></h3></td></tr>
        <tr><td><h3>问诊五:<%=q5%></h3></td></tr>
        <tr><td>
                <%
                    String[] userInfo = new String[]{"python", "F:\\HostitalProject\\src\\java\\pyFile\\zhenduan.py", qone, qtow, qthree, qforce, qfive, userid, username, surgest, subject, province, administ};
                    Process pr = Runtime.getRuntime().exec(userInfo);
                    BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                    List<String> allList = new ArrayList<>();
                    String line;
                    while ((line = in.readLine()) != null) {
                        allList.add(line);
                    }
                    Iterator<String> iter = allList.iterator();
                    int length = allList.size();
                    String[] str_back = new String[length];
                    for (int i = 0; i < str_back.length; i++) {
                        str_back[i] = iter.next();
                    }
                %>
                <h3>诊断结果:<%=str_back[0]%>                </h3>
                <h3><%=str_back[1]%></h3>
                <h3><%=str_back[2]%></h3>
                <h3><%=str_back[3]%></h3>
                <h3><%=str_back[4]%></h3>
                <h3><%=str_back[5]%></h3>
                <h3><%=str_back[6]%></h3>
                <h3><%=str_back[7]%></h3>
                <h3><%=str_back[8]%></h3>
                <h3><%=str_back[9]%></h3>
                <h3><%=str_back[10]%></h3>
                <h3><%=str_back[11]%></h3>
                <h3><%=str_back[12]%></h3>
                <h3><%=str_back[13]%></h3>
            </td></tr>            
    </table> 
    <h2><a href="log.html">返回登录页</a></h2>
</body>
</html>