public async Task <HttpResponseMessage> MakeXRayExamination()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            // 存储文件到数据库
            //一个对象反序列化的过程
            XrayInfo xrayInfo = (XrayInfo) await ReadAndSaveFile();

            string jsonStr = "";

            try
            {
                jsonStr          = JsonObjectConverter.ObjectToJson(xrayInfo);
                response.Content = new StringContent(jsonStr);
            }
            catch (Exception e)
            {
                response.Content    = new StringContent("post数据格式错误\nReceives:\n" + JsonObjectConverter.ObjectToJson(xrayInfo));
                response.StatusCode = HttpStatusCode.BadRequest;
                return(response);
            }
            // XRay表插入

            if (!ExaminerHelper.MakeXRayExamination(xrayInfo))
            {
                response.Content    = new StringContent("由于某种原因检测插入不成功");
                response.StatusCode = HttpStatusCode.Forbidden;
            }
            else
            {
                response.Content    = new StringContent("检测结果插入表中");
                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
        public async Task <HttpResponseMessage> MakeGastroscopeExamination()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            GastroscopeInfo     gastroInfo;

            try
            {
                gastroInfo = (GastroscopeInfo) await ReadAndSaveFile();
            }
            catch (Exception e)
            {
                response.Content = new StringContent(e.Message);
                return(response);
            }
            try
            {
                if (!ExaminerHelper.MakeGastroscopeExamination(gastroInfo))
                {
                    response.Content    = new StringContent("由于某种原因插入检查结果不成功");
                    response.StatusCode = HttpStatusCode.Forbidden;
                }
                else
                {
                    response.Content    = new StringContent("检测结果插入成功" + JsonObjectConverter.ObjectToJson(gastroInfo));
                    response.StatusCode = HttpStatusCode.OK;
                }
            }
            catch (Exception e)
            {
                response.Content    = new StringContent(e.Message);
                response.StatusCode = HttpStatusCode.BadRequest;
            }

            return(response);
        }
        public HttpResponseMessage GetExamination()
        {
            HttpResponseMessage response = new HttpResponseMessage();
            string docId = HttpContext.Current.User.Identity.Name;
            // get ALL Examination FROM Specific doc_id
            // examination表查找doc_id匹配的数据
            // 序列化返回
            ArrayList list     = null;
            JArray    resArray = new JArray();

            try
            {
                list = ExaminerHelper.GetAllExamination(docId);
            }
            catch (Exception e)
            {
                response.Content = new StringContent(e.Message);
                return(response);
            }
            if (list.Count == 0)
            {
                response.Content    = new StringContent("未找到相关检测记录");
                response.StatusCode = HttpStatusCode.NotFound;
            }
            else
            {
                foreach (ExaminationInfo item in list)
                {
                    JObject     obj          = new JObject();
                    string      treat_id     = UserHelper.GetTreatmentIdByExamId(item.exam_id);
                    string      patient_id   = UserHelper.GetPatientIdByTreatmentId(treat_id);
                    PatientInfo patient_info = UserHelper.GetPatientInfo(patient_id);
                    if (patient_info == null)
                    {
                        continue;
                    }
                    obj.Add("exam_id", item.exam_id);
                    obj.Add("name", patient_info.name);
                    obj.Add("sex", patient_info.sex);
                    obj.Add("type", item.type);
                    obj.Add("exam_time", item.exam_time);
                    resArray.Add(obj);
                }
                response.Content    = new StringContent(JsonObjectConverter.ObjectToJson(resArray));
                response.StatusCode = HttpStatusCode.OK;
            }


            //response.Content = new StringContent(JsonObjectConverter.ObjectToJson(new Examination()));
            return(response);
        }
        public HttpResponseMessage MakeBloodExamination(dynamic obj)
        {
            string exam_id       = obj.exam_id.Value;
            string wbc           = obj.wbc.Value;
            string neut_percent  = obj.neut_percent.Value;
            string lymph_percent = obj.lymph_percent.Value;
            string mono_percent  = obj.mono_percent.Value;
            string eo_percent    = obj.eo_percent.Value;
            string baso_percent  = obj.baso_percent.Value;
            string neut_num      = obj.neut_num.Value;
            string lymph_num     = obj.lymph_num.Value;
            string mono_num      = obj.mono_num.Value;
            string eo_num        = obj.eo_num.Value;
            string baso_num      = obj.baso_num.Value;
            string rbc           = obj.rbc.Value;
            string hgb           = obj.hgb.Value;
            string hct           = obj.hct.Value;
            string mcv           = obj.mcv.Value;
            string mch           = obj.mch.Value;
            string mchc          = obj.mchc.Value;
            string rdw_cv        = obj.rdw_cv.Value;
            string rdw_sd        = obj.rdw_sd.Value;
            string plt           = obj.plt.Value;
            string mpv           = obj.mpv.Value;
            string pdw           = obj.pdw.Value;
            string pct           = obj.pct.Value;

            HttpResponseMessage response = new HttpResponseMessage();

            Blood blood = new Blood();

            try
            {
                blood = JsonConvert.DeserializeAnonymousType(JsonObjectConverter.ObjectToJson(obj), blood);

                // Blood表插入
                ExaminerHelper.MakeBloodExamination(blood);
            }
            catch (Exception e)
            {
                response.Content    = new StringContent(e.Message);
                response.StatusCode = HttpStatusCode.BadRequest;
            }
            return(response);
        }
        public HttpResponseMessage GetPatientNameById(string examInfo)
        {
            ArrayList list = ExaminerHelper.GetPatientByExamId(examInfo);

            HttpResponseMessage response = new HttpResponseMessage();

            if (list == null)
            {
                response.Content    = new StringContent("查询失败");
                response.StatusCode = HttpStatusCode.NotFound;
            }
            else if (list.Count == 0)
            {
                response.Content    = new StringContent("查询失败");
                response.StatusCode = HttpStatusCode.BadRequest;
            }
            else
            {
                response.Content    = new StringContent(JsonObjectConverter.ObjectToJson(list));
                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }