Exemplo n.º 1
0
        public static IList<Link> FindByDrug(Drug d, Question q)
        {
            if (d == null || d.ID == null || q == null || q.ID == null)
                return null;

            return FindByDrug(d.ID.Value, q.ID.Value);
        }
Exemplo n.º 2
0
        public static Answer FindByDrug(Drug d, Question q)
        {
            if (d == null || !d.ID.HasValue || q == null || !q.ID.HasValue)
                return null;

            return FindByDrug(d.ID.Value, q.ID.Value);
        }
Exemplo n.º 3
0
        public TakingPlanPage()
        {
            this.InitializeComponent();

            /// Add todays date (with the days name) to the view
            /// author: Florian Schnyder
            TodaysDate.Text = DateTime.Now.ToString("dddd, dd.MM.yyy");

            ///For binding tests!!!! generates drug lists object and add an item
            List<Drug> morning = new List<Drug>();
            List<Drug> noon = new List<Drug>();
            List<Drug> evening = new List<Drug>();
            List<Drug> night = new List<Drug>();
            
            
            Drug morgen = new Drug(2, " Dafalgan", 2, "Paracetamol ", "Tablette", null);
            morning.Add(morgen);

         /*   Drug mittag = new Drug(2, "Dafalgan", 2, "Paracetamol ", "Tablette", null);
            noon.Add(mittag);*/

            Drug abend = new Drug(2, "Dafalgan", 2, "Paracetamol ", "Tablette", null);
            evening.Add(abend);

         /* Drug nacht = new Drug(2, "Medi für Nacht", 2, "Gärste", "Tablette", null);
            night.Add(nacht);*/

            /// Add the lists to the TakingPlanModel constructor and bind it with the DataContext
            this.DataContext = new TakingPlanModel(morning, noon, evening, night);
                     
        }
        public void PrescriptionHasEnded_True()
        {
            DateTime expiry = new DateTime(2012, 1, 1, 0, 0, 0);
            IClock clock = Clock.Instance;
            Drug drug = new Drug("Ibuprophen");
            Prescription prescription = new Prescription(expiry, clock, drug);

            Assert.That(prescription.HasExpired, Is.True);
        }
        public void PrescriptionHasEnded_True_Exact_Time_FakeClock()
        {
            DateTime expiry = new DateTime(2012, 1, 1, 0, 0, 0);
            FakeClock clock = new FakeClock(expiry);
            Drug drug = new Drug("Ibuprophen");

            Prescription prescription = new Prescription(expiry, clock, drug);

            Assert.That(prescription.HasExpired, Is.True);
        }
        public void PrescriptionHasEnded_False_FakeClock()
        {
            DateTime expiry = new DateTime(2012, 1, 1, 0, 0, 0);
            FakeClock clock = new FakeClock(expiry.AddTicks(-1));
            Drug drug = new Drug("Ibuprophen");

            Prescription prescription = new Prescription(expiry, clock, drug);

            Assert.That(prescription.HasExpired, Is.False);
        }
Exemplo n.º 7
0
        public void DecreaseStockCount_By_One_Stock_Is_Empty()
        {
            // Arrange
            Drug drug = new Drug("Ibuprophen");
            Fakes.FakeStockProvider stockProvider = new Fakes.FakeStockProvider(0);

            Stock stock = new Stock(stockProvider);

            // Act
            stock.DecreaseStock(drug, 1);
        }
Exemplo n.º 8
0
        public void DecreaseStockCount_By_Five_Stock_Is_Too_Low()
        {
            // Arrange
            Drug drug = new Drug("Ibuprophen");
            Fakes.FakeStockProvider stockProvider = new Fakes.FakeStockProvider(4);

            Stock stock = new Stock(stockProvider);

            // Act
            stock.DecreaseStock(drug, 5);
        }
        public void ExtendPrescription_Date_Before_Original_Expiry_Invalid()
        {
            DateTime expiry = new DateTime(2012, 1, 1, 0, 0, 0);
            FakeClock clock = new FakeClock(expiry.AddTicks(1));
            Drug drug = new Drug("Ibuprophen");

            Prescription prescription = new Prescription(expiry, clock, drug);

            Assert.That(prescription.HasExpired, Is.True);

            DateTime newExpiry = new DateTime(2011, 1, 2, 0, 0, 0);
            prescription.ExtendPrescription(newExpiry);
        }
Exemplo n.º 10
0
        public void IsDrugInStock_True()
        {
            // Arrange
            Drug drug = new Drug("Ibuprophen");
            Fakes.FakeStockProvider stockProvider = new Fakes.FakeStockProvider(1);

            Stock stock = new Stock(stockProvider);

            // Act
            bool isDrugInStock = stock.IsDrugInStock(drug);

            // Assert
            Assert.That(isDrugInStock, Is.True);
        }
Exemplo n.º 11
0
        public void DecreaseStockCount_By_One_Stock_Is_Not_Empty()
        {
            // Arrange
            Drug drug = new Drug("Ibuprophen");
            Fakes.FakeStockProvider stockProvider = new Fakes.FakeStockProvider(10);

            Stock stock = new Stock(stockProvider);

            Assert.That(stock.StockCount(drug), Is.EqualTo(10));

            // Act
            stock.DecreaseStock(drug, 1);

            // Assert
            Assert.That(stock.StockCount(drug), Is.EqualTo(9));
        }
