Exemplo n.º 1
0
        public void UpdateDrugSeal(string userId, bool COCA, bool BARB, bool LSD, bool METH, bool MTQL, bool PCP, bool KET, bool BUPRE, bool CAT, bool PPZ, bool NPS, string updatedBy)
        {
            string     NRIC      = new DAL_User().GetUserByUserId(userId).Data.NRIC;
            var        localRepo = _localUnitOfWork.GetRepository <DrugResult>();
            DateTime   today     = DateTime.Today;
            DrugResult drug      = _localUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC) && DbFunctions.TruncateTime(d.UploadedDate) == today);

            if (drug != null)
            {
                drug.COCA                  = COCA;
                drug.BARB                  = BARB;
                drug.LSD                   = LSD;
                drug.METH                  = METH;
                drug.MTQL                  = MTQL;
                drug.PCP                   = PCP;
                drug.KET                   = KET;
                drug.BUPRE                 = BUPRE;
                drug.CAT                   = CAT;
                drug.PPZ                   = PPZ;
                drug.NPS                   = NPS;
                drug.IsSealed              = true;
                drug.SealedOrDiscardedBy   = updatedBy;
                drug.SealedOrDiscardedDate = DateTime.Now;
                localRepo.Update(drug);
                _localUnitOfWork.Save();
            }
        }
Exemplo n.º 2
0
        public string GetResultUTByNRIC(string NRIC, DateTime date)
        {
            date = date.Date;
            DrugResult drug = _localUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC) && DbFunctions.TruncateTime(d.UploadedDate) == date);

            if (drug == null)
            {
                return(string.Empty);
            }
            else
            {
                if (
                    (drug.AMPH.HasValue && drug.AMPH.Value) ||
                    (drug.BENZ.HasValue && drug.BENZ.Value) ||
                    (drug.OPI.HasValue && drug.OPI.Value) ||
                    (drug.THC.HasValue && drug.THC.Value)
                    )
                {
                    return(EnumUTResult.POS);
                }
                else
                {
                    return(EnumUTResult.NEG);
                }
            }

            //if (EnumAppConfig.IsLocal)
            //{

            //}
            //else
            //{
            //    DrugResult drug = _centralizedUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC));
            //    if (drug == null)
            //        return EnumUTResult.NEG;
            //    else
            //    {
            //        if (drug.AMPH.Value || drug.BARB.Value || drug.BENZ.Value || drug.BUPRE.Value || drug.CAT.Value || drug.COCA.Value || drug.KET.Value || drug.LSD.Value
            //            || drug.METH.Value || drug.MTQL.Value || drug.NPS.Value || drug.OPI.Value || drug.PCP.Value || drug.PPZ.Value || drug.THC.Value)
            //        {
            //            return EnumUTResult.POS;
            //        }
            //        else
            //        {
            //            return EnumUTResult.NEG;
            //        }
            //    }
            //}
        }
Exemplo n.º 3
0
        public string GetDrugTypeByNRIC(string NRIC)
        {
            if (EnumAppConfig.IsLocal)
            {
                System.Text.StringBuilder result = new System.Text.StringBuilder();
                DrugResult drug = _localUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC));
                if (drug == null)
                {
                    result.Append("NA-");
                }
                else
                {
                    if (drug.AMPH == true)
                    {
                        result.Append("AMPH-");
                    }
                    if (drug.BENZ == true)
                    {
                        result.Append("BENZ-");
                    }
                    if (drug.OPI == true)
                    {
                        result.Append("OPI-");
                    }
                    if (drug.THC == true)
                    {
                        result.Append("THC-");
                    }
                    if (drug.COCA == true)
                    {
                        result.Append("COCA-");
                    }
                    if (drug.BARB == true)
                    {
                        result.Append("BARB-");
                    }
                    if (drug.LSD == true)
                    {
                        result.Append("LSD-");
                    }
                    if (drug.METH == true)
                    {
                        result.Append("METH-");
                    }
                    if (drug.MTQL == true)
                    {
                        result.Append("MTQL-");
                    }
                    if (drug.PCP == true)
                    {
                        result.Append("PCP-");
                    }
                    if (drug.KET == true)
                    {
                        result.Append("KET-");
                    }
                    if (drug.BUPRE == true)
                    {
                        result.Append("BUPRE-");
                    }
                    if (drug.CAT == true)
                    {
                        result.Append("CAT-");
                    }
                    if (drug.PPZ == true)
                    {
                        result.Append("PPZ-");
                    }
                    if (drug.NPS == true)
                    {
                        result.Append("NPS-");
                    }
                    if (string.IsNullOrEmpty(result.ToString()))
                    {
                        result.Append("NA-");
                    }
                }

                return(result.ToString().Remove(result.ToString().Length - 1));
            }
            else
            {
                System.Text.StringBuilder result = new System.Text.StringBuilder();
                DrugResult drug = _centralizedUnitOfWork.DataContext.DrugResults.FirstOrDefault(d => d.NRIC.Equals(NRIC));
                if (drug == null)
                {
                    result.Append("NA-");
                }
                else
                {
                    if (drug.AMPH == true)
                    {
                        result.Append("AMPH-");
                    }
                    if (drug.BENZ == true)
                    {
                        result.Append("BENZ-");
                    }
                    if (drug.OPI == true)
                    {
                        result.Append("OPI-");
                    }
                    if (drug.THC == true)
                    {
                        result.Append("THC-");
                    }
                    if (drug.COCA == true)
                    {
                        result.Append("COCA-");
                    }
                    if (drug.BARB == true)
                    {
                        result.Append("BARB-");
                    }
                    if (drug.LSD == true)
                    {
                        result.Append("LSD-");
                    }
                    if (drug.METH == true)
                    {
                        result.Append("METH-");
                    }
                    if (drug.MTQL == true)
                    {
                        result.Append("MTQL-");
                    }
                    if (drug.PCP == true)
                    {
                        result.Append("PCP-");
                    }
                    if (drug.KET == true)
                    {
                        result.Append("KET-");
                    }
                    if (drug.BUPRE == true)
                    {
                        result.Append("BUPRE-");
                    }
                    if (drug.CAT == true)
                    {
                        result.Append("CAT-");
                    }
                    if (drug.PPZ == true)
                    {
                        result.Append("PPZ-");
                    }
                    if (drug.NPS == true)
                    {
                        result.Append("NPS-");
                    }
                    if (string.IsNullOrEmpty(result.ToString()))
                    {
                        result.Append("NA-");
                    }
                }

                return(result.ToString().Remove(result.ToString().Length - 1));
            }
        }
