Exemplo n.º 1
0
 ///<summary>Inserts one LabResult into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(LabResult labResult,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         labResult.LabResultNum=ReplicationServers.GetKey("labresult","LabResultNum");
     }
     string command="INSERT INTO labresult (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="LabResultNum,";
     }
     command+="LabPanelNum,DateTimeTest,TestName,TestID,ObsValue,ObsUnits,ObsRange,AbnormalFlag) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(labResult.LabResultNum)+",";
     }
     command+=
              POut.Long  (labResult.LabPanelNum)+","
         +    POut.DateT (labResult.DateTimeTest)+","
         +"'"+POut.String(labResult.TestName)+"',"
         //DateTStamp can only be set by MySQL
         +"'"+POut.String(labResult.TestID)+"',"
         +"'"+POut.String(labResult.ObsValue)+"',"
         +"'"+POut.String(labResult.ObsUnits)+"',"
         +"'"+POut.String(labResult.ObsRange)+"',"
         +    POut.Int   ((int)labResult.AbnormalFlag)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         labResult.LabResultNum=Db.NonQ(command,true);
     }
     return labResult.LabResultNum;
 }
Exemplo n.º 2
0
 ///<summary>Inserts one LabResult into the database.  Returns the new priKey.</summary>
 internal static long Insert(LabResult labResult)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         labResult.LabResultNum=DbHelper.GetNextOracleKey("labresult","LabResultNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(labResult,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     labResult.LabResultNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(labResult,false);
     }
 }
Exemplo n.º 3
0
        protected void btnSaveLabResult_Click(object sender, EventArgs e)
        {
            LabResult labresult = null;

            if (txtUID.Value == "0")
            {
                if (!IsLabResultUnique(txtDescription.Value, 0))
                {
                    divErrorDuplicate.Visible = true;

                    RenderItems();
                    return;
                }

                labresult = new LabResult {
                    Description = txtDescription.Value
                };

                UnitOfWork.Repository <LabResult>().Save(labresult);
            }
            else
            {
                labresult = GetLabResult(Convert.ToInt32(txtUID.Value));

                if (labresult != null)
                {
                    if (!IsLabResultUnique(txtDescription.Value, labresult.Id))
                    {
                        divErrorDuplicate.Visible = true;

                        RenderItems();
                        return;
                    }

                    labresult.Description = txtDescription.Value;

                    UnitOfWork.Repository <LabResult>().Update(labresult);
                }
            }

            UnitOfWork.Complete();

            RenderItems();
            divstatus.Visible = true;
        }
Exemplo n.º 4
0
        private void CreateLabPanel()
        {
            MedicalOrder order = listLabOrders[gridMain.GetSelectedIndex()];
            MessageHL7   msg   = new MessageHL7(textHL7Raw.Text);
            //SegmentHL7 segOBR=null;
            //SegmentHL7 segOBX=null;
            //int idxPanel=0;
            //int idxResult=0;
            LabPanel  panel  = null;
            LabResult result = null;

            //loop through all message segments.
            for (int i = 0; i < msg.Segments.Count; i++)
            {
                if (msg.Segments[i].Name == SegmentNameHL7.OBR)              //if this is the start of a new panel
                {
                    panel                   = new LabPanel();
                    panel.PatNum            = order.PatNum;
                    panel.MedicalOrderNum   = order.MedicalOrderNum;
                    panel.RawMessage        = textHL7Raw.Text;
                    panel.LabNameAddress    = msg.Segments[i].GetFieldFullText(20);
                    panel.SpecimenSource    = msg.Segments[i].GetFieldFullText(15);
                    panel.SpecimenCondition = msg.Segments[i].GetFieldFullText(13);
                    panel.ServiceId         = msg.Segments[i].GetFieldComponent(4, 0);
                    panel.ServiceName       = msg.Segments[i].GetFieldComponent(4, 1);
                    LabPanels.Insert(panel);
                }
                if (msg.Segments[i].Name == SegmentNameHL7.OBX)              //if this is a result within a panel
                {
                    result              = new LabResult();
                    result.LabPanelNum  = panel.LabPanelNum;
                    result.DateTimeTest = msg.Segments[i].GetDateTime(14);
                    result.TestID       = msg.Segments[i].GetFieldComponent(3, 0);
                    result.TestName     = msg.Segments[i].GetFieldComponent(3, 1);
                    result.ObsValue     = msg.Segments[i].GetFieldFullText(5);
                    result.ObsUnits     = msg.Segments[i].GetFieldFullText(6);
                    result.ObsRange     = msg.Segments[i].GetFieldFullText(7);
                    LabResults.Insert(result);
                }
                //any other kind of segment, continue.
            }
            //order.IsLabPending=false;
            //MedicalOrders.Update(order);
            //return true;//I guess it's always true?
        }
Exemplo n.º 5
0
        public LabResult setLabResult(DataTable dt)
        {
            LabResult dgs1 = new LabResult();

            if (dt.Rows.Count > 0)
            {
                dgs1.result_id         = dt.Rows[0][lbRes.result_id].ToString();
                dgs1.lis_id            = dt.Rows[0][lbRes.lis_id].ToString();
                dgs1.req_id            = dt.Rows[0][lbRes.req_id].ToString();
                dgs1.visit_id          = dt.Rows[0][lbRes.visit_id].ToString();
                dgs1.patient_id        = dt.Rows[0][lbRes.patient_id].ToString();
                dgs1.lab_id            = dt.Rows[0][lbRes.lab_id].ToString();
                dgs1.result            = dt.Rows[0][lbRes.result].ToString();
                dgs1.method            = dt.Rows[0][lbRes.method].ToString();
                dgs1.active            = dt.Rows[0][lbRes.active].ToString();
                dgs1.remark            = dt.Rows[0][lbRes.remark].ToString();
                dgs1.date_create       = dt.Rows[0][lbRes.date_create].ToString();
                dgs1.date_modi         = dt.Rows[0][lbRes.date_modi].ToString();
                dgs1.date_cancel       = dt.Rows[0][lbRes.date_cancel].ToString();
                dgs1.user_create       = dt.Rows[0][lbRes.user_create].ToString();
                dgs1.user_modi         = dt.Rows[0][lbRes.user_modi].ToString();
                dgs1.user_cancel       = dt.Rows[0][lbRes.user_cancel].ToString();
                dgs1.unit              = dt.Rows[0][lbRes.unit].ToString();
                dgs1.sort1             = dt.Rows[0][lbRes.sort1].ToString();
                dgs1.staff_id_result   = dt.Rows[0][lbRes.staff_id_result].ToString();
                dgs1.staff_id_approve  = dt.Rows[0][lbRes.staff_id_approve].ToString();
                dgs1.date_time_result  = dt.Rows[0][lbRes.date_time_result].ToString();
                dgs1.date_time_approve = dt.Rows[0][lbRes.date_time_approve].ToString();
                dgs1.normal_value      = dt.Rows[0][lbRes.date_time_approve].ToString();
                dgs1.status_result     = dt.Rows[0][lbRes.status_result].ToString();
                dgs1.row1              = dt.Rows[0][lbRes.row1].ToString();
                //dgs1.remark = dt.Rows[0][lbRes.remark].ToString();
                dgs1.req_date_time     = dt.Rows[0][lbRes.req_date_time].ToString();
                dgs1.date_time_receive = dt.Rows[0][lbRes.date_time_receive].ToString();
                dgs1.reactive_message  = dt.Rows[0][lbRes.reactive_message].ToString();
                dgs1.doctor_id         = dt.Rows[0][lbRes.doctor_id].ToString();
                dgs1.date_time_collect = dt.Rows[0][lbRes.date_time_collect].ToString();
                dgs1.remark_nurse      = dt.Rows[0][lbRes.remark_nurse].ToString();
            }
            else
            {
                setLabResult(dgs1);
            }
            return(dgs1);
        }
Exemplo n.º 6
0
 public void Add(LabResult Entity)
 {
     if (IsValid(Entity))
     {
         using (var context = new DatabaseContainer())
         {
             context.LabResultSet.Add(Entity);
             try
             {
                 context.SaveChanges();
             }
             catch (Exception)
             {
                 throw new ArgumentException("There is already a lab result with that id");
             }
         }
     }
 }