Exemplo n.º 12
0
        public CheckingDrug()
        {
            InitializeComponent();

            List <Drug> drugs = dc.ViewUnconfirmedDrugs();

            drug         = drugs[0];
            newDrug.Text = drugs[0].Name;
            List <Ingredient> ingredients = drugs[0].ingredient;
            List <string>     names       = new List <string>();

            foreach (Ingredient i in ingredients)
            {
                names.Add(i.Name);
            }
            listBox1.DataContext = names;
        }
Exemplo n.º 13
0
        public ActionResult Create(Drug  obj)
        {
            try
            {

                if (ModelState.IsValid)
                {
                    int id = db.AddDrug(obj);
                    return RedirectToAction("Index");
                }
            }
            catch (DataException ex)
            {
                ModelState.AddModelError("", ex.Message.ToString() + " Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору.");
            }
            return RedirectToAction("Index");
        }
Exemplo n.º 14
0
        public async Task <bool> AddDrugAsync(Drug drug)
        {
            if (drug == null)
            {
                return(false);
            }
            var drugs = new Drug {
                Id        = $"HYGD - {new Random().Next(1111111,9999999)}",
                Name      = drug.Name,
                Price     = drug.Price,
                Quantity  = drug.Quantity,
                DateAdded = DateTime.Now.ToString()
            };
            await dataContext.Drugs.AddAsync(drugs);

            return(await dataContext.SaveChangesAsync() == 1);
        }
Exemplo n.º 15
0
        public ActionResult Edit(Drug drug)
        {
            var product = DrugServices.Instance.GetDrug(drug.Id);

            product.Name                = drug.Name;
            product.DespensaryAmount    = drug.DespensaryAmount;
            product.StoreHouseAmount    = drug.StoreHouseAmount;
            product.StudentSeriveAmount = drug.StudentSeriveAmount;
            product.StafftSeriveAmount  = drug.StafftSeriveAmount;
            product.PricePerTab         = drug.PricePerTab;
            product.Description         = drug.Description;
            product.ProductionDate      = drug.ProductionDate;
            product.ExpireDate          = drug.ExpireDate;

            DrugServices.Instance.UpdateDrug(product);
            return(RedirectToAction("DrugTable"));
        }
Exemplo n.º 16
0
        private void DataGrid3_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cell = DataGrid4.SelectedIndex;

            drugSelCell = (int)cell;

            if (DataGrid3.SelectedItem != null)
            {
                var    cellC = DataGrid3.Columns[2].GetCellContent(DataGrid3.SelectedItem);
                var    row   = cellC.Parent;
                string s     = row.ToString();

                string[] lines = s.Split(':');
                txtDrug.Text = lines[1];

                var      cellC1 = DataGrid3.Columns[1].GetCellContent(DataGrid3.SelectedItem);
                var      row1   = cellC1.Parent;
                string   s1     = row1.ToString();
                string[] lines1 = s1.Split(':');
                string   d      = lines1[1];
                idDrug = Int32.Parse(d);

                List <Drug> drugs1 = dcon.ViewConfirmedDrugs();
                Drug        drug   = new Drug();
                foreach (Drug dd in drugs1)
                {
                    if (dd.Id == idDrug)
                    {
                        drug = dd;
                        break;
                    }
                }
                drugSelected = drug;


                var      cellC2 = DataGrid3.Columns[3].GetCellContent(DataGrid3.SelectedItem);
                var      row2   = cellC2.Parent;
                string   s2     = row2.ToString();
                string[] lines2 = s2.Split(':');
                string   d2     = lines2[1];
                drugQuantity = Int32.Parse(d2);

                txtbox3.Text = drugSelected.Name;
            }
        }