Exemplo n.º 4
0
        public UpdateDriverResults GetDriver(int id)
        {
            var thisID = id;

            using RDATContext context = new RDATContext();
            UpdateDriverResults _driverResults = new UpdateDriverResults();

            Driver _driver  = context.Drivers.Where(c => c.Id == id).FirstOrDefault();
            int    _batchId = context.Batches.OrderByDescending(b => b.Id).FirstOrDefault().Id;

            // Get TestingLog
            // TODO: Create List of Alcohol Dates - There can be multiples
            List <TestingLog> _logDrug = context.TestingLogs.Where(l => l.Driver_Id == id && l.Test_Type == "Drug" && l.ResultsDate == null).ToList();

            // TODO: Create List of Alcohol Dates - There can be multiples
            List <TestingLog> _logAlcohol = context.TestingLogs.Where(l => l.Driver_Id == id && l.Test_Type == "Alcohol" && l.ResultsDate == null).ToList();

            // Set Values
            _driverResults.Driver_Id       = _driver.Id;
            _driverResults.Driver_Name     = _driver.DriverName;
            _driverResults.Company_Name    = context.Companys.Where(c => c.Id == _driver.Company_id).FirstOrDefault().Name;
            _driverResults.Driver_UniqueID = _driver.UniqueId.ToString();

            // Do we have results
            _driverResults.Alcohol_Show = _logAlcohol.Count > 0 ? true : false;
            _driverResults.Drug_Show    = _logDrug.Count > 0 ? true : false;

            // Alcohol Test
            if (_logAlcohol.Count > 0)
            {
                List <AlcoholResult> results = new List <AlcoholResult>();
                foreach (TestingLog tl in _logAlcohol)
                {
                    AlcoholResult alcoholResult = new AlcoholResult();
                    alcoholResult.Alcohol_TestingLogID    = tl.Id;
                    alcoholResult.Alcohol_Test_Date       = tl.TestDate;
                    alcoholResult.Alcohol_Specimen_Id     = tl.Specimen_Id;
                    alcoholResult.Alcohol_Results_Date    = tl.ResultsDate;
                    alcoholResult.Alcohol_Reported_Result = tl.Reported_Results;
                    alcoholResult.BatchID = tl.Batch_Id;
                    results.Add(alcoholResult);
                }

                _driverResults.AlcoholResults = results;
            }

            // Drug Test
            if (_logDrug.Count > 0)
            {
                List <DrugResult> dresults = new List <DrugResult>();
                foreach (TestingLog tl in _logDrug)
                {
                    DrugResult drugResult = new DrugResult();
                    drugResult.Drug_TestingLogID    = tl.Id;
                    drugResult.Drug_Test_Date       = tl.TestDate;
                    drugResult.Drug_Specimen_Id     = tl.Specimen_Id;
                    drugResult.Drug_Results_Date    = tl.ResultsDate;
                    drugResult.Drug_Reported_Result = tl.Reported_Results;
                    drugResult.BatchID = tl.Batch_Id;
                    dresults.Add(drugResult);
                }

                _driverResults.DrugResults = dresults;
            }

            return(_driverResults);
        }