Exemplo n.º 7
0
        public async Task <IActionResult> CreateLabResult(
            [FromBody] LabResultForUpdateDto labResultForUpdate)
        {
            if (labResultForUpdate == null)
            {
                ModelState.AddModelError("Message", "Unable to locate payload for new request");
                return(BadRequest(ModelState));
            }

            if (_unitOfWork.Repository <LabResult>().Queryable().
                Where(l => l.Description == labResultForUpdate.LabResultName)
                .Count() > 0)
            {
                ModelState.AddModelError("Message", "Item with same name already exists");
                return(BadRequest(ModelState));
            }

            long id = 0;

            if (ModelState.IsValid)
            {
                var newLabResult = new LabResult()
                {
                    Description = labResultForUpdate.LabResultName,
                    Active      = true
                };

                _labResultRepository.Save(newLabResult);
                id = newLabResult.Id;
            }

            var mappedLabResult = await GetLabResultAsync <LabResultIdentifierDto>(id);

            if (mappedLabResult == null)
            {
                return(StatusCode(500, "Unable to locate newly added item"));
            }

            return(CreatedAtAction("GetLabResultByIdentifier",
                                   new
            {
                id = mappedLabResult.Id
            }, CreateLinksForLabResult <LabResultIdentifierDto>(mappedLabResult)));
        }
        public LabResult UpdatePatient(LabResult labresult)
        {
            var session = HttpContext.Current.Session;

            if (session["UserId"] != null)
            {
                userId = session["UserId"].ToString();
            }
            LabResult       labsr = _labresults.UpdatePatient(labresult);
            EncounterReport erp   = new EncounterReport();

            erp.RefId     = labsr._id;
            erp.PatientId = labsr.UserId;
            erp.UpdateBy  = userId;
            erp.Action    = "update LabResult";
            var encreports = encrepo.AddEncReport(erp);

            return(labsr);
        }
        public void Update(LabResult labResult)
        {
            var currentLabResult = _data.FirstOrDefault(p => p.Id == labResult.Id);

            if (currentLabResult == null)
            {
                return;
            }

            currentLabResult.TestType          = labResult.TestType;
            currentLabResult.Result            = labResult.Result;
            currentLabResult.PatientId         = labResult.PatientId;
            currentLabResult.TimeOfTest        = labResult.TimeOfTest;
            currentLabResult.EnteredTime       = labResult.EnteredTime;
            currentLabResult.LabName           = labResult.LabName;
            currentLabResult.OrderedByProvider = labResult.OrderedByProvider;
            currentLabResult.Measurement       = labResult.Measurement;
            currentLabResult.MeasurementUnit   = labResult.MeasurementUnit;
        }
Exemplo n.º 10
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<LabResult> TableToList(DataTable table){
			List<LabResult> retVal=new List<LabResult>();
			LabResult labResult;
			for(int i=0;i<table.Rows.Count;i++) {
				labResult=new LabResult();
				labResult.LabResultNum= PIn.Long  (table.Rows[i]["LabResultNum"].ToString());
				labResult.LabPanelNum = PIn.Long  (table.Rows[i]["LabPanelNum"].ToString());
				labResult.DateTimeTest= PIn.DateT (table.Rows[i]["DateTimeTest"].ToString());
				labResult.TestName    = PIn.String(table.Rows[i]["TestName"].ToString());
				labResult.DateTStamp  = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				labResult.TestID      = PIn.String(table.Rows[i]["TestID"].ToString());
				labResult.ObsValue    = PIn.String(table.Rows[i]["ObsValue"].ToString());
				labResult.ObsUnits    = PIn.String(table.Rows[i]["ObsUnits"].ToString());
				labResult.ObsRange    = PIn.String(table.Rows[i]["ObsRange"].ToString());
				labResult.AbnormalFlag= (LabAbnormalFlag)PIn.Int(table.Rows[i]["AbnormalFlag"].ToString());
				retVal.Add(labResult);
			}
			return retVal;
		}
Exemplo n.º 11
0
 /// <summary>
 /// 将查询到的检查项目列表绑定到gridview中
 /// </summary>
 /// <param name="dgvResultList">gridview</param>
 /// <param name="lstResultInfo">检查项目列表</param>
 private void BindResultList(DataGridView dgvResultList, List <LabResult> lstResultInfo)
 {
     dgvResultList.Rows.Clear();
     for (int index = lstResultInfo.Count - 1; index >= 0; index--)
     {
         LabResult resultInfo = lstResultInfo[index];
         if (resultInfo == null)
         {
             continue;
         }
         int             nRowIndex = dgvResultList.Rows.Add();
         DataGridViewRow row       = dgvResultList.Rows[nRowIndex];
         row.Cells[0].Value = resultInfo.ITEM_NAME;
         row.Cells[1].Value = resultInfo.ITEM_RESULT;
         row.Cells[2].Value = resultInfo.ITEM_UNITS;
         row.Cells[3].Value = resultInfo.ABNORMAL_INDICATOR;
         row.Cells[4].Value = resultInfo.ITEM_REFER;
     }
 }
Exemplo n.º 12
0
        private void initConfig()
        {
            lbRes = new LabResult();
            lDgs  = new List <LabResult>();

            lbRes.result_id         = "result_id";
            lbRes.lis_id            = "lis_id";
            lbRes.req_id            = "req_id";
            lbRes.visit_id          = "visit_id";
            lbRes.patient_id        = "patient_id";
            lbRes.lab_id            = "lab_id";
            lbRes.result            = "result";
            lbRes.method            = "method";
            lbRes.active            = "active";
            lbRes.remark            = "remark";
            lbRes.date_create       = "date_create";
            lbRes.date_modi         = "date_modi";
            lbRes.date_cancel       = "date_cancel";
            lbRes.user_create       = "user_create";
            lbRes.user_modi         = "user_modi";
            lbRes.user_cancel       = "user_cancel";
            lbRes.unit              = "unit";
            lbRes.sort1             = "sort1";
            lbRes.staff_id_result   = "staff_id_result";
            lbRes.staff_id_approve  = "staff_id_approve";
            lbRes.date_time_result  = "date_time_result";
            lbRes.date_time_approve = "date_time_approve";
            lbRes.normal_value      = "normal_value";
            lbRes.interpret         = "interpret";
            lbRes.status_result     = "status_result";
            lbRes.row1              = "row1";
            lbRes.lot_input         = "lot_input";
            lbRes.req_date_time     = "req_date_time";
            lbRes.date_time_receive = "date_time_receive";
            lbRes.reactive_message  = "reactive_message";
            lbRes.doctor_id         = "doctor_id";
            lbRes.date_time_collect = "date_time_collect";
            lbRes.remark_nurse      = "remark_nurse";

            lbRes.table   = "lab_t_result";
            lbRes.pkField = "result_id";
        }
Exemplo n.º 13
0
        public Student CreateStudent(Student s)
        {
            MembershipUser user     = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            string         userId   = user.ToString();
            Guid           userGuid = new Guid(user.ProviderUserKey.ToString());

            s.UserId  = userGuid;
            s.Created = System.DateTime.Now;
            _datacontext.Students.InsertOnSubmit(s);
            _datacontext.SubmitChanges();
            LabResult lr = new LabResult();

            lr.StudentId = s.StudentId;
            lr.Lab1      = "-";
            lr.Lab2      = "-";
            lr.Lab3      = "-";
            _datacontext.LabResults.InsertOnSubmit(lr);
            _datacontext.SubmitChanges();
            return(s);
        }