Exemplo n.º 17
0
        private async Task <Drug> GetDrugInfo(string drudName)
        {
            Thread.Sleep(200);
            Drug ret    = new Drug();
            var  drugId = await GetDrugId(drudName);

            if (drugId == null)
            {
                return(null);
            }
            ret.Id   = drugId.Value.id;
            ret.Name = drugId.Value.name;
            //Костыль чтоб билинг не зарубил запрос
            Thread.Sleep(200);

            ret.ActiveIngridients = await GetActiveIngredients(ret.Id);

            if (ret.ActiveIngridients == null)
            {
                return(ret);
            }
            ret.AnatomicalTherapeuticChemicalClassification = new Dictionary <uint, string>();
            //По плану тут был Parallel.Foreach, однако биллинговая система не позволила мне этого сделать =(
            foreach (var x in ret.ActiveIngridients)
            {
                //Костыль чтоб билинг не зарубил запрос
                Thread.Sleep(200);
                var atcc = await GetAnatomicalTherapeuticChemicalClassification(x.Key);

                if (atcc != null)
                {
                    lock (ret.AnatomicalTherapeuticChemicalClassification)
                    {
                        foreach (var record in atcc)
                        {
                            if (!ret.AnatomicalTherapeuticChemicalClassification.ContainsKey(record.Key))
                            {
                                ret.AnatomicalTherapeuticChemicalClassification.Add(record.Key, record.Value);
                            }
                        }
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 18
0
        public ReciepForm(Directory directory, Doctor doctor, Illness ill)
        {
            InitializeComponent();

            this.directory = directory;
            this.doctor    = doctor;
            this.ill       = ill;
            string symp = ill.Symptoms[0];

            for (int i = 1; i < ill.Symptoms.Count; i++)
            {
                symp += $", {ill.Symptoms[i]}";
            }
            SympBox.Text   = symp;
            DoctorBox.Text = doctor.Name;
            illBox.Text    = ill.Name;
            for (int i = 0; i < ill.Portions.Count; i++)
            {
                var portion = ill.Portions[i];
                if (ill.Portions[i].Drug.Total - ill.Portions[i].Amount > 0)
                {
                    drug.Add(new Drug {
                        Name = portion.Drug.Name, Total = portion.Amount, Unit = portion.Drug.Unit, Change = null
                    });
                }
                for (int j = 0; j < portion.Drug.Change.Count; j++)
                {
                    Drug dr = GetDrugByName(portion.Drug.Change[j]);
                    if (dr.Total - portion.Amount > 0)
                    {
                        drug.Add(new Drug {
                            Name = dr.Name, Total = portion.Amount, Unit = dr.Unit, Change = null
                        });
                    }
                }
            }
            if (drug == null)
            {
                DrugGriedView.DataSource = "Лекарств нет";
            }
            else
            {
                DrugGriedView.DataSource = drug;
            }
        }
Exemplo n.º 19
0
        public async Task <IActionResult> Create([Bind("Name,Manufacturer,AgeLimit,TypeOfDrug,Price")] Drug drug)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(drug);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            } catch (DbUpdateException /* ex */)
            {
                ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists ");
            }

            return(View(drug));
        }
        public async Task <IActionResult> Create([Bind("DrugCode,DrugName,Category,DrugCompany,Description,Quantity")] Drug drug)
        {
            if (_signInManager.IsSignedIn(User))
            {
                if (ModelState.IsValid)
                {
                    _context.Add(drug);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(drug));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 21
0
        public async Task <Drug> DrugAdd([FromBody] Drug data)
        {
            string         values  = "('" + data.DrugName + "'," + data.PatientId + ")";
            string         query   = "INSERT INTO dbo.Drugs(DrugName,PatientId) VALUES " + values;
            SqlDataAdapter adapter = new SqlDataAdapter();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(query, connection);
                adapter.InsertCommand = new SqlCommand(query, connection);
                adapter.InsertCommand.ExecuteNonQuery();
                command.Dispose();
                connection.Close();
                //command.Parameters.AddWithValue("@id", id);
            }
            return(data);
        }
Exemplo n.º 22
0
        public async Task <IActionResult> PostDrug([FromBody] Drug drug)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Drugs.Add(drug);
            await _context.SaveChangesAsync();

            CancellationTokenSource cts = _cache.Get <CancellationTokenSource>("cts");

            cts.Cancel();

            _context.Entry(drug).State = EntityState.Modified;

            return(CreatedAtAction("GetDrug", new { id = drug.Id }, drug));
        }
Exemplo n.º 23
0
        public async void RemoveItemFromDb(object selectedDrug)
        {
            containingShellVm.startProcessing("Removing drug");
            Drug drug = selectedDrug as Drug;
            await Task.Run(() =>
            {
                try
                {
                    drugsManagementM.RemoveFromDb(drug);
                    containingShellVm.finishProcessing("Drug removed");
                }

                catch (ArgumentException e) { containingShellVm.ShowMessage(e.Message); }
                catch (Exception e) { containingShellVm.ShowMessage(e.Message); }
            });

            Items.Remove(drug);
        }
Exemplo n.º 24
0
        public async Task AddDrugToRegistry(Drug input)
        {
            Suffix suffix = new Suffix
            {
                Value = new string(
                    input
                    .Name
                    .Skip(input.Name.Length - 3)
                    .ToArray()
                    )
            };

            input.Suffix = suffix;

            _unitOfWork.DrugRepository
            .AddDrug(input);
            await _unitOfWork.SaveAsync();
        }
Exemplo n.º 25
0
        public void GetClosestLocation(Vector3 currentLocation, out Drug closeLocation, out Vector3 closestVector, out bool isHarvest)
        {
            var location = drugs.FirstOrDefault(o => o.HarvestLocations.Any(loc => loc.DistanceToSquared(currentLocation) < 15.0f));

            if (location != null)
            {
                closeLocation = location;
                closestVector = location.HarvestLocations.Where(loc => loc.DistanceToSquared(currentLocation) < 15.0f).ElementAt(0);
                isHarvest     = true;
                return;
            }

            location = drugs.FirstOrDefault(o => o.ProcessLocations.Any(loc => loc.DistanceToSquared(currentLocation) < 15.0f));

            closeLocation = location;
            closestVector = location?.ProcessLocations.Where(loc => loc.DistanceToSquared(currentLocation) < 15.0f).ElementAt(0) ?? Vector3.Zero;
            isHarvest     = false;
        }
Exemplo n.º 26
0
        static void AddDrugs(Default.Container container)
        {
            Drug drug = new Drug()
            {
                Name      = "多吉美",
                Code      = "123456",
                BarCode   = "123456",
                SuperCode = "123456"
            };

            container.AddToDrug(drug);
            var serviceResponse = container.SaveChanges();

            foreach (var operationResponse in serviceResponse)
            {
                System.Console.WriteLine("Response: {0}", operationResponse.StatusCode);
            }
        }
Exemplo n.º 27
0
 public void Add(Drug drug)
 {
     try
     {
         if (string.IsNullOrEmpty(drug.Name) ||
             string.IsNullOrEmpty(drug.Code) ||
             string.IsNullOrEmpty(drug.Type)
             )
         {
             throw new Exception("Invalid input");
         }
         _drugDAO.Add(drug);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task <IActionResult> EditDrug(int id, [FromBody] Drug drug)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.ValidationProblem(this.ModelState));
            }

            try
            {
                Drug result = await this.service.UpdateAsync(id, drug);

                return(this.Ok(result));
            }
            catch (ArgumentException ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
Exemplo n.º 29
0
 public bool updateDrug(eDrug e)
 {
     try
     {
         Drug d = new Drug();
         d.Description = e.Description;
         d.DrugID      = e.DrugID;
         d.Name        = e.Name;
         d.Price       = Convert.ToDecimal(e.Price);
         d.TypeID      = e.TypeID;
         drugdal.updateDrug(d);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 30
0
        private void InsertDrug()
        {
            string barcode = textBoxBarcode.Text;
            string name    = textBoxDrugName.Text;

            Drug drug = api.InsertDrug(barcode, name, User);

            labelDrugID.Text = drug.ID;
            LockControls();

            try
            {
                DrugListForm druglistform = (DrugListForm)Application.OpenForms[2];
                druglistform.GetDrugs(false, "");
            }
            catch
            { }
        }
        public async Task <IActionResult> AddDrug([FromBody] Drug drug)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.ValidationProblem(this.ModelState));
            }

            try
            {
                Drug result = await this.service.AddAsync(drug);

                return(this.Created(DEFAULT_ROUTE, result.Id));
            }
            catch (ArgumentException ex)
            {
                return(this.BadRequest(ex.Message));
            }
        }
Exemplo n.º 32
0
 public DrugForm(Drug item = null)
 {
     InitializeComponent();
     _connection = new DbAccess();
     _item       = item;
     if (_item != null)
     {
         nameTextBox.Text         = _item.Name;
         priceTextBox.Text        = _item.Price.ToString();
         amountUpDown.Value       = _item.Amount;
         codeTextBox.Text         = _item.Code;
         formTextBox.Text         = _item.Form;
         manufacturerTextBox.Text = _item.Manufacturer;
         atxTextBox.Text          = _item.ATX;
         pharmGroupTextBox.Text   = _item.PharmGroup;
         storehouseTextBox.Text   = _item.Storehouse;
     }
 }
Exemplo n.º 33
0
        /// <summary>
        /// Method to handled the updating of a drug. After confirming the drug is associated
        /// with the current user, the drug details are set to the passed in parameters and
        /// a boolean response is returned to the caller to indicate if the in memory
        /// version of the drug was successfully edited. This method does not persist the changes.
        /// The caller is required to do that.
        /// </summary>
        /// <param name="drug">The details of the drug to be edited</param>
        /// <param name="user">The user associated with this request</param>
        /// <returns>True if the drug was loaded into memory from the database and sucessfully edited,
        /// false otherwise
        /// </returns>
        private bool EditDrug(Drug drug, MyUser user)
        {
            // LOAD THE DRUG FROM THE DATABASE INTO MEMORY
            Drug drugToEdit = _context.Drug.Find(drug.DrugId);

            // CONFIRM THE DRUG WAS FOUND AND IS ASSOCIATED WITH THE CURRENT USER
            if (drugToEdit == null || drugToEdit.User != user)
            {
                return(false);
            }

            // SET THE DRUG DETAILS TO THOSE IN THE PARAMETER
            drugToEdit.Name         = drug.Name;
            drugToEdit.TradeName    = drug.TradeName;
            drugToEdit.Manufacturer = drug.Manufacturer;
            drugToEdit.GenericForId = drug.GenericForId;
            return(true);
        }
Exemplo n.º 34
0
 public async Task <IActionResult> Create(DrugViewModel drugView, IFormFile file)
 {
     if (file != null)
     {
         // путь к папке Files
         string path = "/Files/" + file.FileName;
         // сохраняем файл в папку Files в каталоге wwwroot
         using (var fileStream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create))
         {
             await file.CopyToAsync(fileStream);
         }
         Drug drug = _mapper.Map <DrugViewModel, Drug>(drugView);
         drug.Path = path;
         db.Drugs.Add(drug);
         await db.SaveChangesAsync();
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 35
0
 public Drug GetById(int id)
 {
     OpenConnection();
     drugs.Clear();
     using (SqlCommand cmd = new SqlCommand("SELECT * FROM [Drugs] where id=@id", connection))
     {
         cmd.Parameters.AddWithValue("@id", id);
         try
         {
             dataReader = cmd.ExecuteReader();
             if (dataReader.Read())
             {
                 Drug res = new Drug
                 {
                     Id           = Convert.ToInt32(dataReader["ID"]),
                     Name         = Convert.ToString(dataReader["Name"]),
                     Price        = Convert.ToDecimal(dataReader["Price"]),
                     Amount       = Convert.ToInt32(dataReader["Amount"]),
                     Code         = Convert.ToString(dataReader["Code"]),
                     Manufacturer = Convert.ToString(dataReader["Manufacturer"]),
                     ATX          = Convert.ToString(dataReader["ATX"]),
                     PharmGroup   = Convert.ToString(dataReader["PharmGroup"]),
                     Form         = Convert.ToString(dataReader["Form"]),
                     Storehouse   = Convert.ToString(dataReader["Storehouse"]),
                 };
                 return(res);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             if (dataReader != null)
             {
                 dataReader.Close();
             }
             CloseConnection();
         }
     }
     //Not found
     return(null);
 }
Exemplo n.º 36
0
        public async Task <IHttpActionResult> CreateDrugAsync(DrugDto drug)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Drug dbDrug = new Drug
                    {
                        BrandName   = drug.BrandName,
                        GenericName = drug.GenericName,
                        NdcId       = drug.NdcId,
                        Price       = drug.Price,
                        Strength    = drug.Strength,
                        CreatedBy   = User.Identity.Name
                    };


                    _unitOfWork.Drugs.Add(dbDrug);
                    await _unitOfWork.CompleteAsync();

                    drug.Id = dbDrug.Id;

                    _logger.Info($"New drug created with id {drug.Id}");

                    InvalidateCache();

                    return(Created(new Uri(Request.RequestUri + "/" + drug.Id), drug));
                }
                else
                {
                    _logger.Warn(string.Join(" | ", ModelState.Values.SelectMany(e => e.Errors.Take(1)).Select(e => e.ErrorMessage)));
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug(ex);
                    return(InternalServerError(ex));
                }
                return(InternalServerError());
            }
        }
Exemplo n.º 37
0
        public frmCreateCustomDrug(Character objCharacter, Drug objDrug = null)
        {
            if (objDrug == null)
            {
                objDrug      = new Drug(objCharacter);
                objDrug.GUID = new Guid();
            }
            _objCharacter = objCharacter;
            InitializeComponent();
            LoadData();

            lstSelectedDrugComponents = new List <clsNodeData>();

            foreach (var item in dictDrugComponents)
            {
                string category      = item.Value.Category;
                int    categoryIndex = FindRootNodeIndexForCategory(category);
                if (categoryIndex == -1)
                {
                    Log.Warning(string.Format("Uknown category %s in component %s", category, item.Key));
                    return;
                }
                var node       = treAvailableComponents.Nodes[categoryIndex].Nodes.Add(item.Key);
                int levelCount = item.Value.DrugEffects.Count;
                if (levelCount == 1)
                {
                    node.Tag = new clsNodeData(item.Value, 0);
                }
                else
                {
                    node.Tag = new clsNodeData(item.Value);
                    for (int i = 0; i < levelCount; i++)
                    {
                        var subNode = node.Nodes.Add("Level " + (i + 1).ToString());
                        subNode.Tag = new clsNodeData(item.Value, i);
                    }
                }
            }
            treAvailableComponents.ExpandAll();
            treChoosenComponents.ExpandAll();
            PopulateGrades();
            UpdateCustomDrugStats();
            lblDrugDescription.Text = objDrug.Description;
        }
Exemplo n.º 38
0
        //Unfin
        public void CopyDrugs()
        {
            if (SelectedSession == null)
            {
                return;
            }
            if (SelectedSession == _currentSession)
            {
                return;
            }

            var drugs = _esClinicContext.Drugs.ToList().Where(d => d.SessionId == SelectedSession.SessionId);

            Drugs.Clear();
            foreach (var drug in drugs)
            {
                var newDrug = new Drug();
            }
        }
Exemplo n.º 39
0
        public async Task UpdateDrugAsync_ShouldReturnDrugNotFound()
        {
            Drug    drug        = UnitOfWork.Drugs.Get(1);
            DrugDto updatedDrug = new DrugDto
            {
                BrandName   = drug.BrandName,
                GenericName = drug.GenericName,
                Id          = -1,
                NdcId       = drug.NdcId,
                Price       = drug.Price,
                Strength    = drug.Strength
            };

            DrugController.Validate(updatedDrug);
            var result = await DrugController.UpdateDrugAsync(updatedDrug);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Exemplo n.º 40
0
        /// <summary>
        /// 修改药品信息按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            if (KEY == 0)
            {
                MessageBox.Show("请先选中一行数据!", "温馨提示");
                return;
            }

            //创建drug,获取当前信息
            Drug drug = new Drug(KEY);

            InfoMgmtForm infoForm = new InfoMgmtForm(KEY);

            //为组件赋值:当前值
            infoForm.setValue(drug.Name, drug.Unit, drug.Spec, drug.Origin, drug.Lot_num, drug.Reserve, drug.W_price, drug.R_price);
            infoForm.asChange();//更改按钮
            infoForm.ShowDialog();
            BindAll_K();
        }
Exemplo n.º 41
0
        //显示药品列表
        private void ShowDrug(string code, bool Barcode)
        {
            string sql = "";

            if (Barcode)
            {
                sql = @"select distinct p.drugonlycode,drugname,drugaliasname,drugpycode,drugspec,drugfactory from drug_info i,drug_pos p where i.drugonlycode=p.drugonlycode and maccode='{0}'
             and p.drugonlycode in(select drugonlycode from drug_infoannex where drugbarcode='{1}' or drugsupcode='{1}')";
                sql = string.Format(sql, Config.Soft.MacCode, code);
            }
            else
            {
                sql = @"select distinct p.drugonlycode,drugname,drugaliasname,drugpycode,drugspec,drugfactory from drug_info i,drug_pos p where i.drugonlycode=p.drugonlycode and maccode='{0}'
             and p.drugonlycode in(select drugonlycode from drug_info where drugpycode like '%{1}%' or drugaliaspycode like '%{1}%')";
                sql = string.Format(sql, Config.Soft.MacCode, code);
            }
            DataTable dtDrug = new DataTable();

            csSql.ExecuteSelect(sql, Config.Soft.ConnString, out dtDrug);
            Drug[] ds = null;
            if (dtDrug != null && dtDrug.Rows.Count > 0)
            {
                ds = new Drug[dtDrug.Rows.Count];
                for (int r = 0; r < dtDrug.Rows.Count; r++)
                {
                    ds[r] = new Drug
                    {
                        DrugOnlyCode = dtDrug.Rows[r]["drugonlycode"].ToString(),
                        DrugName     = dtDrug.Rows[r]["drugname"].ToString(),
                        DrugSpec     = dtDrug.Rows[r]["drugspec"].ToString(),
                        DrugFactory  = dtDrug.Rows[r]["drugfactory"].ToString()
                    };
                }
            }
            lvDrug.ItemsSource = ds;
            //如果只有一项,则直接显示
            if (lvDrug.Items.Count == 1)
            {
                Drug d = lvDrug.Items[0] as Drug;
                ShowSize(d.DrugOnlyCode);
                ShowPos(d.DrugOnlyCode, true);
            }
        }
Exemplo n.º 42
0
    private void Start()
    {
        GameObject go;

        switch (Type)//依据传入的数据类型构造面板上的物品
        {
        case ItemType.food:
            go = GameObject.Instantiate(food[ID], transform.position, Quaternion.identity, this.transform);
            Food fd = go.GetComponent <Food>();
            fd.SetFood(ID, Quality, State);
            introducrion.text = fd.intro;
            break;

        case ItemType.drug:
            go = GameObject.Instantiate(drug[ID], transform.position, Quaternion.identity, this.transform);
            Drug dg = go.GetComponent <Drug>();
            dg = go.GetComponent <Drug>();
            dg.SetDrug(ID);
            introducrion.text = dg.intro;
            break;

        case ItemType.battery:
            go = GameObject.Instantiate(battery[ID], transform.position, Quaternion.identity, this.transform);
            Battery bty = go.GetComponent <Battery>();
            bty.SetBattery(ID, Quality);
            introducrion.text = bty.intro;
            break;

        case ItemType.upgrade:
            go = GameObject.Instantiate(upgrade[ID], transform.position, Quaternion.identity, this.transform);
            Upgrade ud = go.GetComponent <Upgrade>();
            ud.SetUpgrade(ID);
            introducrion.text = ud.intro;
            break;

        case ItemType.other:
            go = GameObject.Instantiate(other[ID], transform.position, Quaternion.identity, this.transform);
            Other ot = go.GetComponent <Other>();
            ot.SetOther(ID);
            introducrion.text = ot.intro;
            break;
        }
    }
Exemplo n.º 43
0
        public ActionResult Edit(Drug obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    dbActionResult resultAction = new dbActionResult();
                    resultAction = db.EditDrug(obj);
                    int id = resultAction.intResult;
                    if (id >= 0)
                    {
                    return RedirectToAction("Index");
                    }

                    if (id == -1)
                    {
                        db.DetachDrug(obj);
                        Drug oldObj = db.GetDrug(obj.DrugID);
                        ModelState.AddModelError("", "Ошибка параллельного доступа к данным. Если проблема повторится, обратитесь к системному администратору.");
                        if (oldObj.Code != obj.Code)
                            ModelState.AddModelError("Code", "Текущее значение: " + oldObj.Code.ToString());
                        if (oldObj.DescriptionEng != obj.DescriptionEng)
                            ModelState.AddModelError("DescriptionEng", "Текущее значение: " + oldObj.DescriptionEng.ToString());
                        if (oldObj.DescriptionRus.ToString() != obj.DescriptionRus.ToString())
                            ModelState.AddModelError("DescriptionRus", "Текущее значение: " + oldObj.DescriptionRus.ToString());
                        obj.Timestamp = oldObj.Timestamp;
                    }
                    if (id == -2)
                    {
                        ModelState.AddModelError("", resultAction.exData.Message.ToString() + " | " + resultAction.exData.GetType().ToString() + " | " +
                            "Невозможно сохранить изменения. Нажмите обновить страницу и повторить действия. Если проблема повторится, обратитесь к системному администратору.");
                    }
                }
            }

            catch (DataException ex)
            {
                ModelState.AddModelError("", ex.Message.ToString() + " | " + ex.GetType().ToString() + " | " + "Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору.");
            }

            return View(obj);
        }
