using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; namespace BatchService.Framework.Utility.DatabaseHelper { [Serializable] public class LISOutputResultInfo { public string sampleDate { get; set; } public string instrument { get; set; } public string sampleNo { get; set; } public string patientId { get; set; } public string orderNo { get; set; } public string barcode { get; set; } public string patientName { get; set; } public string patientGender { get; set; } public string patientAge { get; set; } public string patientType { get; set; } public string itemCode { get; set; } public string itemName { get; set; } public string printOrder { get; set; } public string result { get; set; } public string unit { get; set; } public string report_limit { get; set; } public string Load(string sampleDate, string patientId) { var connString = ConfigHelper.ReadConnectionConfig("LISDBContext", ""); DateTime dt1 = DateTime.Parse(sampleDate); DateTime dt2 = DateTime.Now; string sql = string.Format("select * from tb_current_sample_info where sample_date>'{0}' and sample_date<='{1}' and left(instrument,3)<>'@#@'", dt1.ToString("yyyy-MM-dd"), dt2.ToString("yyyy-MM-dd")); if (!string.IsNullOrEmpty(patientId)) { sql += string.Format(" and patient_id='{0}'", patientId); } var jsonArray = JsonConvert.DeserializeObject(new LISHelper().ExecuteQueySQL(connString, sql)) as JArray; List results = new List(); if (jsonArray != null) { foreach (JObject row in jsonArray) { string instrument = StringHelper.GetString(row["INSTRUMENT"]); sampleDate = StringHelper.GetString(row["SAMPLE_DATE"]); string sampleNo = StringHelper.GetString(row["SAMPLE_NO"]); var itemResults = JsonConvert.DeserializeObject(new LISHelper().ExecuteSampleQueryAction( ConfigHelper.ReadConnectionConfig("LISDBContext", ""), LISHelper.SampleQueryActionType.ValidatedReulstInfo_TB_LABRESULT, instrument, sampleDate, sampleNo)) as JArray; if (itemResults == null) { continue; } foreach (JObject row_result in itemResults) { LISOutputResultInfo resultInfo = new LISOutputResultInfo(); results.Add(resultInfo); resultInfo.barcode = StringHelper.GetString(row["BARCODE"]); resultInfo.instrument = instrument; resultInfo.sampleDate = sampleDate; resultInfo.sampleNo = sampleNo; resultInfo.itemCode = StringHelper.GetString(row_result["item_no"]); resultInfo.itemName = StringHelper.GetString(row_result["item_name"]); resultInfo.orderNo = StringHelper.GetString(row["ORDER_NO"]); resultInfo.patientAge = StringHelper.GetString(row["AGE"]); resultInfo.patientGender = StringHelper.GetString(row["GENDER"]); resultInfo.patientId = StringHelper.GetString(row["PATIENT_ID"]); resultInfo.patientName = StringHelper.GetString(row["PATIENT_NAME"]); resultInfo.patientType = StringHelper.GetString(row["PATIENT_TYPE"]); resultInfo.printOrder = StringHelper.GetString(row_result["print_order"]); resultInfo.report_limit = StringHelper.GetString(row_result["ref"]); resultInfo.result = StringHelper.GetString(row_result["result"]); resultInfo.unit = StringHelper.GetString(row_result["unit"]); } } } return JsonConvert.SerializeObject(results); } } }