Exemplo n.º 14
0
        private void chkNull(LabResult p)
        {
            long chk = 0;

            p.date_modi   = p.date_modi == null ? "" : p.date_modi;
            p.date_cancel = p.date_cancel == null ? "" : p.date_cancel;
            p.user_create = p.user_create == null ? "" : p.user_create;
            p.user_modi   = p.user_modi == null ? "" : p.user_modi;
            p.user_cancel = p.user_cancel == null ? "" : p.user_cancel;

            p.visit_id = p.visit_id == null ? "" : p.visit_id;
            //p.patient_id = p.patient_id == null ? "" : p.patient_id;
            //p.lab_id = p.lab_id == null ? "" : p.lab_id;
            p.result    = p.result == null ? "" : p.result;
            p.method    = p.method == null ? "" : p.method;
            p.remark    = p.remark == null ? "" : p.remark;
            p.unit      = p.unit == null ? "" : p.unit;
            p.interpret = p.interpret == null ? "" : p.interpret;
            //p.normal_value = p.normal_value == null ? "" : p.normal_value;
            p.date_time_result  = p.date_time_result == null ? "" : p.date_time_result;
            p.date_time_approve = p.date_time_approve == null ? "" : p.date_time_approve;
            p.normal_value      = p.normal_value == null ? "" : p.normal_value;
            p.status_result     = p.status_result == null ? "0" : p.status_result;
            p.row1              = p.row1 == null ? "0" : p.row1;
            p.lot_input         = p.lot_input == null ? "0" : p.lot_input;
            p.req_date_time     = p.req_date_time == null ? "" : p.req_date_time;
            p.date_time_receive = p.date_time_receive == null ? "" : p.date_time_receive;
            p.reactive_message  = p.reactive_message == null ? "" : p.reactive_message;
            p.date_time_collect = p.date_time_collect == null ? "" : p.date_time_collect;
            p.remark_nurse      = p.remark_nurse == null ? "" : p.remark_nurse;

            p.lis_id           = long.TryParse(p.lis_id, out chk) ? chk.ToString() : "0";
            p.req_id           = long.TryParse(p.req_id, out chk) ? chk.ToString() : "0";
            p.sort1            = long.TryParse(p.sort1, out chk) ? chk.ToString() : "0";
            p.staff_id_result  = long.TryParse(p.staff_id_result, out chk) ? chk.ToString() : "0";
            p.staff_id_approve = long.TryParse(p.staff_id_approve, out chk) ? chk.ToString() : "0";
            p.lab_id           = long.TryParse(p.lab_id, out chk) ? chk.ToString() : "0";
            p.patient_id       = long.TryParse(p.patient_id, out chk) ? chk.ToString() : "0";
            p.visit_id         = long.TryParse(p.visit_id, out chk) ? chk.ToString() : "0";
            p.doctor_id        = long.TryParse(p.doctor_id, out chk) ? chk.ToString() : "0";
        }
Exemplo n.º 15
0
        public IActionResult Post(LabResult labResult)
        {
            var patient      = _patientRepository.GetById(labResult.PatientId);
            var errorMessage = ValidateData(labResult, patient);

            if (!String.IsNullOrEmpty(errorMessage))
            {
                return(BadRequest(errorMessage));
            }

            try
            {
                _labResultRepository.Add(labResult);
                var cacheKey = "LabResult" + labResult.Id;
                return(CreatedAtAction("Get", new { id = labResult.Id }, labResult));
            }
            catch (Exception e)
            {
                return(StatusCode(500, $"Cannot save this lab report -- internal error {e}"));
            }
        }
        /// <summary>
        /// Patient Lab Results Information
        /// </summary>
        /// <param name="dataArr"></param>
        /// <returns></returns>
        public List <LabResult> GetLabResults(Dictionary <string, ArrayList> dataArr)
        {
            List <LabResult> labResult = new List <LabResult>();

            if (dataArr.Count > 0)
            {
                for (int i = 0; i < dataArr.Count; i++)
                {
                    LabResult ptLabResult   = new LabResult();
                    ArrayList itemlabResult = dataArr[i.ToString()];
                    ptLabResult.LonicCode      = itemlabResult[4] == null ? "" : itemlabResult[4].ToString();
                    ptLabResult.TestPerformed  = itemlabResult[0].ToString();
                    ptLabResult.ReportDate     = itemlabResult[2].ToString() == "null" ? null : new DateTime?(Convert.ToDateTime(itemlabResult[2].ToString()));
                    ptLabResult.TestResultn    = itemlabResult[1].ToString().Split(" ")[0].ToString();
                    ptLabResult.Units          = itemlabResult[1].ToString().Split(" ")[1].ToString();
                    ptLabResult.NormalFindings = itemlabResult[3].ToString();
                    labResult.Add(ptLabResult);
                }
            }
            return(labResult);
        }
Exemplo n.º 17
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <LabResult> TableToList(DataTable table)
        {
            List <LabResult> retVal = new List <LabResult>();
            LabResult        labResult;

            foreach (DataRow row in table.Rows)
            {
                labResult = new LabResult();
                labResult.LabResultNum = PIn.Long(row["LabResultNum"].ToString());
                labResult.LabPanelNum  = PIn.Long(row["LabPanelNum"].ToString());
                labResult.DateTimeTest = PIn.DateT(row["DateTimeTest"].ToString());
                labResult.TestName     = PIn.String(row["TestName"].ToString());
                labResult.DateTStamp   = PIn.DateT(row["DateTStamp"].ToString());
                labResult.TestID       = PIn.String(row["TestID"].ToString());
                labResult.ObsValue     = PIn.String(row["ObsValue"].ToString());
                labResult.ObsUnits     = PIn.String(row["ObsUnits"].ToString());
                labResult.ObsRange     = PIn.String(row["ObsRange"].ToString());
                labResult.AbnormalFlag = (OpenDentBusiness.LabAbnormalFlag)PIn.Int(row["AbnormalFlag"].ToString());
                retVal.Add(labResult);
            }
            return(retVal);
        }
Exemplo n.º 18
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <LabResult> TableToList(DataTable table)
        {
            List <LabResult> retVal = new List <LabResult>();
            LabResult        labResult;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                labResult = new LabResult();
                labResult.LabResultNum = PIn.Long(table.Rows[i]["LabResultNum"].ToString());
                labResult.LabPanelNum  = PIn.Long(table.Rows[i]["LabPanelNum"].ToString());
                labResult.DateTimeTest = PIn.DateT(table.Rows[i]["DateTimeTest"].ToString());
                labResult.TestName     = PIn.String(table.Rows[i]["TestName"].ToString());
                labResult.DateTStamp   = PIn.DateT(table.Rows[i]["DateTStamp"].ToString());
                labResult.TestID       = PIn.String(table.Rows[i]["TestID"].ToString());
                labResult.ObsValue     = PIn.String(table.Rows[i]["ObsValue"].ToString());
                labResult.ObsUnits     = PIn.String(table.Rows[i]["ObsUnits"].ToString());
                labResult.ObsRange     = PIn.String(table.Rows[i]["ObsRange"].ToString());
                labResult.AbnormalFlag = (LabAbnormalFlag)PIn.Int(table.Rows[i]["AbnormalFlag"].ToString());
                retVal.Add(labResult);
            }
            return(retVal);
        }
Exemplo n.º 19
0
        public String selectRowNoByHnVn(String lab_id, String result, String docgid)
        {
            String    re = "0", re1 = "";
            int       chk  = 0;
            LabResult cop1 = new LabResult();
            DataTable dt   = new DataTable();
            String    sql  = "select max(" + lbRes.req_id + ") as " + lbRes.req_id + " " +
                             "From " + lbRes.table + " dsc " +
                             //"Left Join f_patient_prefix pfx On stf.prefix_id = pfx.f_patient_prefix_id " +
                             "Where dsc." + lbRes.lab_id + " ='" + lab_id + "' and dsc." + lbRes.lis_id + "='" + docgid + "' and dsc." + lbRes.result + "='" + result + "' " +
                             "  ";

            dt = conn.selectData(conn.conn, sql);
            if (dt.Rows.Count > 0)
            {
                re1 = dt.Rows[0][lbRes.req_id].ToString();
                int.TryParse(re1, out chk);
                chk++;
                re = chk.ToString();
            }
            return(re);
        }
Exemplo n.º 20
0
        ///<summary>Inserts one LabResult into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(LabResult labResult, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO labresult (";

            if (!useExistingPK && isRandomKeys)
            {
                labResult.LabResultNum = ReplicationServers.GetKeyNoCache("labresult", "LabResultNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "LabResultNum,";
            }
            command += "LabPanelNum,DateTimeTest,TestName,TestID,ObsValue,ObsUnits,ObsRange,AbnormalFlag) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(labResult.LabResultNum) + ",";
            }
            command +=
                POut.Long(labResult.LabPanelNum) + ","
                + POut.DateT(labResult.DateTimeTest) + ","
                + "'" + POut.String(labResult.TestName) + "',"
                //DateTStamp can only be set by MySQL
                + "'" + POut.String(labResult.TestID) + "',"
                + "'" + POut.String(labResult.ObsValue) + "',"
                + "'" + POut.String(labResult.ObsUnits) + "',"
                + "'" + POut.String(labResult.ObsRange) + "',"
                + POut.Int((int)labResult.AbnormalFlag) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                labResult.LabResultNum = Db.NonQ(command, true, "LabResultNum", "labResult");
            }
            return(labResult.LabResultNum);
        }
