Example #1
0
        /// <summary>
        /// Присвоение и пронумеровывание лекарств
        /// </summary>
        /// <param name="result"></param>
        private void SetAndOrderMedications(Result <List <Medications> > result)
        {
            Medications = result.Value;
            int num = 0;

            Medications.ForEach(d => d.OrderNumber = ++num);
        }
Example #2
0
        public IHttpActionResult PutMedication(int id, Medications medication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != medication.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult PostMedication(Medications medication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Medications.Add(medication);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MedicationExists(medication.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = medication.Id }, medication));
        }
Example #4
0
        public IHttpActionResult GetMedicationNames(short Store_Id, string search_string)
        {
            try
            {
                using (DunkeyContext ctx = new DunkeyContext())
                {
                    var         response      = ctx.Products.Where(x => x.Name.Contains(search_string) && x.Store_Id == Store_Id && x.IsDeleted == false).ToList();
                    var         f             = Mapper.Map <List <MedicationNames> >(response);
                    Medications responseModel = new Medications {
                        medications = f
                    };


                    CustomResponse <Medications> res = new CustomResponse <Medications>
                    {
                        Message    = "Success",
                        StatusCode = (int)HttpStatusCode.OK,
                        Result     = responseModel
                    };
                    return(Ok(res));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(DunkeyDelivery.Utility.LogError(ex)));
            }
        }
Example #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                int donorId = int.Parse(textBox1.Text.ToString());


                Medications k = new Medications();



                int result = k.DeleteMedication(donorId);
                if (result > 0)
                {
                    label2.Text = "Medication deleted";
                }
                else
                {
                    label2.Text = "Medication Not deleted";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void EditMedications(Medications medications)
 {
     medications.LastModifiedDateUtc = DateTime.UtcNow;
     medications.CreatedDateUtc      = DateTime.UtcNow;
     medications.LastModifiedBy      = 1;
     _repository.Update(medications);
 }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("MedicationId,MedicationDescription,MedicationCost,PackageSize,Strength,Sig,UnitsUsedYtd,LastPrescribedDate")] Medications medications)
        {
            if (id != medications.MedicationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medications);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicationsExists(medications.MedicationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medications));
        }
        public List <Medications> getAllMedications(int patientID)
        {
            clsUtility.Connection = dbTool.getConnectionString();

            InfiniEdge.SqlParameterCollection parameters = new InfiniEdge.SqlParameterCollection();
            parameters.Add(new SqlParameter("@PatientID", patientID));

            List <Medications> tmpMeds = new List <Medications>();
            SqlDataReader      sqlDR   = clsUtility.ExecuteSP_DataReader("getMedication", parameters);

            try
            {
                while (sqlDR.Read())
                {
                    Medications tmpM = new Medications();
                    tmpM.Dosage         = Single.Parse(sqlDR["Dosage"].ToString());
                    tmpM.Measurement    = sqlDR["Measurement"].ToString();
                    tmpM.MedicationDesc = sqlDR["Medication Name"].ToString();
                    tmpM.MedicationId   = Int32.Parse(sqlDR["MedicationId"].ToString());
                    tmpM.PatientID      = Int32.Parse(sqlDR["PatientID"].ToString());
                    tmpMeds.Add(tmpM);
                }
                return(tmpMeds);
            }
            finally
            {
                sqlDR.Close();
            }
        }
Example #9
0
        ///<summary>The values returned are sent to the webserver.</summary>
        public static List <Medicationm> GetMultMedicationms(List <long> medicationNums)
        {
            List <Medication>  MedicationList  = Medications.GetMultMedications(medicationNums);
            List <Medicationm> MedicationmList = ConvertListToM(MedicationList);

            return(MedicationmList);
        }
        [Route("{Key}")] //<--key == petId
        public ActionResult PutEdit(int key, [FromBody] Medications med)
        {
            pethouseContext db = new pethouseContext();

            try
            {
                Medications medDb = db.Medications.Find(key);
                if (med != null)
                {
                    medDb.Medname    = med.Medname;
                    medDb.MedDate    = med.MedDate;
                    medDb.MedExpDate = med.MedExpDate;
                    db.SaveChanges();

                    return(Ok(medDb.MedId));
                }
                else
                {
                    return(NotFound("Not found"));
                }
            }
            catch (Exception)
            {
                return(BadRequest("Error"));
            }
            finally
            {
                db.Dispose();
            }
        }
Example #11
0
        public async Task <Result <string> > AddMedicationsAsync(Medications medications)
        {
            if (medications == null)
            {
                return(new Result <string>("Пустое значение параметра"));
            }

            var    parameters = GetParametersfromMedications(medications);
            var    nameProc   = @"[dbo].[spMedications_Add]";
            object res        = null;

            try
            {
                using (var con = _conService.GetConnection())
                    using (var cmd = new SqlCommand(nameProc, con))
                    {
                        parameters.ForEach(p => cmd.Parameters.Add(p));
                        cmd.CommandType = CommandType.StoredProcedure;

                        await con.OpenAsync();

                        res = await cmd.ExecuteScalarAsync();
                    }
            }
            catch (Exception ex)
            {
                return(new Result <string>(ex.Message));
            }

            return(new Result <string>($"Успешно сохраненО новое лекарство {res}.", string.Empty));
        }
 public void Update(Medications entity)
 {
     using (DataContext _context = new DataContext())
     {
         _context.Update(MedicationsMapper.MapMedicationsEntityToMedicationsPersistance(entity));
         _context.SaveChanges();
     }
 }
Example #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            Medications medications = db.Medications.Find(id);

            db.Medications.Remove(medications);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public Guid Create(MedicationsDTO entityDTO)
        {
            Medications medications = CreateMedicationsFromDTO(entityDTO);

            _medicationsRepository.Create(medications);

            return(medications.KeyMedication);
        }