Exemplo n.º 44
0
        public override void Run()
        {
            Drug drug = new Drug(DrugId);
            Prescriber prescriber = new Prescriber(PrescriberId);
            User user = new User(prescriber.Profile.UserID);

            StringBuilder message = new StringBuilder();

            message.Append("Your certification for ");
            message.Append(drug.GenericName);
            message.Append(" needs to be renewed.");

            Notification n = Lib.Systems.Notifications.NotificationService.Create(
                "Certification renewal notice",
                message.ToString(),
                true,
                Lib.Systems.Notifications.NotificationService.DataType.Drug,
                DrugId);

            Lib.Systems.Notifications.NotificationService.Send(n, user);
        }
Exemplo n.º 45
0
    /// <summary>
    /// Inserts new Drug object into database.
    /// </summary> 
    /// <returns>ID of the new object as int</returns>
    public static int insertNewDrug(Drug drug)
    {
        SqlConnection con = new SqlConnection(_ConnectionString);

        SqlCommand cmd = new SqlCommand("INSERT into Drugs (Name, Formula, Administration, Effects) VALUES('" + drug.Name + "', '" + drug.Formula +
            "', '" + drug.Administration + "', '" + drug.Effects + "'); " + "SELECT CAST(Scope_Identity() as int)", con);

        Int32 returnID = 0;

        using (con)
        {
            try
            {
                con.Open();
                returnID = (Int32)cmd.ExecuteScalar();    // Why this always returns 0?
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
            }
        }
        return returnID;
    }