Exemplo n.º 21
0
        ///<summary>Inserts one LabResult into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(LabResult labResult, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                labResult.LabResultNum = ReplicationServers.GetKey("labresult", "LabResultNum");
            }
            string command = "INSERT INTO labresult (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "LabResultNum,";
            }
            command += "LabPanelNum,DateTimeTest,TestName,TestID,ObsValue,ObsUnits,ObsRange,AbnormalFlag) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(labResult.LabResultNum) + ",";
            }
            command +=
                POut.Long(labResult.LabPanelNum) + ","
                + POut.DateT(labResult.DateTimeTest) + ","
                + "'" + POut.String(labResult.TestName) + "',"
                //DateTStamp can only be set by MySQL
                + "'" + POut.String(labResult.TestID) + "',"
                + "'" + POut.String(labResult.ObsValue) + "',"
                + "'" + POut.String(labResult.ObsUnits) + "',"
                + "'" + POut.String(labResult.ObsRange) + "',"
                + POut.Int((int)labResult.AbnormalFlag) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                labResult.LabResultNum = Db.NonQ(command, true);
            }
            return(labResult.LabResultNum);
        }
Exemplo n.º 22
0
 ///<summary>Returns true if Update(LabResult,LabResult) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(LabResult labResult, LabResult oldLabResult)
 {
     if (labResult.LabPanelNum != oldLabResult.LabPanelNum)
     {
         return(true);
     }
     if (labResult.DateTimeTest != oldLabResult.DateTimeTest)
     {
         return(true);
     }
     if (labResult.TestName != oldLabResult.TestName)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (labResult.TestID != oldLabResult.TestID)
     {
         return(true);
     }
     if (labResult.ObsValue != oldLabResult.ObsValue)
     {
         return(true);
     }
     if (labResult.ObsUnits != oldLabResult.ObsUnits)
     {
         return(true);
     }
     if (labResult.ObsRange != oldLabResult.ObsRange)
     {
         return(true);
     }
     if (labResult.AbnormalFlag != oldLabResult.AbnormalFlag)
     {
         return(true);
     }
     return(false);
 }
        public ActionResult DonationComplete(AddDonateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddDonation", model));
            }

            if (model.Plasma < 0 || model.RedCell < 0 || model.Thrombocytes < 0)
            {
                ModelState.AddModelError(String.Empty, "Quantity cannot be 0");
                return(View("AddDonation", model));
            }
            else if (model.Date < DateTime.Today)
            {
                ModelState.AddModelError(String.Empty, "Date cannot be before today");
                return(View("AddDonation", model));
            }
            else
            {
                DonationAppointment app = _donationAppointmentService.GetById(model.AppointmentId);
                _donationAppointmentService.Update(app.Id, app.AppointmentDate, app.RequestId, true, app.ProfileId,
                                                   app.TransfusionCenterId);
                Plasma       p = _plasmaService.Add(model.Date.AddMonths(2), null, model.Plasma);
                RedCell      r = _redCellService.Add(model.Date.AddDays(42), null, model.RedCell);
                Thrombocytes t = _thrombocytesService.Add(model.Date.AddDays(5), null, model.Thrombocytes);

                BloodSeparation b = _bloodSeparation.Add(p.Id, r.Id, t.Id);

                Donation d = _donationService.Add(app.RequestId, model.Plasma + model.RedCell + model.Thrombocytes, model.Date, false,
                                                  StatusEnum.Preparated, app.ProfileId, b.Id, model.BloodType);

                LabResult lb = _labResultService.Add(false, false, false, false, false, "None", d.Id);
            }


            return(View("AddDonation", model));
        }
Exemplo n.º 24
0
 public LabResult setLabResult(LabResult dgs1)
 {
     dgs1.result_id         = "";
     dgs1.lis_id            = "";
     dgs1.req_id            = "";
     dgs1.visit_id          = "";
     dgs1.patient_id        = "";
     dgs1.lab_id            = "";
     dgs1.result            = "";
     dgs1.method            = "";
     dgs1.active            = "";
     dgs1.remark            = "";
     dgs1.date_create       = "";
     dgs1.date_modi         = "";
     dgs1.date_cancel       = "";
     dgs1.user_create       = "";
     dgs1.user_modi         = "";
     dgs1.user_cancel       = "";
     dgs1.unit              = "";
     dgs1.sort1             = "";
     dgs1.staff_id_result   = "";
     dgs1.staff_id_approve  = "";
     dgs1.date_time_result  = "";
     dgs1.date_time_approve = "";
     dgs1.normal_value      = "";
     dgs1.status_result     = "";
     dgs1.row1              = "";
     //dgs1.remark = "";
     dgs1.req_date_time     = "";
     dgs1.date_time_receive = "";
     dgs1.reactive_message  = "";
     dgs1.doctor_id         = "";
     dgs1.date_time_collect = "";
     dgs1.remark_nurse      = "";
     return(dgs1);
 }
Exemplo n.º 25
0
		///<summary>Updates one LabResult in the database.</summary>
		public static void Update(LabResult labResult){
			string command="UPDATE labresult SET "
				+"LabPanelNum =  "+POut.Long  (labResult.LabPanelNum)+", "
				+"DateTimeTest=  "+POut.DateT (labResult.DateTimeTest)+", "
				+"TestName    = '"+POut.String(labResult.TestName)+"', "
				//DateTStamp can only be set by MySQL
				+"TestID      = '"+POut.String(labResult.TestID)+"', "
				+"ObsValue    = '"+POut.String(labResult.ObsValue)+"', "
				+"ObsUnits    = '"+POut.String(labResult.ObsUnits)+"', "
				+"ObsRange    = '"+POut.String(labResult.ObsRange)+"', "
				+"AbnormalFlag=  "+POut.Int   ((int)labResult.AbnormalFlag)+" "
				+"WHERE LabResultNum = "+POut.Long(labResult.LabResultNum);
			Db.NonQ(command);
		}
Exemplo n.º 26
0
        private void LoadLabTestList()
        {
            this.dgvLabMaster.SuspendLayout();
            this.dgvLabMaster.Rows.Clear();
            this.dgvLabMaster.ResumeLayout();

            if (this.MainForm == null || this.MainForm.IsDisposed)
            {
                return;
            }
            if (SystemParam.Instance.PatVisitInfo == null)
            {
                return;
            }

            string           szPatientID  = SystemParam.Instance.PatVisitInfo.PATIENT_ID;
            string           szVisitID    = SystemParam.Instance.PatVisitInfo.VISIT_ID;
            List <LabMaster> lstLabMaster = null;

            if (GlobalMethods.Misc.IsEmptyString(szPatientID) || GlobalMethods.Misc.IsEmptyString(szVisitID))
            {
                return;
            }
            short shRet = LabMasterAccess.Instance.GetList(szPatientID, szVisitID, ref lstLabMaster);

            if (shRet != SystemData.ReturnValue.OK && shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("检验主记录数据下载失败!");
                return;
            }
            if (lstLabMaster == null || lstLabMaster.Count <= 0)
            {
                return;
            }
            string szTestIDs = string.Empty;

            foreach (var item in lstLabMaster)
            {
                if (szTestIDs == string.Empty)
                {
                    szTestIDs = "'" + item.TEST_ID + "'";
                }
                else
                {
                    szTestIDs = string.Format("{0},'{1}'", szTestIDs, item.TEST_ID);
                }
            }
            List <LabResult> lstResultInfo = null;

            shRet = LabResultAccess.Instance.GetList2(szTestIDs, ref lstResultInfo);
            if (shRet != SystemData.ReturnValue.OK &&
                shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("检验记录数据下载失败!");
            }
            this.dgvLabMaster.SuspendLayout();
            for (int index = lstLabMaster.Count - 1; index >= 0; index--)
            {
                LabMaster labMaster = lstLabMaster[index];
                if (labMaster == null)
                {
                    continue;
                }
                int             nRowIndex = this.dgvLabMaster.Rows.Add();
                DataGridViewRow row       = this.dgvLabMaster.Rows[nRowIndex];
                row.Tag = labMaster;
                row.Cells[this.colSpecimen.Index].Value = labMaster.SPECIMEN;
                if (labMaster.REQUEST_TIME != labMaster.DefaultTime)
                {
                    row.Cells[this.colRequestTime.Index].Value = labMaster.REQUEST_TIME.ToString("yyyy-MM-dd");
                }
                row.Cells[this.colRequestDoctor.Index].Value = labMaster.REQUEST_DOCTOR;
                row.Cells[this.colResultStatus.Index].Value  = labMaster.RESULT_STATUS;
                if (labMaster.REPORT_TIME != labMaster.DefaultTime)
                {
                    row.Cells[this.colReportTime.Index].Value = labMaster.REPORT_TIME.ToString("yyyy-MM-dd");
                }
                row.Cells[this.colReportDoctor.Index].Value = labMaster.REPORT_DOCTOR;
                row.Cells[this.colSubject.Index].Value      = labMaster.SUBJECT;
                if (lstResultInfo != null)
                {
                    var result = lstResultInfo.Where(m => m.TEST_ID == labMaster.TEST_ID).ToList();
                    if (result == null || result.Count <= 0)
                    {
                        continue;
                    }
                    row.Cells[this.colYiChang.Index].Tag = result;
                    for (int index1 = 0; index1 < result.Count; index1++)
                    {
                        LabResult labResult = result[index1];
                        if (labResult == null)
                        {
                            continue;
                        }

                        if (labResult.ABNORMAL_INDICATOR.Trim().Contains("危机"))//危机值标红
                        {
                            row.DefaultCellStyle.ForeColor = Color.Red;
                        }
                        if (labResult.ABNORMAL_INDICATOR.Trim().Contains("高") ||
                            labResult.ABNORMAL_INDICATOR.Contains("低"))
                        {
                            row.Cells[this.colYiChang.Index].Value           = "!";
                            row.Cells[this.colYiChang.Index].Style.ForeColor = Color.Red;
                        }
                    }
                }
            }
            this.dgvLabMaster.ResumeLayout();
        }
