Beispiel #1
0
    // 将患者出院未出院字段改为已经出院,返回病人信息和费用
    public static LeaveInformation LeaveHospital(String ID)
    {
        DatabaseTool.ExecSql(String.Format(UPDATE_PATIENT_CONDITION, ID));                              //更新患者状态为已出院
        DatabaseTool.ExecSql(String.Format(UPDATE_DISCHARGE_TIME, System.DateTime.Now.ToString(), ID)); //插入病人出院时间
        //全部订单存放至orders
        List <Dictionary <String, Object> > sqlResult1 = DatabaseTool.ExecSqlReturn(String.Format(SELECT_ALL_ORDERS_BY_ID, ID));
        List <Order> orders = new List <Order>();

        foreach (Dictionary <String, Object> dic in sqlResult1)    //遍历结果集,每一条都加入list
        {
            orders.Add(Order.CreateOrder(dic));
        }
        //获取入院时间与出院时间,计算时间差
        DateTime admissionTime = Convert.ToDateTime(DatabaseTool.ExeclSqlReturnItem(String.Format(SELECT_PATIENT_BY_ID, ID), "admission_time"));

        DateTime dischargeTime = Convert.ToDateTime(DatabaseTool.ExeclSqlReturnItem(String.Format(SELECT_PATIENT_BY_ID, ID), "discharge_time"));
        TimeSpan ts            = dischargeTime.Subtract(admissionTime).Duration();
        String   dateDiff      = ts.Days.ToString() + "天";
        //获取全部医嘱存放至advices
        List <DoctorsAdvice> advices = new List <DoctorsAdvice>();
        List <Dictionary <String, Object> > sqlResult2 = DatabaseTool.ExecSqlReturn(String.Format(SELECT_ALL_ADVICES_BY_ID, ID));

        foreach (Dictionary <String, Object> dic in sqlResult2)  //遍历结果集,每一条都加入list
        {
            advices.Add(DoctorsAdvice.CreateDoctorsAdvice(dic));
        }
        //计算最终费用存放至totalPrice
        Decimal totalPrice = DatabaseTool.ExeclSqlDecimal(String.Format(SELECT_ALL_PRICE, ID));

        //获取用户部分信息
        PatientPartInformation partInformation         = new PatientPartInformation();
        List <Dictionary <String, Object> > sqlResult3 = DatabaseTool.ExecSqlReturn(String.Format(SELECT_PATIENT_BY_ID, ID));

        foreach (Dictionary <String, Object> dic in sqlResult3) //遍历结果集,每一条都加入list
        {
            partInformation = PatientPartInformation.CreatePatientInformation(dic);
        }


        //新建信息对象,返回
        LeaveInformation information = LeaveInformation.CreateLeavelInformation(advices, dateDiff, orders, totalPrice, partInformation);

        return(information);
    }