Exemplo n.º 46
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Height = 242;
            incorrect = new List<string>();
            correct = new HashSet<string>();

            newCat = true;
            num = 0;
            flag = true;
            answer = "____";
            random = new Random();
            textBox1.Text = "Press enter here to start";

            choice = 1;
            choice2 = 1;
            index = 0;
            data = new List<Drugs>();

            // Read the file and display it line by line.
            lines = System.IO.File.ReadAllLines("data.txt");

            comboBox1.Items.Add("All drugs");
            comboBox1.Items.Add("Drugs by numbers");
            comboBox1.Items.Add("Drugs #1-50");
            comboBox1.Items.Add("Drugs #51-100");
            comboBox1.Items.Add("Drugs #101-150");
            comboBox1.Items.Add("Drugs #151-200");

            foreach (string line in lines)
            {
                if (line.Length != 0)
                {
                    string[] temp = line.Split('\t');
                    if (newCat)
                    {
                        Drugs x = new Drugs();
                        x.num = 0;
                        x.corr = 0;
                        x.list = new List<Drug>();
                        data.Add(x);
                        newCat = false;
                        comboBox1.Items.Add(temp[3]);
                    }

                    Drug y = new Drug();
                    y.num = Int32.Parse(temp[4]);
                    y.descr = line;
                    data[data.Count - 1].list.Add(y);
                    data[data.Count - 1].num++;
                }
                else
                    newCat = true;
            }

            comboBox1.SelectedIndex = 0;
            comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
            index = random.Next(0, data.Count);
            index2 = random.Next(0, data[index].list.Count);

            string[] str = data[index].list[index2].descr.Split('\t');
            label7.Text = "____";
            label8.Text = str[1];
            label9.Text = str[2];
            label10.Text = str[3];
            textBox1.Text = "";
            label6.Text = "____";
            answer = str[0];
            
           
            textBox1.Focus();
        }