Exemplo n.º 27
0
        /// <summary>
        /// 根据指定的申请序号,获取检验结果列表
        /// </summary>
        /// <param name="szTestID">申请序号</param>
        /// <param name="lstTestResultInfo">检验结果列表</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short GetList(string szTestID, ref List <LabResult> lstTestResultInfo)
        {
            if (szTestID == null || szTestID.Trim() == "")
            {
                LogManager.Instance.WriteLog("EMRDBAccess.GetTestResultList", "查询参数为空!");
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            if (lstTestResultInfo == null)
            {
                lstTestResultInfo = new List <LabResult>();
            }
            else
            {
                lstTestResultInfo.Clear();
            }

            string szField = string.Format("{0},{1},{2},{3},{4},{5},{6}"
                                           , SystemData.LabResultView.TEST_ID, SystemData.LabResultView.ITEM_NO
                                           , SystemData.LabResultView.ITEM_NAME, SystemData.LabResultView.ITEM_RESULT
                                           , SystemData.LabResultView.ITEM_UNITS, SystemData.LabResultView.ITEM_REFER
                                           , SystemData.LabResultView.ABNORMAL_INDICATOR);
            string szTable      = SystemData.DataView.LAB_RESULT;
            string szCondition  = string.Format("{0}='{1}'", SystemData.LabResultView.TEST_ID, szTestID);
            string szOrderField = SystemData.LabResultView.ITEM_NO;
            string szSQL        = string.Format(SystemData.SQL.SELECT_WHERE_ORDER_ASC, szField, szTable, szCondition, szOrderField);

            IDataReader dataReader = null;

            try
            {
                dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text);
                if (dataReader == null || dataReader.IsClosed || !dataReader.Read())
                {
                    return(SystemData.ReturnValue.RES_NO_FOUND);
                }
                do
                {
                    LabResult testResultInfo = new LabResult();
                    if (!dataReader.IsDBNull(0))
                    {
                        testResultInfo.TEST_ID = dataReader.GetString(0);
                    }
                    if (!dataReader.IsDBNull(1))
                    {
                        testResultInfo.ITEM_NO = int.Parse(dataReader.GetValue(1).ToString());
                    }
                    if (!dataReader.IsDBNull(2))
                    {
                        testResultInfo.ITEM_NAME = dataReader.GetString(2);
                    }
                    if (!dataReader.IsDBNull(3))
                    {
                        testResultInfo.ITEM_RESULT = dataReader.GetString(3);
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        testResultInfo.ITEM_UNITS = dataReader.GetString(4);
                    }
                    if (!dataReader.IsDBNull(5))
                    {
                        testResultInfo.ITEM_REFER = dataReader.GetString(5);
                    }
                    if (!dataReader.IsDBNull(6))
                    {
                        testResultInfo.ABNORMAL_INDICATOR = dataReader.GetString(6);
                    }
                    lstTestResultInfo.Add(testResultInfo);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("EMRDBAccess.GetTestResultList", new string[] { "szSQL" }, new object[] { szSQL }, "查询检验结果列表时出现异常!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            finally { base.MedQCAccess.CloseConnnection(false); }
        } /// <summary>
Exemplo n.º 28
0
        static void LeapYearSample()
        {
            LabResult L = new LabResult();

            L.Leapyear();
        }
Exemplo n.º 29
0
        // TODO - finish and write tests
        internal IList<LabReport> toLabsFromXmlNode(XmlNode node)
        {
            IList<LabReport> labs = new List<LabReport>();

            int total = verifyTopLevelNode(node);
            if (total == 0)
            {
                return labs;
            }

            XmlNodeList labNodes = node.SelectNodes("/lab");
            if (labNodes == null || labNodes.Count == 0)
            {
                return labs;
            }

            CCRHelper helper = new CCRHelper();
            Dictionary<string, IList<LabResult>> results = new Dictionary<string, IList<LabResult>>();

            foreach (XmlNode labNode in labNodes)
            {
                LabResult result = new LabResult();
                string specimentType = result.SpecimenType = XmlUtils.getXmlAttributeValue(labNode, "specimen", "name");
                string resultValue = result.Value = XmlUtils.getXmlAttributeValue(labNode, "result", "value");

                XmlNode commentNode = labNode.SelectSingleNode("comment");
                if (commentNode != null)
                {
                    string resultComment = result.Comment = commentNode.InnerXml;
                }

                result.Test = new LabTest();
                string testDataType = result.Test.DataType = XmlUtils.getXmlAttributeValue(labNode, "type", "value");
                string testHighRef = result.Test.HiRef = XmlUtils.getXmlAttributeValue(labNode, "high", "value");
                string testId = result.Test.Id = XmlUtils.getXmlAttributeValue(labNode, "id", "value");
                string testName = result.Test.Name = XmlUtils.getXmlAttributeValue(labNode, "test", "value");
                string testLoinc = result.Test.Loinc = XmlUtils.getXmlAttributeValue(labNode, "loinc", "value");
                string testLowRef = result.Test.LowRef = XmlUtils.getXmlAttributeValue(labNode, "low", "value");
                string testShortName = result.Test.ShortName = XmlUtils.getXmlAttributeValue(labNode, "localName", "value");
                string testUnits = result.Test.Units = XmlUtils.getXmlAttributeValue(labNode, "units", "value");

                string id = XmlUtils.getXmlAttributeValue(labNode, "id", "value");
                string accessionNumber = XmlUtils.getXmlAttributeValue(labNode, "groupName", "value");

                //helper.buildLabObject(id, accessionNumber, testDataType, specimentType,

                if (!results.ContainsKey(accessionNumber))
                {
                    results.Add(accessionNumber, new List<LabResult>());
                }
                results[accessionNumber].Add(result);
            }

            foreach (string key in results.Keys)
            {
                if (key.StartsWith("CH"))
                {
                }
                else if (key.StartsWith("HE"))
                {

                }
                else if (key.StartsWith("MI"))
                {

                }
                else if (key.StartsWith("COAG"))
                {

                }
                else if (key.StartsWith("RIA"))
                {

                }
            }
            return labs;
        }
Exemplo n.º 30
0
        ///<summary>Updates one LabResult in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(LabResult labResult, LabResult oldLabResult)
        {
            string command = "";

            if (labResult.LabPanelNum != oldLabResult.LabPanelNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LabPanelNum = " + POut.Long(labResult.LabPanelNum) + "";
            }
            if (labResult.DateTimeTest != oldLabResult.DateTimeTest)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeTest = " + POut.DateT(labResult.DateTimeTest) + "";
            }
            if (labResult.TestName != oldLabResult.TestName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TestName = '" + POut.String(labResult.TestName) + "'";
            }
            //DateTStamp can only be set by MySQL
            if (labResult.TestID != oldLabResult.TestID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TestID = '" + POut.String(labResult.TestID) + "'";
            }
            if (labResult.ObsValue != oldLabResult.ObsValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ObsValue = '" + POut.String(labResult.ObsValue) + "'";
            }
            if (labResult.ObsUnits != oldLabResult.ObsUnits)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ObsUnits = '" + POut.String(labResult.ObsUnits) + "'";
            }
            if (labResult.ObsRange != oldLabResult.ObsRange)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ObsRange = '" + POut.String(labResult.ObsRange) + "'";
            }
            if (labResult.AbnormalFlag != oldLabResult.AbnormalFlag)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "AbnormalFlag = " + POut.Int((int)labResult.AbnormalFlag) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE labresult SET " + command
                      + " WHERE LabResultNum = " + POut.Long(labResult.LabResultNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 31
0
 ///<summary>Inserts one LabResult into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(LabResult labResult)
 {
     return(InsertNoCache(labResult, false));
 }
Exemplo n.º 32
0
        internal ChemHemReport buildChemHemReport(IDataReader reader)
        {
            string patientIcn          = DbReaderUtil.getValue(reader, reader.GetOrdinal("PatientICN"));
            string testName            = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemTestName"));    // LabResult.LabTest.ShortName
            string resultValue         = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemResultValue")); // LabResult.Value
            string refHigh             = DbReaderUtil.getValue(reader, reader.GetOrdinal("RefHigh"));            // LabResult.LabTest.hiRef
            string refLow              = DbReaderUtil.getValue(reader, reader.GetOrdinal("RefLow"));             // LabResult.LabTest.lowRef
            string abnormal            = DbReaderUtil.getValue(reader, reader.GetOrdinal("Abnormal"));           // LabResult.BoundaryStatus
            string loinc               = DbReaderUtil.getValue(reader, reader.GetOrdinal("LOINC"));              // LabResult.LabTest.Loinc
            string component           = DbReaderUtil.getValue(reader, reader.GetOrdinal("Component"));          // LabResult.LabTest.Name
            string labTestType         = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabTestType"));        //LabResult.LabTest.Category
            string labChemTestSid      = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("LabChemTestSID"));
            string labChemTestIen      = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemTestIEN"));
            string labChemIen          = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemIEN")); // LabTest.Id
            string labChemSid          = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("LabChemSID"));
            string siteCode            = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
            string labChemCompleteDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("LabChemCompleteDateTime"));

            SiteId facility = new SiteId()
            {
                Id = siteCode
            };

            LabTest labTest = new LabTest()
            {
                Id        = labChemTestIen,
                Name      = testName,
                ShortName = labTestType,
                DataId    = labChemTestSid,
                HiRef     = refHigh,
                LowRef    = refLow,
                Loinc     = loinc
            };

            LabResult labResult = new LabResult()
            {
                Value          = resultValue,
                BoundaryStatus = abnormal,
                Test           = labTest
            };

            LabResult[] labResults = new LabResult[1];
            labResults[0] = labResult;

            LabSpecimen labSpecimen = new LabSpecimen()
            {
                Id             = labChemIen,
                Name           = DbReaderUtil.getValue(reader, reader.GetOrdinal("Specimen")),
                CollectionDate = labChemCompleteDate,
                Site           = siteCode
            };

            ChemHemReport report = new ChemHemReport()
            {
                Id        = labChemSid,
                Specimen  = labSpecimen,
                Facility  = facility,
                Results   = labResults,
                Timestamp = labChemCompleteDate
            };

            return(report);
        }