Example #15
0
        public void ShowAddMedicationsView(Medications medications)
        {
            var vm = new AddMedicationsViewModel(this);

            vm.SetMedications(medications);
            var from = new AddMedicationsView(vm);

            from.Owner = _mainfrom;
            from.ShowDialog();
        }
Example #16
0
 public ActionResult Edit(Medications medications)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medications).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medications));
 }
Example #17
0
        public async Task <IActionResult> Create([Bind("MedicationId,MedicationDescription,MedicationCost,PackageSize,Strength,Sig,UnitsUsedYtd,LastPrescribedDate")] Medications medications)
        {
            if (ModelState.IsValid)
            {
                _context.Add(medications);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(medications));
        }
Example #18
0
        public ActionResult Create(Medications medications)
        {
            if (ModelState.IsValid)
            {
                db.Medications.Add(medications);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medications));
        }
 public Task <Result <string> > AddMedicationsAsync(Medications medications)
 {
     medications.Id = 1;
     if (_dataSource.Medications.Count > 0)
     {
         medications.Id = _dataSource.Medications.Max(d => d.Id) + 1;
     }
     _dataSource.Medications.Add(medications);
     return(Task.FromResult(new Result <string>(
                                $"Успешно сохранен {medications.Name}", String.Empty)));
 }
Example #20
0
 private void LISTToolStripMenuItem6_Click(object sender, EventArgs e)
 {
     try
     {
         Medications r = new Medications();
         dgvDonors.DataSource = r.ListMedications();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private async Task GetMedications(int id)
        {
            Medications = await _context.Medications.ToListAsync();

            var medicationDistributions = await _context.MedicationDistributions.ToListAsync();

            MedicationUnits = await _context.MedicationUnits.ToListAsync();

            var medicationIds = medicationDistributions.Where(x => x.SubjectId == id).Select(x => x.MedicationId).ToList();

            Medications = Medications.Where(x => medicationIds.Contains(x.ID)).ToList();
        }
 internal void SetMedications(Medications medications)
 {
     Id              = medications.Id;
     Name            = medications.Name;
     Description     = medications.Description;
     ArrivalDate     = medications.ArrivalDate;
     ArrivalPackages = medications.ArrivalPackages;
     ShelfLife       = medications.ShelfLife;
     QuantityPackage = medications.QuantityPackage;
     RestPackages    = medications.RestPackages;
     RemainedUnits   = medications.RemainedUnits;
 }
Example #23
0
 public string GetJSONMedications(DataTable dtMedications, string EMRPatientID, string RequestID, string EMRID, string ModuleID, string UserID)
 {
     try
     {
         Medications objMedications = new Medications();
         string      JSONString     = objMedications.GenerateAPIJSONString(dtMedications, EMRPatientID, RequestID, EMRID, ModuleID, UserID);
         return(JSONString);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #24
0
        public Medication PopMedication()
        {
            if (Medications == null || Medications.Count < 1)
            {
                return(null);
            }

            var        i          = Medications.Count - 1;
            Medication medication = Medications[i];

            Medications.RemoveAt(i);
            return(medication);
        }
        public Task <Result <string> > UpdateMedicationsAsync(Medications medications)
        {
            var dg = _dataSource.Medications.FirstOrDefault(d => d.Id == medications.Id);

            if (dg == null)
            {
                return(Task.FromResult(new Result <string>("Не удалось обновить")));
            }

            dg.Name        = medications.Name;
            dg.Description = medications.Description;
            return(Task.FromResult(new Result <string>("Успешно обновлен", String.Empty)));
        }
Example #26
0
        public IHttpActionResult DeleteMedication(int id)
        {
            Medications medication = db.Medications.Find(id);

            if (medication == null)
            {
                return(NotFound());
            }

            db.Medications.Remove(medication);
            db.SaveChanges();

            return(Ok(medication));
        }
        public IHttpActionResult DeleteMedications(int id)
        {
            Medications medications = _context.Medications.SingleOrDefault(m => m.MedicationsId == id);

            if (medications == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            _context.Medications.Remove(medications);
            _context.SaveChanges();

            return(Ok(medications));
        }
        [HttpPost] //<-- filtteri, joka sallii vain POST-metodit
        //[Route("")]// <-- Routen placeholder
        public ActionResult PostCreateNew([FromBody] Medications med)
        {
            pethouseContext db = new pethouseContext(); //Tietokanta yhteytden muodostus

            try
            {
                db.Medications.Add(med);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                string virhe = ex.GetType().Name.ToString() + ": " + ex.Message.ToString();
                return(BadRequest("Request failed with error:\n" + virhe));
            }
            db.Dispose();          //Tietokannan vapautus
            return(Ok(med.PetId)); //Palauttaa vastaluodun uuden objektin avainarvon
        }
        public Medications GetTheLatestMedication(int key)
        {
            pethouseContext db          = new pethouseContext();
            Medications     medications = (from p in db.Medications
                                           where p.PetId == key
                                           orderby p.MedDate descending
                                           select p).FirstOrDefault();

            if (medications != null)
            {
                return(medications);
            }
            else
            {
                return(null);
            }
        }
        private IdentifiableDTO <MedicationsDTO> CreateDTOFromMedications(Medications medications)
        {
            if (medications == null)
            {
                return(null);
            }

            return(new IdentifiableDTO <MedicationsDTO>()
            {
                Id = medications.KeyMedication,
                EntityDTO = new MedicationsDTO()
                {
                    Name = medications.Name,
                    Quantity = medications.Quantity
                }
            });
        }