Exemplo n.º 47
0
        private void button3_Click(object sender, EventArgs e)
        {
      //      numericUpDown1.Value = 1;
      //      numericUpDown2.Value = 10;
      //      radioButton1.Select();
      //      this.Height = 242;
      //      button2.Enabled = false;
      //      button1.Enabled = true;
            incorrect = new List<string>();
            correct = new HashSet<string>();

            newCat = true;
            num = 0;
            flag = true;
     //       answer = "____";
            random = new Random();
            textBox1.Text = "";

     //       choice = 1;
       //     choice2 = 1;
         //   index = 0;
            data = new List<Drugs>();

            // Read the file and display it line by line.
            lines = System.IO.File.ReadAllLines("data.txt");
/*
            comboBox1.Items.Clear();
            comboBox1.Items.Add("All drugs");
            comboBox1.Items.Add("Drugs by number");
            comboBox1.Items.Add("Drugs 1-50");
            comboBox1.Items.Add("Drugs 51-100");
            comboBox1.Items.Add("Drugs 101-150");
            comboBox1.Items.Add("Drugs 151-200");
*/
            foreach (string line in lines)
            {
                if (line.Length != 0)
                {
                    string[] temp = line.Split('\t');
                    if (newCat)
                    {
                        Drugs x = new Drugs();
                        x.num = 0;
                        x.corr = 0;
                        x.list = new List<Drug>();
                        data.Add(x);
                        newCat = false;
      //                  comboBox1.Items.Add(temp[3]);
                    }

                    Drug y = new Drug();
                    y.num = Int32.Parse(temp[4]);
                    y.descr = line;
                    data[data.Count - 1].list.Add(y);
                    data[data.Count - 1].num++;
                }
                else
                    newCat = true;
            }

     //       comboBox1.SelectedIndex = 0;
     //       comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
    //        index = random.Next(0, data.Count);
      //      index2 = random.Next(0, data[index].list.Count);

     /*       string[] str = data[index].list[index2].descr.Split('\t');
            label7.Text = "____";
            label8.Text = str[1];
            label9.Text = str[2];
            label10.Text = str[3];
            textBox1.Text = "";
            label6.Text = "____";
            answer = str[0];
*/
            listBox1.Items.Clear();
            chooseQuestion();
            textBox1.Focus();
            System.Windows.Forms.SendKeys.Send("{ENTER}");
        }