Exemplo n.º 33
0
        /// <summary>
        /// 把检验明细结果保存到DaTaTable中
        /// </summary>
        /// <param name="lstTestResultInfo">检查明细结果</param>
        /// <returns>DaTaTable</returns>
        private DataTable CreateResultData(List <LabResult> lstTestResultInfo)
        {
            DataTable  dt     = new DataTable();
            DataColumn column = new DataColumn("检验号");

            dt.Columns.Add(column);
            column = new DataColumn("报告医生");
            dt.Columns.Add(column);
            column = new DataColumn("申请医生");
            dt.Columns.Add(column);
            column = new DataColumn("报告时间");
            dt.Columns.Add(column);
            column = new DataColumn("申请时间");
            dt.Columns.Add(column);
            column = new DataColumn("标本名称");
            dt.Columns.Add(column);
            column = new DataColumn("主题");
            dt.Columns.Add(column);
            //表格列
            column = new DataColumn("项目");
            dt.Columns.Add(column);
            column = new DataColumn("结果");
            dt.Columns.Add(column);
            column = new DataColumn("参考值");
            dt.Columns.Add(column);
            column = new DataColumn("单位");
            dt.Columns.Add(column);
            column = new DataColumn("异常标记");
            dt.Columns.Add(column);
            for (int index = lstTestResultInfo.Count - 1; index >= 0; index--)
            {
                LabResult resultInfo = lstTestResultInfo[index];
                if (resultInfo == null)
                {
                    continue;
                }

                DataRow row = dt.NewRow();
                row["项目"] = resultInfo.ITEM_NAME;
                row["结果"] = resultInfo.ITEM_RESULT;
                row["单位"] = resultInfo.ITEM_UNITS;
                if (SystemParam.Instance.LocalConfigOption.IsLabPrintNewMethod)
                {
                    row["参考值"] = resultInfo.ITEM_REFER;
                    if (resultInfo.ABNORMAL_INDICATOR.Contains("高"))
                    {
                        row["异常标记"] = "↑";
                    }
                    if (resultInfo.ABNORMAL_INDICATOR.Contains("低"))
                    {
                        row["异常标记"] = "↓";
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(resultInfo.ABNORMAL_INDICATOR))
                    {
                        row["参考值"] = resultInfo.ITEM_REFER + resultInfo.ITEM_UNITS;
                    }
                    else
                    {
                        row["参考值"] = string.Format("{0} {1}{2}", resultInfo.ABNORMAL_INDICATOR, resultInfo.ITEM_REFER, resultInfo.ITEM_UNITS);
                    }
                }
                dt.Rows.Add(row);
            }
            return(dt);
        }
Exemplo n.º 34
0
		///<summary>Updates one LabResult in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(LabResult labResult,LabResult oldLabResult){
			string command="";
			if(labResult.LabPanelNum != oldLabResult.LabPanelNum) {
				if(command!=""){ command+=",";}
				command+="LabPanelNum = "+POut.Long(labResult.LabPanelNum)+"";
			}
			if(labResult.DateTimeTest != oldLabResult.DateTimeTest) {
				if(command!=""){ command+=",";}
				command+="DateTimeTest = "+POut.DateT(labResult.DateTimeTest)+"";
			}
			if(labResult.TestName != oldLabResult.TestName) {
				if(command!=""){ command+=",";}
				command+="TestName = '"+POut.String(labResult.TestName)+"'";
			}
			//DateTStamp can only be set by MySQL
			if(labResult.TestID != oldLabResult.TestID) {
				if(command!=""){ command+=",";}
				command+="TestID = '"+POut.String(labResult.TestID)+"'";
			}
			if(labResult.ObsValue != oldLabResult.ObsValue) {
				if(command!=""){ command+=",";}
				command+="ObsValue = '"+POut.String(labResult.ObsValue)+"'";
			}
			if(labResult.ObsUnits != oldLabResult.ObsUnits) {
				if(command!=""){ command+=",";}
				command+="ObsUnits = '"+POut.String(labResult.ObsUnits)+"'";
			}
			if(labResult.ObsRange != oldLabResult.ObsRange) {
				if(command!=""){ command+=",";}
				command+="ObsRange = '"+POut.String(labResult.ObsRange)+"'";
			}
			if(labResult.AbnormalFlag != oldLabResult.AbnormalFlag) {
				if(command!=""){ command+=",";}
				command+="AbnormalFlag = "+POut.Int   ((int)labResult.AbnormalFlag)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE labresult SET "+command
				+" WHERE LabResultNum = "+POut.Long(labResult.LabResultNum);
			Db.NonQ(command);
		}
Exemplo n.º 35
0
        internal ChemHemReport toChemHemReport(string response, ref string nextDate)
        {
            if (String.IsNullOrEmpty(response))
            {
                return null;
            }

            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);
            string[] flds = StringUtils.split(lines[0], StringUtils.CARET);
            nextDate = flds[2];
            if (flds[1] != "CH")
            {
                return null;
            }
            if (lines.Length == 1)
            {
                return null;
            }
            int ntests = Convert.ToInt16(flds[0]);
            ChemHemReport rpt = new ChemHemReport();
            rpt.Id = flds[2] + '^' + flds[5];
            rpt.Timestamp = flds[2];
            rpt.Specimen = new LabSpecimen();
            rpt.Specimen.CollectionDate = VistaTimestamp.toUtcString(flds[2]);
            rpt.Specimen.Name = flds[4];
            rpt.Specimen.AccessionNumber = flds[5];
            rpt.Author = new Author();
            rpt.Author.Name = flds[6];

            int lineIdx = 1;
            for (lineIdx = 1; lineIdx <= ntests; lineIdx++)
            {
                LabResult lr = new LabResult();
                flds = StringUtils.split(lines[lineIdx], StringUtils.CARET);
                if (flds.Length < 6)
                {
                    continue;
                }
                lr.Test = new LabTest();

                lr.Test.Id = flds[0];
                lr.Test.Name = flds[1];
                lr.Value = flds[2].Trim();
                lr.BoundaryStatus = flds[3];
                lr.Test.Units = flds[4].Trim();
                lr.Test.RefRange = flds[5];

                // MHV patch - probably no one needs this
                lr.LabSiteId = cxn.DataSource.SiteId.Id;

                rpt.AddResult(lr);
            }

            rpt.Comment = "";
            while (lineIdx < lines.Length)
            {
                rpt.Comment += lines[lineIdx++].TrimStart() + "\r\n";
            }

            return rpt;
        }
Exemplo n.º 36
0
        internal ChemHemReport[] toChemHemReports(string response)
        {
            if (response == "")
            {
                return null;
            }
            DictionaryHashList lst = new DictionaryHashList();
            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            lines = StringUtils.trimArray(lines);

            ChemHemReport rpt = null;
            LabResult rslt = null;
            string ts = "";
            string facilityTag = "";
            string facilityName = "";
            for (int i = 0; i < lines.Length; i++)
            {
                string[] flds = StringUtils.split(lines[i], StringUtils.CARET);
                if (!StringUtils.isNumeric(flds[0]))
                {
                    throw new DataMisalignedException("Invalid fldnum: " + flds[0] + " in lines[" + i + "]");
                }
                int fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                    case 1:
                        string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                        if (parts.Length == 2)
                        {
                            facilityTag = parts[1];
                            facilityName = parts[0];
                        }
                        else if (flds[1] != "")
                        {
                            facilityTag = cxn.DataSource.SiteId.Id;
                            facilityName = flds[1];
                        }
                        else
                        {
                            facilityTag = cxn.DataSource.SiteId.Id;
                            facilityName = cxn.DataSource.SiteId.Name;
                        }
                        break;
                    case 2:
                        if (rpt != null)
                        {
                            if (StringUtils.isEmpty(rslt.Test.RefRange))
                            {
                                if (!StringUtils.isEmpty(rslt.Test.LowRef) &&
                                    !StringUtils.isEmpty(rslt.Test.HiRef))
                                {
                                    rslt.Test.RefRange = rslt.Test.LowRef + " - " + rslt.Test.HiRef;
                                }
                            }
                            rpt.AddResult(rslt);
                        }
                        rslt = new LabResult();
                        rslt.Test = new LabTest();
                        ts = VistaTimestamp.toUtcFromRdv(flds[1]);
                        if (lst[ts] == null)
                        {
                            rpt = new ChemHemReport();
                            rpt.Facility = new SiteId(facilityTag, facilityName);
                            rpt.Timestamp = ts;
                            lst.Add(ts, rpt);
                        }
                        break;
                    case 3:
                        if (flds.Length == 2)
                        {
                            rslt.Test.Name = flds[1];
                        }
                        break;
                    case 4:
                        if (flds.Length == 2)
                        {
                            if (null != rslt)
                                rslt.SpecimenType = flds[1];
                        }
                        break;
                    case 5:
                        if (flds.Length == 2)
                        {
                            rslt.Value = flds[1];
                        }
                        break;
                    case 6:
                        if (flds.Length == 2)
                        {
                            rslt.BoundaryStatus = flds[1];
                        }
                        break;
                    case 7:
                        if (flds.Length == 2)
                        {
                            rslt.Test.Units = flds[1];
                        }
                        break;
                    case 8:
                        if (flds.Length == 2)
                        {
                            rslt.Test.LowRef = flds[1];
                        }
                        break;
                    case 9:
                        if (flds.Length == 2)
                        {
                            rslt.Test.HiRef = flds[1];
                        }
                        break;
                    case 10:
                        if (flds.Length == 2)
                        {
                            rslt.Comment += flds[1] + '\n';
                        }
                        break;
                }
            }

            if (rpt != null)
            {
                if (StringUtils.isEmpty(rslt.Test.RefRange))
                {
                    if (!StringUtils.isEmpty(rslt.Test.LowRef) &&
                        !StringUtils.isEmpty(rslt.Test.HiRef))
                    {
                        rslt.Test.RefRange = rslt.Test.LowRef + " - " + rslt.Test.HiRef;
                    }
                }
                rpt.AddResult(rslt);
            }

            ChemHemReport[] result = new ChemHemReport[lst.Count];
            for (int i = 0; i < lst.Count; i++)
            {
                DictionaryEntry de = lst[i];
                result[i] = (ChemHemReport)de.Value;
            }
            return result;
        }
Exemplo n.º 37
0
		///<summary>Converts one LabResult object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
		internal static LabResultm ConvertToM(LabResult labResult){
			LabResultm labResultm=new LabResultm();
			//CustomerNum cannot be set.  Remains 0.
			labResultm.LabResultNum=labResult.LabResultNum;
			labResultm.LabPanelNum =labResult.LabPanelNum;
			labResultm.DateTimeTest=labResult.DateTimeTest;
			labResultm.TestName    =labResult.TestName;
			labResultm.TestID      =labResult.TestID;
			labResultm.ObsValue    =labResult.ObsValue;
			labResultm.ObsUnits    =labResult.ObsUnits;
			labResultm.ObsRange    =labResult.ObsRange;
			labResultm.AbnormalFlag=labResult.AbnormalFlag;
			return labResultm;
		}
Exemplo n.º 38
0
        // it appears we're missing local IEN that maps to LabReport.Id
        LabResult readLab(XmlReader reader, ref ChemHemReport rpt)
        {
            LabResult result = new LabResult();
            result.Test = new LabTest();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement && String.Equals(reader.Name, "lab", StringComparison.CurrentCultureIgnoreCase))
                {
                    break;
                }
                switch (reader.Name)
                {
                    case "collected":
                        if (reader.HasAttributes)
                        {
                            rpt.Specimen.CollectionDate = reader.GetAttribute("value");
                        }
                        break;
                    case "comment":
                        result.Comment = reader.GetAttribute("value");
                        break;
                    case "facility":
                        if (reader.HasAttributes)
                        {
                            rpt.Facility = new SiteId(reader.GetAttribute("code"), reader.GetAttribute("name"));
                        }
                        break;
                    case "groupName":
                        if (reader.HasAttributes)
                        {
                            rpt.Specimen.AccessionNumber = reader.GetAttribute("value");
                        }
                        break;
                    case "high":
                        result.Test.HiRef = reader.GetAttribute("value");
                        break;
                    case "id":
                        if (reader.HasAttributes)
                        {
                            rpt.Id = reader.GetAttribute("value"); // not the same as old ChemHemRpts ID!!!
                        }
                        break;
                    case "interpretation":
                        break;
                    case "labOrderID":
                        break;
                    case "localName":
                        result.Test.ShortName = reader.GetAttribute("value");
                        break;
                    case "loinc":
                        result.Test.Loinc = reader.GetAttribute("value");
                        break;
                    case "low":
                        result.Test.LowRef = reader.GetAttribute("value");
                        break;
                    case "orderID":
                        break;
                    case "result":
                        result.Value = reader.GetAttribute("value");
                        break;
                    case "resulted":
                        if (reader.HasAttributes)
                        {
                            rpt.Timestamp = reader.GetAttribute("value");
                        }
                        break;
                    case "specimen":
                        rpt.Specimen.Name = reader.GetAttribute("name");
                        break;
                    case "status":
                        // place to put this?
                        break;
                    case "test":
                        result.Test.Name = reader.GetAttribute("value");
                        break;
                    case "type":
                        // place to put this??
                        break;
                    case "units":
                        result.Test.Units = reader.GetAttribute("value");
                        break;
                    case "vuid":
                        // TBD - where to put this?
                        break;
                }
            }
            return result;
        }