Exemplo n.º 48
0
    /// <summary>
    /// Updates an item with specified ID
    /// </summary>    
    /// <returns>ID of updated object as Int, 0 if an object with specified ID doesn't exist.</returns>
    public static int updateDrug(int id, Drug drug)
    {
        SqlConnection con = new SqlConnection(_ConnectionString);

        SqlCommand cmd = new SqlCommand("UPDATE Drugs SET Name='" + drug.Name + "', Formula='" + drug.Formula + "', Administration='" + drug.Administration + "', Effects='" + drug.Effects + "'WHERE SexID='" + id.ToString() + "'", con);

        Drug oldDrug = getDrug(id);
        int returnID = 0;

        using (con)
        {
            try
            {
                con.Open();
                returnID = (int)cmd.ExecuteScalar();
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
            }
        }

        return returnID;
    }
 public bool AddNewDrug(Drug drug)
 {
     return repository.AddNewDrug(drug);
 }
Exemplo n.º 50
0
    /// <summary>
    /// Gets a single Drug item with specified ID.
    /// </summary>
    /// <param name="id"></param>
    /// <returns>Drug object or null</returns>
    public static Drug getDrug(int id)
    {
        SqlConnection con = new SqlConnection(_ConnectionString);

        SqlCommand cmd = new SqlCommand("SELECT * FROM Drugs WHERE DrugID='" + id.ToString() + "'", con);

        Drug drug = null;

        using (con)
        {
            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();
                drug = new Drug((string)reader["Name"], (string)reader["Formula"], (string)reader["Administration"], (string)reader["Effects"]);
            }
            catch (System.Exception ex)
            {
                LastError = ex.Message;
            }
        }
        return drug;
    }
        public IHttpActionResult PutDrug(int id, Drug drug)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != drug.DrugID)
            {
                return BadRequest();
            }

            db.Entry(drug).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DrugExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 52