Exemplo n.º 39
0
        public String insert(LabResult p, String userId)
        {
            String re  = "";
            String sql = "";

            //DataTable dt = new DataTable();
            p.active = "1";
            //p.ssdata_id = "";
            int chk = 0;

            chkNull(p);
            sql = "Insert Into " + lbRes.table + " set " +
                  "" + lbRes.lis_id + "= '" + p.lis_id + "'" +
                  "," + lbRes.active + "= '" + p.active + "'" +
                  "," + lbRes.req_id + "= '" + p.req_id + "'" +
                  "," + lbRes.visit_id + "= '" + p.visit_id + "'" +
                  "," + lbRes.patient_id + "= '" + p.patient_id + "'" +
                  "," + lbRes.lab_id + "= '" + p.lab_id + "'" +
                  "," + lbRes.result + "= '" + p.result + "'" +
                  "," + lbRes.method + "= '" + p.method + "'" +
                  "," + lbRes.remark + "= '" + p.remark + "'" +
                  "," + lbRes.date_create + "= now()" +
                  "," + lbRes.date_modi + "= ''" +
                  "," + lbRes.date_cancel + "= ''" +
                  "," + lbRes.user_create + "= '" + userId + "@" + conn._IPAddress + "'" +
                  "," + lbRes.user_modi + "= ''" +
                  "," + lbRes.user_cancel + "= ''" +
                  "," + lbRes.unit + "= '" + p.unit + "'" +
                  "," + lbRes.sort1 + "= '" + p.sort1 + "'" +
                  "," + lbRes.staff_id_result + "= '" + p.staff_id_result + "'" +
                  "," + lbRes.staff_id_approve + "= '" + p.staff_id_approve + "'" +
                  "," + lbRes.date_time_result + "= '" + p.date_time_result + "'" +
                  "," + lbRes.date_time_approve + " " + "= '" + p.date_time_approve + "'" +
                  "," + lbRes.normal_value + " " + "= '" + p.normal_value + "'" +
                  "," + lbRes.interpret + " " + "= '" + p.interpret + "'" +
                  "," + lbRes.status_result + " " + "= '" + p.status_result + "'" +
                  "," + lbRes.row1 + " " + "= '" + p.row1 + "'" +
                  "," + lbRes.lot_input + " " + "= '" + p.lot_input + "'" +
                  "," + lbRes.req_date_time + " " + "= '" + p.req_date_time + "'" +
                  "," + lbRes.date_time_receive + " " + "= '" + p.date_time_receive + "'" +
                  //"," + lbRes.date_time_receive + " " + "= now()" +
                  "," + lbRes.reactive_message + " " + "= '" + p.reactive_message + "'" +
                  "," + lbRes.doctor_id + " " + "= '" + p.doctor_id + "'" +
                  "," + lbRes.date_time_collect + " " + "= '" + p.date_time_collect + "'" +
                  "," + lbRes.remark_nurse + " " + "= '" + p.remark_nurse + "'" +
                  "";
            try
            {
                //    conn.comStore = new System.Data.SqlClient.SqlCommand();
                //    conn.comStore.Connection = conn.conn;
                //    conn.comStore.CommandText = "insert_doc_scan";
                //    conn.comStore.CommandType = CommandType.StoredProcedure;
                //    conn.comStore.Parameters.AddWithValue("lis_id", p.lis_id);
                //    conn.comStore.Parameters.AddWithValue("visit_id", p.visit_id);
                //    conn.comStore.Parameters.AddWithValue("lab_id", p.lab_id);
                //    conn.comStore.Parameters.AddWithValue("result", p.result);
                //    conn.comStore.Parameters.AddWithValue("remark", p.remark);
                //    conn.comStore.Parameters.AddWithValue("user_create", userId);
                //    conn.comStore.Parameters.AddWithValue("unit", p.unit);
                //    conn.comStore.Parameters.AddWithValue("sort1", p.sort1);
                //    conn.comStore.Parameters.AddWithValue("staff_id_result", p.staff_id_result);
                //    conn.comStore.Parameters.AddWithValue("staff_id_approve", p.staff_id_approve);
                //    conn.comStore.Parameters.AddWithValue("date_time_result", p.date_time_result);
                //    conn.comStore.Parameters.AddWithValue("ext", p.patient_id);
                //    conn.comStore.Parameters.AddWithValue("method", p.method);
                //    SqlParameter retval =  conn.comStore.Parameters.Add("row_no1", SqlDbType.VarChar, 50);
                //    retval.Value = "";
                //    retval.Direction = ParameterDirection.Output;

                re = conn.ExecuteNonQuery(conn.conn, sql);
                //conn.Open();
                //    conn.comStore.ExecuteNonQuery();
                //    re = (String)conn.comStore.Parameters["row_no1"].Value;
                //    //string retunvalue = (string)sqlcomm.Parameters["@b"].Value;
            }
            catch (Exception ex)
            {
                sql = ex.Message + " " + ex.InnerException;
            }
            finally
            {
                conn.conn.Close();
                //conn.comStore.Dispose();
            }
            return(re);
        }
Exemplo n.º 40
0
        void OrderRow_Finalized(object sender, OrdersView.FinalizedEventArgs e)
        {
            //Finalize has been clicked
            if (order.Order_finalized == 0)
            {
                order.Order_finalized = 1;
                Patient proband = SessionManager.Instance.GetActivePatient();
                HraModelChangedEventArgs args = new HraModelChangedEventArgs(this.owningView);

                int panelID = SessionManager.Instance.MetaData.GeneticTests.GetPanelIDFromName(order.Order_orderDesc);
                if (panelID > 0)  // a genetic test has been ordered
                {
                    //add the pending gen test to the model
                    PastMedicalHistory pmh = proband.PMH;


                    //GeneticTest geneticTest = (GeneticTest)(pmh.GeneticTests.SingleOrDefault(v => ((GeneticTest)v).panelID == panelID && ((GeneticTest)v).status == "Pending"
                    //    && ((GeneticTest)v).GeneticTest_testYear == (order.Order_orderDate.Year).ToString()
                    //    && ((GeneticTest)v).GeneticTest_testMonth == (order.Order_orderDate.Month).ToString()
                    //    && ((GeneticTest)v).GeneticTest_testDay == (order.Order_orderDate.Day).ToString()));
                    //if (geneticTest == null)
                    //{

                    //duplicate pending tests are allowed, so ignore commented check above
                    //also, no difference between all "Familial Known Genetic Test"s, regardless of group
                    GeneticTest geneticTest = new GeneticTest(pmh);
                    geneticTest.GeneticTest_status    = "Pending";
                    geneticTest.GeneticTest_panelID   = panelID;
                    geneticTest.GeneticTest_testYear  = (order.Order_orderDate.Year).ToString();
                    geneticTest.GeneticTest_testMonth = (order.Order_orderDate.Month).ToString();
                    geneticTest.GeneticTest_testDay   = (order.Order_orderDate.Day).ToString();

                    pmh.GeneticTests.AddToList(geneticTest, args);
                    //}
                    //else
                    //{
                    //    geneticTest.SignalModelChanged(args);
                    //}
                }

                else if (order.Order_orderDesc.Contains("mammo"))
                {
                    BreastImagingStudy bis = new BreastImagingStudy();
                    bis.unitnum     = proband.unitnum;
                    bis.type        = "MammographyHxView";
                    bis.date        = DateTime.Today;
                    bis.imagingType = "MammographyHxView";
                    bis.status      = "Ordered";
                    proband.breastImagingHx.AddToList(bis, args);
                }
                else if (order.Order_orderDesc.Contains("MRI"))
                {
                    BreastImagingStudy bis = new BreastImagingStudy();
                    bis.unitnum     = proband.unitnum;
                    bis.type        = "MRI";
                    bis.date        = DateTime.Today;
                    bis.imagingType = "MRI";
                    bis.status      = "Ordered";
                    bis.side        = "Bilateral";
                    proband.breastImagingHx.AddToList(bis, args);
                }
                else if (order.Order_orderDesc.Contains("Transvaginal Sonography"))
                {
                    TransvaginalImagingStudy tvs = new TransvaginalImagingStudy();
                    tvs.unitnum     = proband.unitnum;
                    tvs.type        = "TVS";
                    tvs.date        = DateTime.Today;
                    tvs.imagingType = "TVS";
                    tvs.status      = "Ordered";
                    proband.transvaginalImagingHx.AddToList(tvs, args);
                }
                else if (order.Order_orderDesc.Contains("CA-125"))
                {
                    LabResult lr = new LabResult();
                    lr.unitnum  = proband.unitnum;
                    lr.date     = DateTime.Today;
                    lr.TestDesc = "CA125";
                    lr.status   = "Ordered";
                    proband.labsHx.AddToList(lr, args);
                }
            }
        }