0
        /// <summary>
        /// The constructor saves the given drug in a local variable
        /// author: Florian Schnyder
        /// </summary>
        /// <param name="drug"></param>
        public DrugDetailsModel(Drug drug)
        {
            this.drug = drug;

        }
Exemplo n.º 53
0
 static int CompareByQuantityDecreasing( Drug lhs, Drug rhs ) 
     { return - lhs.Quantity.CompareTo( rhs.Quantity ); }
Exemplo n.º 54
0
        public static void ImportDrugs(OleDbConnection con, AriClinicContext ctx)
        {
            // (0) Borra tipos previos
            ctx.Delete(ctx.Treatments);
            ctx.SaveChanges();
            ctx.Delete(ctx.Drugs);
            ctx.SaveChanges();

            // (1) Dar de alta los diferentes diagnósticos
            string sql = "SELECT * FROM Farmacos";
            cmd = new OleDbCommand(sql, con);
            da = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds, "ConFarmacos");
            int nreg = ds.Tables["ConFarmacos"].Rows.Count;
            int reg = 0;
            foreach (DataRow dr in ds.Tables["ConFarmacos"].Rows)
            {
                reg++;
                Console.WriteLine("Fármacos {0:#####0} de {1:#####0} {2}", reg, nreg, (string)dr["NomFarm"]);
                Drug d = (from drg in ctx.Drugs
                          where drg.OftId == (int)dr["IdFarm"]
                          select drg).FirstOrDefault<Drug>();
                if (d == null)
                {
                    d = new Drug();
                    ctx.Add(d);
                }
                d.OftId = (int)dr["IdFarm"];
                d.Name = (string)dr["NomFarm"];
                ctx.SaveChanges();
            }
        }
        public IHttpActionResult PostDrug(Drug drug)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Drugs.Add(drug);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = drug.DrugID }, drug);
        }
Exemplo n.º 56
0
 public int StockCount(Drug drug)
 {
     // TODO: Make connection to database and count the stock
     throw new NotImplementedException();
 }
Exemplo n.º 57
0
 public void DecreaseStock(Drug drug, int decrease)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 58
0
    /// <summary>
    /// Gets all the drugs from the database.
    /// </summary>
    /// <returns>List of all drugs items</returns>
    public static List<Drug> getAllDrugs()
    {
        List<Drug> drugList = new List<Drug>();
        SqlConnection con = new SqlConnection(_ConnectionString);

        SqlCommand cmd = new SqlCommand("SELECT * FROM Drugs", con);

        using (con)
        {
            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Drug d = new Drug((string)reader["Name"], (string)reader["Formula"], (string)reader["Administration"], (string)reader["Effects"]);
                    drugList.Add(d);
                }
            }
            catch (System.Exception ex)
            {
                LastError = ex.Message;
            }
        }

        return drugList;
    }
Exemplo n.º 59
0
 private void ClearForm()
 {
     grvItems.CurrentRow = null;
     Drug item = new Drug();
     item.Context = DataLayer.GetContext();
     srcItem.DataSource = item;
     btnAdd.Enabled = true;
     txtName.Focus();
 }
Exemplo n.º 60
0
 static int CompareByTotalPaidDecreasing( Drug lhs, Drug rhs ) 
     { return - lhs.TotalPaid.CompareTo( rhs.TotalPaid ); }