示例#1
0
 ///<summary>Inserts one Medication into the database.  Returns the new priKey.</summary>
 internal static long Insert(Medication medication)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         medication.MedicationNum=DbHelper.GetNextOracleKey("medication","MedicationNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(medication,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     medication.MedicationNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(medication,false);
     }
 }
示例#2
0
 ///<summary>Inserts one Medication into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Medication medication,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         medication.MedicationNum=ReplicationServers.GetKey("medication","MedicationNum");
     }
     string command="INSERT INTO medication (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MedicationNum,";
     }
     command+="MedName,GenericNum,Notes,RxCui) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(medication.MedicationNum)+",";
     }
     command+=
          "'"+POut.String(medication.MedName)+"',"
         +    POut.Long  (medication.GenericNum)+","
         +"'"+POut.String(medication.Notes)+"',"
         //DateTStamp can only be set by MySQL
         +    POut.Long  (medication.RxCui)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         medication.MedicationNum=Db.NonQ(command,true);
     }
     return medication.MedicationNum;
 }
示例#3
0
        Medication buildMedication(RXE rxe)
        {
            Medication med = new Medication();

            med.RxNumber = rxe.PrescriptionNumber.Value;
            med.Quantity = rxe.QuantityTiming.Quantity.Quantity.Value;
            med.StartDate = rxe.GiveCode.Identifier.Value;
            med.Status = rxe.GiveCode.Text.Value;
            med.Refills = rxe.NumberOfRefills.Value;

            return med;
        }
示例#4
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Medication> TableToList(DataTable table){
			List<Medication> retVal=new List<Medication>();
			Medication medication;
			for(int i=0;i<table.Rows.Count;i++) {
				medication=new Medication();
				medication.MedicationNum= PIn.Long  (table.Rows[i]["MedicationNum"].ToString());
				medication.MedName      = PIn.String(table.Rows[i]["MedName"].ToString());
				medication.GenericNum   = PIn.Long  (table.Rows[i]["GenericNum"].ToString());
				medication.Notes        = PIn.String(table.Rows[i]["Notes"].ToString());
				medication.DateTStamp   = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				medication.RxCui        = PIn.Long  (table.Rows[i]["RxCui"].ToString());
				retVal.Add(medication);
			}
			return retVal;
		}
示例#5
0
        public IActionResult EditPost(EditMedViewModel editMedViewModel)
        {
            string          user         = User.Identity.Name;
            ApplicationUser userLoggedIn = _context.Users.Single(c => c.UserName == user);

            Medication editedMed = _context.Medication.Single(c => c.ID == editMedViewModel.Med.ID);

            editedMed.Name       = editMedViewModel.Med.Name;
            editedMed.Dosage     = editMedViewModel.Med.Dosage;
            editedMed.Notes      = editMedViewModel.Med.Notes;
            editedMed.TimesXDay  = editMedViewModel.Med.TimesXDay;
            editedMed.RefillRate = editMedViewModel.Med.RefillRate;
            editedMed.UserID     = userLoggedIn.Id;

            // update change and save to db
            _context.Medication.Update(editedMed);
            _context.SaveChanges();

            return(Redirect("/Medications/Index"));
        }
示例#6
0
        private void btnMedSave_Click(object sender, EventArgs e)
        {
            if (tBoxMedTitle.Text.Trim() == "" || rtBoxMedDescription.Text.Trim() == "")
            {
                MessageBox.Show("Complete all fields");
            }
            else
            {
                string title       = tBoxMedTitle.Text.Trim();
                string description = rtBoxMedDescription.Text.Trim();
                int    doseUnit    = Convert.ToInt32(numUDUnit.Value);
                int    dosePortion = Convert.ToInt32(numUDPortion.Value);
                int    dosePeriod  = Convert.ToInt32(numUDPeriod.Value);
                int    quantity    = Convert.ToInt32(numUDinStock.Value);

                NewMed = new Medication(title, description, doseUnit, dosePortion, dosePeriod, quantity);

                Close();
            }
        }
示例#7
0
        private void gridAllMedications_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            Medication med = (Medication)gridAllMedications.Rows[e.Row].Tag;

            if (IsSelectionMode)
            {
                SelectedMedicationNum = med.MedicationNum;
                DialogResult          = DialogResult.OK;
            }
            else                                                                   //normal mode from main menu
            {
                if (!CultureInfo.CurrentCulture.Name.EndsWith("US") || e.Col != 3) //Not United States RxNorm Column
                {
                    FormMedicationEdit FormME = new FormMedicationEdit();
                    FormME.MedicationCur = med;
                    FormME.ShowDialog();                    //This window refreshes the Medication cache if the user clicked OK.
                    FillTab();
                }
            }
        }
示例#8
0
        ///<summary>Inserts the new medication and returns it.</summary>
        public static Medication CreateMedication(string medName = "", string rxCui = "")
        {
            Medication medication = new Medication();

            medication.MedName = medName;
            if (medication.MedName == "")
            {
                medication.MedName = "Med_" + MiscUtils.CreateRandomAlphaNumericString(8);
            }
            medication.RxCui = PIn.Long(rxCui, false);
            if (medication.RxCui != 0 && RxNorms.GetByRxCUI(rxCui) == null)
            {
                RxNorm rxNorm = new RxNorm();
                rxNorm.RxCui       = rxCui;
                rxNorm.Description = medication.MedName;
                RxNorms.Insert(rxNorm);
            }
            Medications.Insert(medication);
            return(medication);
        }
        public ActionResult <string> EditMedication([FromBody] Medication medication)
        {
            try
            {
                //TODO: Check if id is null
                var command = new SqlCommand("UPDATE Medication SET DIN=@DIN, PERSONID=@PERSONID, PRESCRIPTIONID=@PRESCRIPTIONID " +
                                             ", [NAME]=@NAME, DOSAGE=@DOSAGE, STRENGTH=@STRENGTH, UNITS=@UNITS, FORMAT=@FORMAT, INSTRUCTIONS=@INSTRUCTIONS, NUMREFILLS=@NUMREFILLS," +
                                             " REMAININGPILLS=@REMAININGPILLS, PHARMACYOBTAINED=@PHARMACYOBTAINED, [IMAGE]=null, TAKEASNEEDED=@TAKEASNEEDED, SIDEEFFECTS=@SIDEEFFECTS," +
                                             " DATEOBTAINED=@DATEOBTAINED WHERE ID=@ID", Connections.pillboxDatabase);

                command.Parameters.AddWithValue("@ID", medication.Id);
                command.Parameters.AddWithValue("@DIN", medication.DIN);
                command.Parameters.AddWithValue("@PERSONID", medication.PersonId);
                command.Parameters.AddWithValue("@PRESCRIPTIONID", medication.PrescriptionId);
                command.Parameters.AddWithValue("@NAME", medication.Name);
                command.Parameters.AddWithValue("@DOSAGE", medication.Dosage);
                command.Parameters.AddWithValue("@STRENGTH", medication.Strength);
                command.Parameters.AddWithValue("@UNITS", medication.Units);
                command.Parameters.AddWithValue("@FORMAT", medication.Format);
                command.Parameters.AddWithValue("@INSTRUCTIONS", medication.Instructions);
                command.Parameters.AddWithValue("@NUMREFILLS", medication.NumRefills);
                command.Parameters.AddWithValue("@REMAININGPILLS", medication.RemainingPills);
                command.Parameters.AddWithValue("@PHARMACYOBTAINED", medication.PharmacyObtained);
                command.Parameters.AddWithValue("@TAKEASNEEDED", medication.TakeAsNeeded);
                command.Parameters.AddWithValue("@SIDEEFFECTS", medication.SideEffects);
                command.Parameters.AddWithValue("@DATEOBTAINED", medication.DateObtained);

                Connections.pillboxDatabase.Open();
                command.ExecuteScalar();

                return(Ok($"Successfully updated Medication: {medication.Id}"));
            }
            catch (Exception ex)
            {
                return(BadRequest($"EditMedication() error \n {ex.ToString()}"));
            }
            finally
            {
                Connections.pillboxDatabase.Close();
            }
        }
示例#10
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            int index = Medication.IndexOf("(");

            if (index > 0)
            {
                Medication = Medication.Substring(0, index - 1);
            }
            MyRepo.Medication = Medication;

            Ranorex.Report.Info("Validate PCA Medication: " + Medication);
            Validate.Exists(MyRepo.MainWindow.Modalities.AdvancedModalities.AddedPCAInfo);

            if (Dose != "")
            {
                Ranorex.Report.Info("Validate Bolus Dose: " + Dose + " " + Unit);
                Validate.AttributeContains(MyRepo.MainWindow.Modalities.AdvancedModalities.AddedPCAInfo, "caption", "Bolus dose: " + Dose + " " + Unit);
            }

            if (Dose != "")
            {
                Ranorex.Report.Info("Validate Bolus Lockout: " + Lockout + " minutes");
                Validate.AttributeContains(MyRepo.MainWindow.Modalities.AdvancedModalities.AddedPCAInfo, "caption", "Lockout: " + Lockout + " minutes");
            }

            if (Rate != "")
            {
                Ranorex.Report.Info("Validate Continuous Rate: " + Rate + " " + Unit);
                Validate.AttributeContains(MyRepo.MainWindow.Modalities.AdvancedModalities.AddedPCAInfo, "caption", "Continuous rate: " + Rate + " " + Unit);
            }

            if (DoseLimit != "")
            {
                Ranorex.Report.Info("Validate " + hr + " hr Dose Limit: " + DoseLimit + " " + Unit);
                Validate.AttributeContains(MyRepo.MainWindow.Modalities.AdvancedModalities.AddedPCAInfo, "caption", hr + " hr dose limit: " + DoseLimit + " " + Unit);
            }
        }
示例#11
0
        public JsonResult EditMedication()
        {
            try
            {
                MedicationRepository medicationRepo = new MedicationRepository();
                Medication           medication     = medicationRepo.Get(int.Parse(Request.Form["Medication"]));
                medication.Name = Request.Form["EditMedication"];

                return(Json(new
                {
                    error = "false"
                }));
            }
            catch
            {
                return(Json(new
                {
                    error = "true"
                }));
            }
        }
示例#12
0
 protected virtual void Setup()
 {
     this.Setup(m => m.GetAllAsync())
     .Returns(async() =>
     {
         List <Medication> list = new List <Medication>();
         return(await Task.FromResult(list));
     });
     this.Setup(m => m.GetByIdAsync(It.IsAny <Guid>())).Returns(async() =>
     {
         var guid = Guid.NewGuid();
         Medication medication = new Medication()
         {
             PKID         = guid,
             CreationDate = DateTimeOffset.UtcNow,
             Name         = $"test{guid}",
             Quantity     = 3
         };
         return(await Task.FromResult(medication));
     });
 }
示例#13
0
 ///<summary>Returns true if Update(Medication,Medication) 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(Medication medication, Medication oldMedication)
 {
     if (medication.MedName != oldMedication.MedName)
     {
         return(true);
     }
     if (medication.GenericNum != oldMedication.GenericNum)
     {
         return(true);
     }
     if (medication.Notes != oldMedication.Notes)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (medication.RxCui != oldMedication.RxCui)
     {
         return(true);
     }
     return(false);
 }
示例#14
0
        public Visitation AddVisitation(int doctorId, int patientId, string reason, string notes,
                                        string medicationName, string medicationQuantity, string medicationInstructions,
                                        string treatmentPrescribed, string testPrescribed)
        {
            Visitation visitation = _visitationRepository.CreateVisitation(doctorId, patientId, DateTime.Now, reason, notes);

            if (medicationName != null)
            {
                Medication medication = _medicationRepository.AddMedication(visitation.VisitationId, medicationName, medicationQuantity, medicationInstructions);
            }
            if (testPrescribed != null)
            {
                Test test = _testRepository.AddTest(visitation.VisitationId, testPrescribed);
            }
            if (treatmentPrescribed != null)
            {
                Treatment treatment = _treatmentRepository.AddTreatment(visitation.VisitationId, treatmentPrescribed);
            }

            return(visitation);
        }
示例#15
0
        /// <summary>
        /// This method returns a medication list based on the query executed
        /// </summary>
        /// <param name="b">The <see cref="QueryBuilder"/> containing the code to execute.</param>
        /// <returns>A <see cref="List{Medication}"/>.</returns>
        public List <Medication> GetMedicationName(QueryBuilder b)
        {
            Medication        a      = new Medication();
            List <Medication> result = new List <Medication>();
            MySqlCommand      query  = new MySqlCommand(b.ToString(), dbCon.GetConnection());
            MySqlDataReader   reader = query.ExecuteReader();

            while (reader.Read())
            {
                Tables.MedicationTable pt = Tables.MEDICATION_TABLE;
                a.ID             = GetInt(reader[pt.ID.Name]);
                a.CommercialName = GetString(reader[pt.CommercialName.Name]);
                a.Manufacturer   = GetString(reader[pt.Manufacturer.Name]);
                a.ScientificName = GetString(reader[pt.ScientificName.Name]);
                result.Add(a);
            }

            reader.Close();
            reader.Dispose();
            return(result);
        }
示例#16
0
        public async Task <ActionResult <Medication> > PostMedication(Medication medication)
        {
            _context.Medications.Add(medication);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MedicationExists(medication.Name))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetMedication", new { id = medication.Name }, medication));
        }
示例#17
0
        private void gridAllMedications_CellClick(object sender, ODGridClickEventArgs e)
        {
            Medication med = (Medication)gridAllMedications.Rows[e.Row].Tag;

            if (CultureInfo.CurrentCulture.Name.EndsWith("US") && e.Col == 3)           //United States RxNorm Column
            {
                FormRxNorms formRxNorm = new FormRxNorms();
                formRxNorm.IsSelectionMode          = true;
                formRxNorm.InitSearchCodeOrDescript = med.MedName;
                formRxNorm.ShowDialog();
                if (formRxNorm.DialogResult == DialogResult.OK)
                {
                    med.RxCui = PIn.Long(formRxNorm.SelectedRxNorm.RxCui);
                    //The following behavior mimics FormMedicationEdit OK click.
                    Medications.Update(med);
                    MedicationPats.UpdateRxCuiForMedication(med.MedicationNum, med.RxCui);
                    DataValid.SetInvalid(InvalidType.Medications);
                }
                FillTab();
            }
        }
        public async Task <IActionResult> Delete(long id, Medication medication)
        {
            if (!IsLoggedIn())
            {
                return(RedirectToPage("/Account/Login"));
            }
            Medication preSaveMedication = await context.Medications.AsNoTracking().Include(m => m.Infant).FirstOrDefaultAsync(m => m.MedicationId == id);

            if (!IsMedicationOwner(preSaveMedication))
            {
                return(RedirectToPage("/Error/Error404"));
            }


            long infantId = medication.InfantId;

            context.Medications.Remove(medication);
            await context.SaveChangesAsync();

            return(RedirectToAction("Index", "Dashboard", new { id = infantId }));
        }
示例#19
0
        ///<summary>Custom sorting so that generic medications are above branded medications.
        ///Given list elements are a ODTuple of a medication and the given generic name if set.</summary>
        private static List <ODTuple <Medication, string> > SortMedGenericsFirst(List <ODTuple <Medication, string> > listMedLines)
        {
            List <ODTuple <Medication, string> > listMedGeneric = new List <ODTuple <Medication, string> >();
            List <ODTuple <Medication, string> > listMedBranded = new List <ODTuple <Medication, string> >();

            foreach (ODTuple <Medication, string> pair in listMedLines)
            {
                Medication med         = pair.Item1;
                string     genericName = pair.Item2;
                if (med.MedName.ToLower().In(genericName.ToLower(), ""))                //Generic if names directly match, or assume generic if no genericName provided.
                {
                    listMedGeneric.Add(pair);
                }
                else                  //Branded
                {
                    listMedBranded.Add(pair);
                }
            }
            listMedGeneric.AddRange(listMedBranded);
            return(listMedGeneric);
        }
        public async Task GetMedicationByIdAsync_Success(
            string medicationId,
            Medication medication)
        {
            // Arrange
            medication.ExternalId = medicationId;

            this.medicationRepositoryMock
            .Setup(s => s.GetAllMedicationsAsync(medicationId, null))
            .ReturnsAsync(new[] { medication });

            // Act
            var result = await this.medicationService.GetMedicationByIdAsync(medicationId);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(medication.ExternalId, result !.Id);
            Assert.Equal(medication.Name, result !.Name);
            Assert.Equal(medication.Quantity, result !.Quantity);
            Assert.Equal(medication.CreatedAt, result !.CreatedAt);
        }
示例#21
0
        public bool CreateMedication(MedicationCreate model)
        {
            var entity =
                new Medication()
            {
                OwnerId = _userId,
                Name    = model.Name,
                //PetId = model.PetId,
                //Dosage = model.Dosage,
                TimesPerDay = model.TimesPerDay,
                BeginDate   = model.BeginDate,
                EndDate     = model.EndDate,
                RefillLink  = model.RefillLink
            };

            using (var ctx = new ApplicationDbContext())
            {
                Medication medication = ctx.Medications.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public async Task <IActionResult> Edit(string id, [Bind("Din,Name,Image,MedicationTypeId,DispensingCode,Concentration,ConcentrationCode")] Medication medication)
        {
            if (id != medication.Din)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                medication.MedicationTypeId = Convert.ToInt32(Request.Cookies["medicationTypeId"]);

                medication.ConcentrationCode = _context.Medication
                                               .Where(m => m.MedicationTypeId.ToString() == medTypeId)
                                               .FirstOrDefault().ConcentrationCode;

                try
                {
                    _context.Update(medication);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicationExists(medication.Din))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["MedTypeName"]       = medTypeName;
            ViewData["ConcentrationCode"] = new SelectList(_context.ConcentrationUnit.OrderBy(m => m.ConcentrationCode), "ConcentrationCode", "ConcentrationCode", medication.ConcentrationCode);
            ViewData["DispensingCode"]    = new SelectList(_context.DispensingUnit.OrderBy(m => m.DispensingCode), "DispensingCode", "DispensingCode", medication.DispensingCode);
            // ViewData["MedicationTypeId"] = new SelectList(_context.MedicationType, "MedicationTypeId", "Name", medication.MedicationTypeId);
            return(View(medication));
        }
        private void bbiSaveAndClose_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    var medicationToRemove = (from dtr in context.Medications
                                              where dtr.MemberID == memberID
                                              select dtr).ToList();

                    if (medicationToRemove.Count > 0)
                    {
                        foreach (var dtr in medicationToRemove)
                        {
                            context.Medications.Remove(dtr);
                            context.SaveChanges();
                        }
                    }

                    foreach (var dta in medicationToAdd)
                    {
                        Medication medicationToAdd = new Medication();
                        medicationToAdd.MemberID         = memberID;
                        medicationToAdd.MedicationNameID = dta.MedicationNameID;

                        context.Medications.Add(medicationToAdd);
                        context.SaveChanges();
                    }

                    Logging.AddLogEntry(staffID, Logging.ErrorCodes.Broadcast, Logging.RefreshCodes.Medication, MiscStuff.GetMemberName(memberID) + " Medications have been changed", false);
                }
            }
            catch (Exception ex)
            {
                Logging.AddLogEntry(staffID, Logging.ErrorCodes.Error, Logging.RefreshCodes.None, MiscStuff.GetMemberName(memberID) + " Medications have not been changed - Error - " + ex.Message, false);
                MessageBox.Show(ex.Message);
            }

            this.Close();
        }
示例#24
0
        ///<summary>Inserts one Medication into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(Medication medication, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO medication (";

            if (!useExistingPK && isRandomKeys)
            {
                medication.MedicationNum = ReplicationServers.GetKeyNoCache("medication", "MedicationNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MedicationNum,";
            }
            command += "MedName,GenericNum,Notes,RxCui) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(medication.MedicationNum) + ",";
            }
            command +=
                "'" + POut.String(medication.MedName) + "',"
                + POut.Long(medication.GenericNum) + ","
                + DbHelper.ParamChar + "paramNotes,"
                //DateTStamp can only be set by MySQL
                + POut.Long(medication.RxCui) + ")";
            if (medication.Notes == null)
            {
                medication.Notes = "";
            }
            OdSqlParameter paramNotes = new OdSqlParameter("paramNotes", OdDbType.Text, POut.StringParam(medication.Notes));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNotes);
            }
            else
            {
                medication.MedicationNum = Db.NonQ(command, true, "MedicationNum", "medication", paramNotes);
            }
            return(medication.MedicationNum);
        }
        public ActionResult <int> CreateMedication([FromBody] Medication medication)
        {
            try
            {
                var command = new SqlCommand("INSERT INTO Medication (DIN, PERSONID, PRESCRIPTIONID, [NAME]" +
                                             ", DOSAGE, STRENGTH, UNITS, FORMAT, INSTRUCTIONS, NUMREFILLS, REMAININGPILLS, PHARMACYOBTAINED,[image], TAKEASNEEDED, SIDEEFFECTS, DATEOBTAINED)" +
                                             "VALUES(@DIN, @PERSONID, @PRESCRIPTIONID, @NAME, @DOSAGE, @STRENGTH, @UNITS, @FORMAT, @INSTRUCTIONS, @NUMREFILLS, @REMAININGPILLS, @PHARMACYOBTAINED," +
                                             " null, @TAKEASNEEDED, @SIDEEFFECTS, @DATEOBTAINED); SELECT SCOPE_IDENTITY()", Connections.pillboxDatabase);

                command.Parameters.AddWithValue("@DIN", medication.DIN);
                command.Parameters.AddWithValue("@PERSONID", medication.PersonId);
                command.Parameters.AddWithValue("@PRESCRIPTIONID", medication.PrescriptionId);
                command.Parameters.AddWithValue("@NAME", medication.Name);
                command.Parameters.AddWithValue("@DOSAGE", medication.Dosage);
                command.Parameters.AddWithValue("@STRENGTH", medication.Strength);
                command.Parameters.AddWithValue("@UNITS", medication.Units);
                command.Parameters.AddWithValue("@FORMAT", medication.Format);
                command.Parameters.AddWithValue("@INSTRUCTIONS", medication.Instructions);
                command.Parameters.AddWithValue("@NUMREFILLS", medication.NumRefills);
                command.Parameters.AddWithValue("@REMAININGPILLS", medication.RemainingPills);
                command.Parameters.AddWithValue("@PHARMACYOBTAINED", medication.PharmacyObtained);
                command.Parameters.AddWithValue("@TAKEASNEEDED", medication.TakeAsNeeded);
                command.Parameters.AddWithValue("@SIDEEFFECTS", medication.SideEffects);
                command.Parameters.AddWithValue("@DATEOBTAINED", medication.DateObtained);

                Connections.pillboxDatabase.Open();

                var medicationId = Convert.ToInt32(command.ExecuteScalar());

                return(Ok(medicationId));
            }
            catch (Exception ex)
            {
                return(BadRequest($"CreateMedication() error \n {ex.ToString()}"));
            }
            finally
            {
                Connections.pillboxDatabase.Close();
            }
        }
示例#26
0
        public async Task <IActionResult> Create([Bind("Din,Name,Image,MedicationTypeId,DispensingCode,Concentration,ConcentrationCode")] Medication medication)
        {
            medication.MedicationTypeId = Convert.ToInt32(HttpContext.Session.GetString("code"));
            if (_context.Medication.Any(m => m.Name == medication.Name) && _context.Medication.Any(m => m.Concentration == medication.Concentration) && _context.Medication.Any(m => m.ConcentrationCode == medication.ConcentrationCode))
            {
                ModelState.AddModelError("Name", "Medication already exists");
            }

            if (ModelState.IsValid)
            {
                _context.Add(medication);
                await _context.SaveChangesAsync();

                TempData["AlertMessage"] = "Record created";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ConcentrationCode"] = new SelectList(_context.ConcentrationUnit.OrderBy(m => m.ConcentrationCode), "ConcentrationCode", "ConcentrationCode", medication.ConcentrationCode);
            ViewData["DispensingCode"]    = new SelectList(_context.DispensingUnit.OrderBy(m => m.DispensingCode), "DispensingCode", "DispensingCode", medication.DispensingCode);
            ViewData["MedicationTypeId"]  = new SelectList(_context.MedicationType, "MedicationTypeId", "Name", medication.MedicationTypeId);
            ViewData["medName"]           = HttpContext.Session.GetString("medName");
            return(View(medication));
        }
示例#27
0
        public ActionResult UpdateMedication(MedicationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateMedication", viewModel));
            }


            Medication medication = new Medication
            {
                MidNo          = viewModel.Id,
                RecordNo       = viewModel.RecordNo,
                RecordedDate   = DateTime.Now,
                MedicationDesc = viewModel.Medication
            };

            _patientrecordservices.UpdateMedication(medication);

            _unitOfWork.Commit();

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
示例#28
0
    Patient UpdatePulseRateUpwards(Medication m, Patient p)
    {
        if (m.dose > 0f && p.pulseRate > 0f && m.currentLevel >= m.dose && m.dosesAdministered < 99)
        {
            if (m.name == "Pain")
            {
                p.pulseRate = p.pulseRate + pulseRateIncreaseFromPain * Time.deltaTime;
            }

            if (m.name == "Infection")
            {
                p.pulseRate = p.pulseRate + pulseRateIncreaseFromInfection * Time.deltaTime;
            }

            if (m.name == "Blood")
            {
                p.pulseRate = p.pulseRate + pulseRateIncreaseFromBloodLoss * Time.deltaTime;
            }
        }

        return(p);
    }
示例#29
0
        private void SaveMedicationClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var medicationDataRepository = new MedicationDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier);
                var medication = new Medication()
                {
                    PatientId       = EHealthCareDesktopApp.Properties.Settings.Default.PatientID,
                    DoseText        = cmbDose.SelectedValue.ToString(),
                    DoseUnit        = int.Parse(txtDose.Text.Trim()),
                    HowTaken        = ((MedicationTaken)cmbHowTaken.SelectedItem).Name,
                    MedicationName  = txtMedicationName.Text.Trim(),
                    Notes           = txtNotes.Text.Trim(),
                    StartDate       = dtPickerStartDate.SelectedDate.Value,
                    StrengthText    = cmbStrength.SelectedValue.ToString(),
                    StrengthUnit    = int.Parse(txtStrength.Text),
                    ReasonForTaking = txtReasonForTaking.Text.Trim()
                };

                if (dtPickerEndDate.SelectedDate != null)
                {
                    medication.EndDate = dtPickerEndDate.SelectedDate.Value;
                }

                medicationDataRepository.SaveMedication(medication);

                if (MedicationAddedEvent != null)
                {
                    MedicationAddedEvent("Success");
                }
            }
            catch (Exception ex)
            {
                if (MedicationAddedEvent != null)
                {
                    MedicationAddedEvent(string.Format("Problem in adding Medications: {0}", ex.Message));
                }
            }
        }
示例#30
0
        protected void SaveTherapy_Click(object sender, EventArgs e)
        {
            try
            {
                DAL.DBTherapyConnection dBTherapy = new DAL.DBTherapyConnection();
                Therapy therapy = new Therapy();
                therapy.date        = Convert.ToDateTime(NewTherapyDate.Text);
                therapy.Time        = TimeSpan.Parse(NewTherapyEndTime.Text);
                therapy.description = NewTherapyDescriptionTB.Text;
                therapy.Location    = Location.Text ?? "";
                therapy.CostsInEuro = Convert.ToDecimal(Costs.Text ?? "0", CultureInfo.InvariantCulture);
                Desease desease = new Desease();
                desease.ID = Convert.ToInt32(NewDesease.SelectedValue);
                Medication medication = new Medication();
                medication.ID = Convert.ToInt32(NewMedicationDDL.SelectedValue);


                if (dBTherapy.IsTherapyAllowed(LoggedInUser, therapy, NewTherapyClient.SelectedValue))
                {
                    bool result = dBTherapy.Save(LoggedInUser, therapy, medication, desease, NewTherapyClient.SelectedValue);
                    if (result)
                    {
                        lbl.Text = "Behandeling is succesvol opgeslagen";
                    }
                    else
                    {
                        lbl.Text = "Er is iets fout gegaan";
                    }
                }
                else
                {
                    lbl.Text = "De behandelaar of de cliënt heeft al een behandeling gepland in het ingevuld tijdsbestek";
                }
            }
            catch (Exception ex)
            {
                lbl.Text = "Er is iets fout gegaan";
            }
        }
示例#31
0
        private void butEdit_Click(object sender, System.EventArgs e)
        {
            Medications.RefreshCache();
            FormMedicationEdit FormME = new FormMedicationEdit();
            Medication         med    = Medications.GetMedication(MedicationPatCur.MedicationNum); //The edit button is not visible if MedicationNum=0.

            if (med == null)                                                                       //Possible to delete the medication from a separate WS while medication loaded in memory.
            {
                MsgBox.Show(this, "An error occurred loading medication.");
                return;
            }
            FormME.ShowDialog();
            if (FormME.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationPatCur.RxCui = FormME.MedicationCur.RxCui;
            textMedName.Text       = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName; //The edit button is not visible if MedicationNum=0.
            textGenericName.Text   = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName;    //The edit button is not visible if MedicationNum=0.
            textMedNote.Text       = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes;      //The edit button is not visible if MedicationNum=0.
            textRxNormDesc.Text    = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
        }
示例#32
0
        public async Task <IActionResult> Create([Bind("Din,Name,Image,MedicationTypeId,DispensingCode,Concentration,ConcentrationCode")] Medication medication)
        {
            string MedicationTID = string.Empty;

            if (Request.Cookies["MedicationTypeId"] != null)
            {
                MedicationTID = Request.Cookies["MedicationTypeId"].ToString();
            }
            else if (HttpContext.Session.GetString("MedicationTypeId") != null)
            {
                MedicationTID = HttpContext.Session.GetString("MedicationTypeId");
            }

            var MedicationType = _context.MedicationType.Where(m => m.MedicationTypeId.ToString() == MedicationTID).FirstOrDefault();

            ViewData["MedicationTypeName"] = MedicationType.Name;
            //ViewData["MedicationTypeId"] = MedicationTID;

            var isZeroExist = _context.Medication.Where(a => a.Din == medication.Din);

            if (isZeroExist.Any())
            {
                ModelState.AddModelError("", "There is already a same record for this medication. DIN : " + medication.Din);
            }
            medication.MedicationTypeId = Convert.ToInt32(MedicationTID);

            if (ModelState.IsValid)
            {
                //ModelState.AddModelError("", "There is already a same record for this medication. DIN : " + medication.Din);
                _context.Add(medication);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ConcentrationCode"] = new SelectList(_context.ConcentrationUnit.OrderBy(c => c.ConcentrationCode), "ConcentrationCode", "ConcentrationCode", medication.ConcentrationCode);
            ViewData["DispensingCode"]    = new SelectList(_context.DispensingUnit.OrderBy(d => d.DispensingCode), "DispensingCode", "DispensingCode", medication.DispensingCode);
            ViewData["MedicationTypeId"]  = new SelectList(_context.MedicationType, "MedicationTypeId", "Name", medication.MedicationTypeId);
            return(View(medication));
        }
示例#33
0
        public void GetSelectedItemsTest()
        {
            MedicationGrid target = new MedicationGrid();

            Medication[] items = new Medication[3];
            items[0]            = new Medication();
            items[0].IsSelected = true;
            items[1]            = new Medication();
            items[1].IsSelected = false;
            items[2]            = new Medication();
            items[2].IsSelected = true;

            target.Items.Add(items[0]);
            target.Items.Add(items[1]);
            target.Items.Add(items[2]);

            Medication[] actual;

            actual = target.GetSelectedItems();
            Assert.AreEqual(items[0], actual[0], "NhsCui.Toolkit.Web.MedicationGrid.GetSelectedItems did not return the expected value.");
            Assert.AreEqual(items[2], actual[1], "NhsCui.Toolkit.Web.MedicationGrid.GetSelectedItems did not return the expected value.");
        }
        // HTTP Get
        public IActionResult Create(long id)
        {
            if (!IsLoggedIn())
            {
                return(RedirectToPage("/Account/Login"));
            }

            Infant infant = context.Infants.FirstOrDefault(i => i.InfantId == id);

            if (!IsInfantOwner(infant))
            {
                return(RedirectToPage("/Error/Error404"));
            }

            Medication medication = new Medication
            {
                Date     = DateTime.Now,
                InfantId = id
            };

            return(View("MedicationEditor", MedicationViewModelFactory.Create(medication, infant)));
        }
示例#35
0
        internal Medication buildMedication(RDT rdt)
        {
            Medication med = new Medication();
            med.OrderId = HL7Helper.getString(rdt, 13, 0);
            med.Refills = HL7Helper.getString(rdt, 11, 0);
            med.Quantity = HL7Helper.getString(rdt, 9, 0);
            med.DaysSupply = HL7Helper.getString(rdt, 10, 0);

            med.IssueDate = HL7Helper.getString(rdt, 4, 0);
            med.LastFillDate = HL7Helper.getString(rdt, 5, 0);
            med.StartDate = HL7Helper.getString(rdt, 6, 0);
            med.ExpirationDate = HL7Helper.getString(rdt, 7, 0);

            med.RxNumber = HL7Helper.getString(rdt, 1, 0);
            med.Id = HL7Helper.getString(rdt, 2, 0);

            med.Provider = new Author();
            NHapi.Base.Model.IType provider = ((Varies)rdt.GetField(12, 0)).Data;
            if (provider is GenericComposite)
            {
                GenericComposite gc = (GenericComposite)provider;
                NHapi.Base.Model.IType[] components = gc.Components;
                med.Provider.Id = ((Varies)components[0]).Data.ToString();
                med.Provider.Name = ((Varies)components[1]).Data.ToString() + ", " + ((Varies)components[2]).Data.ToString();
            }
            else
            {
                med.Provider.Id = provider.ToString();
            }

            med.Name = HL7Helper.getString(rdt, 3, 0);
            med.Sig = HL7Helper.getString(rdt, 20, 0);
            med.Detail = HL7Helper.getString(rdt, 19, 0);
            med.Status = HL7Helper.getString(rdt, 8, 0);

            return med;
        }
示例#36
0
        public void NotifyPropertyChangedTest()
        {
            Medication target = new Medication();
            target.MedicationNames.Add(new MedicationName("Name", "Info"));

            target.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.OnPropertyChanged);

            this.propertyChangedThreadEvent.Reset();
            target.CriticalAlertGraphic = "~/images/test.png";
            this.WaitForProperty("CriticalAlertGraphic");

            this.propertyChangedThreadEvent.Reset();
            target.DosageText = "dosageText";
            this.WaitForProperty("DosageText");

            this.propertyChangedThreadEvent.Reset();
            target.Dose = "dose";
            this.WaitForProperty("Dose");

            this.propertyChangedThreadEvent.Reset();
            target.Form = "form";
            this.WaitForProperty("Form");

            this.propertyChangedThreadEvent.Reset();
            target.Frequency = "frequency";
            this.WaitForProperty("Frequency");

            this.propertyChangedThreadEvent.Reset();
            target.IndicatorGraphic = "~/images/test.png";
            this.WaitForProperty("IndicatorGraphic");

            this.propertyChangedThreadEvent.Reset();
            target.IsSelected = true;
            this.WaitForProperty("IsSelected");

            this.propertyChangedThreadEvent.Reset();
            target.MedicationNames[0].Name = "NewName";
            this.WaitForProperty("Name");

            this.propertyChangedThreadEvent.Reset();
            target.MedicationTooltip = "tooltip";
            this.WaitForProperty("MedicationTooltip");

            this.propertyChangedThreadEvent.Reset();
            target.Reason = "reason";
            this.WaitForProperty("Reason");

            this.propertyChangedThreadEvent.Reset();
            target.Route = "route";
            this.WaitForProperty("Route");

            this.propertyChangedThreadEvent.Reset();
            target.StartDate = new DateTime(2007, 1, 1);
            this.WaitForProperty("StartDate");

            this.propertyChangedThreadEvent.Reset();
            target.Status = MedicationStatus.Suspended;
            this.WaitForProperty("Status");

            this.propertyChangedThreadEvent.Reset();
            target.StatusDate = new DateTime(2007, 1, 1);
            this.WaitForProperty("StatusDate");

            this.propertyChangedThreadEvent.Close();
        }
示例#37
0
        public void ReasonTest()
        {
            Medication target = new Medication();

            string val = "reason"; 
            target.Reason = val;
            Assert.AreEqual(val, target.Reason, "NhsCui.Tool kit.Web.Medication.Reason was not set correctly.");            
        }
 public void UpdateMedication(int medicationId, Medication medication)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             var medicationToUpdate = GetMedicationById(medication.PatientId, medicationId);
             if (medicationToUpdate != null)
             {
                 medicationToUpdate.DoseText = medication.DoseText;
                 medicationToUpdate.DoseUnit = medication.DoseUnit;
                 medicationToUpdate.HowTaken = medication.HowTaken;
                 medicationToUpdate.MedicationName = medication.MedicationName;
                 medicationToUpdate.Notes = medication.Notes;
                 medicationToUpdate.ReasonForTaking = medication.ReasonForTaking;
                 medicationToUpdate.StrengthText = medication.StrengthText;
                 medicationToUpdate.StrengthUnit = medication.StrengthUnit;
                 if (medication.EndDate != null)
                     medicationToUpdate.EndDate = medication.EndDate;
                 dataContext.Medications.Attach(medicationToUpdate);
                 dataContext.Entry(medicationToUpdate).State = EntityState.Modified;
                 dataContext.SaveChanges();
             }
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }
示例#39
0
        public void IndicatorGraphicTest()
        {
            Medication target = new Medication();

            string val = "~/images/test.png"; 

            target.IndicatorGraphic = val;
            Assert.AreEqual(val, target.IndicatorGraphic, "NhsCui.Toolkit.Web.Medication.IndicatorGraphic was not set correctly.");            
        }
示例#40
0
        internal Medication[] toMeds(IDataReader reader)
        {
            IList<Medication> results = new List<Medication>();
            while (reader.Read())
            {
                string rxIen = getValue(reader, reader.GetOrdinal("RxOutpatIEN"));
                string siteId = isDbNull(reader, reader.GetOrdinal("Sta3n")) ? "" : ((Int16)reader[reader.GetOrdinal("Sta3n")]).ToString();
                string localPid = getValue(reader, reader.GetOrdinal("PatientIEN"));
                string rxNum = getValue(reader, reader.GetOrdinal("RxNumber"));
                string localDrugIen = getValue(reader, reader.GetOrdinal("LocalDrugIEN"));
                string drugNameWithDose = getValue(reader, reader.GetOrdinal("LocalDrugNameWithDose"));
                string drugNameWithoutDose = getValue(reader, reader.GetOrdinal("DrugNameWithoutDose"));
                string natlDrugIen = getValue(reader, reader.GetOrdinal("NationalDrugIEN"));
                string status = getValue(reader, reader.GetOrdinal("RxStatus"));
                string refills = isDbNull(reader, reader.GetOrdinal("MaxRefills")) ? "" : ((Int16)reader[reader.GetOrdinal("MaxRefills")]).ToString();
                string issueDate = isDbNull(reader, reader.GetOrdinal("IssueDate")) ? "" : ((DateTime)reader[reader.GetOrdinal("IssueDate")]).ToShortDateString();

                Medication med = new Medication()
                {
                    IssueDate = issueDate,
                    Refills = refills,
                    Status = status,
                    Name = drugNameWithDose,
                    Id = localDrugIen,
                    RxNumber = rxNum,
                    Drug = new KeyValuePair<string, string>(localDrugIen, drugNameWithoutDose)
                };

                results.Add(med);
            }
            return results.ToArray<Medication>();
        }
示例#41
0
        public void FormTest()
        {
            Medication target = new Medication();

            string val = "form"; 

            target.Form = val;
            Assert.AreEqual(val, target.Form, "NhsCui.Toolkit.Web.Medication.Form was not set correctly.");            
        }
示例#42
0
        public void DoseTest()
        {
            Medication target = new Medication();

            string val = "dose"; 

            target.Dose = val;
            Assert.AreEqual(val, target.Dose, "NhsCui.Toolkit.Web.Medication.Dose was not set correctly.");            
        }
示例#43
0
		///<summary>Updates one Medication 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(Medication medication,Medication oldMedication){
			string command="";
			if(medication.MedName != oldMedication.MedName) {
				if(command!=""){ command+=",";}
				command+="MedName = '"+POut.String(medication.MedName)+"'";
			}
			if(medication.GenericNum != oldMedication.GenericNum) {
				if(command!=""){ command+=",";}
				command+="GenericNum = "+POut.Long(medication.GenericNum)+"";
			}
			if(medication.Notes != oldMedication.Notes) {
				if(command!=""){ command+=",";}
				command+="Notes = '"+POut.String(medication.Notes)+"'";
			}
			//DateTStamp can only be set by MySQL
			if(medication.RxCui != oldMedication.RxCui) {
				if(command!=""){ command+=",";}
				command+="RxCui = "+POut.Long(medication.RxCui)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE medication SET "+command
				+" WHERE MedicationNum = "+POut.Long(medication.MedicationNum);
			Db.NonQ(command);
			return true;
		}
示例#44
0
 /// <summary>
 /// Constructs a MedicationEventArgs object and passes in the medication. 
 /// </summary>
 /// <param name="medication">The medication to be passed from the event source.</param>
 public MedicationEventArgs(Medication medication)
 {
     this.medication = medication;
 }
示例#45
0
        public void MedicationNamesTest()
        {
            Medication target = new Medication();

            MedicationName item = new MedicationName("Name", "Info");
            target.MedicationNames.Add(item);            
            Assert.AreEqual<MedicationName>(item, target.MedicationNames[0], "NhsCui.Toolkit.Web.Medication.MedicationNames was not set correctly.");            
        }
示例#46
0
        /// <summary>
        /// Add a MedicationNameLabel to the view
        /// </summary>
        /// <param name="medication">Medication to extract MedicationName from</param>
        /// <param name="parent">Parent Panel</param>
        /// <param name="cssClass">CssClass to apply to the MedicationNameLable</param>
        private void AddMedicationNameLabel(Medication medication, Panel parent, string cssClass)
        {   
            MedicationNameLabel medicationNameLabel = new MedicationNameLabel(medication.MedicationNames);
            medicationNameLabel.EnableViewState = false;
            medicationNameLabel.EnableExtender = false;
            medicationNameLabel.ShowGraphics = this.showGraphics;
            medicationNameLabel.CriticalAlertGraphic = medication.CriticalAlertGraphic;
            medicationNameLabel.IndicatorGraphic = medication.IndicatorGraphic;
            medicationNameLabel.AllowWrap = false;
            medicationNameLabel.ToolTip = medication.MedicationTooltip;
            medicationNameLabel.CssClass = cssClass;

            // Add each DrugLabel control
            parent.Controls.Add(medicationNameLabel);            
        }
示例#47
0
        public void MedicationTooltipTest()
        {
            Medication target = new Medication();
            string val = "Tooltip"; 

            target.MedicationTooltip = val;
            Assert.AreEqual(val, target.MedicationTooltip, "NhsCui.Toolkit.Web.Medication.MedicationTooltip was not set correctly.");            
        }
示例#48
0
 /// <summary>
 /// Implement the LoadViewState method. Loads the medication State if saved
 /// </summary>
 /// <param name="savedState">Saved State</param>
 protected override void LoadViewState(object savedState)
 {
     base.LoadViewState(savedState);
     Medication medication = ViewState["Medication"] as Medication;
     if (medication != null)
     {
         this.medication = medication;
     }
 }
示例#49
0
        /// <summary>
        /// Construct an Outpatient Medication MDO from CPRS Meds Tab supplimented with RDV
        /// </summary>
        /// <param name="dfn">Patient identifier used for Medication.Id</param>
        /// <param name="fields">CPRS MedTab fields</param>
        /// <param name="textBlob">Text blob details from CPRS MedTab</param>
        /// <param name="rdvSupplement">Dictionary of OP Medication from RDV call</param>
        /// <returns>OP Medication MDO if supplement is available, null otherwise</returns>
        internal Medication toOutpatientMed(string[] fields, string textBlob, Dictionary<string, Medication> rdvSupplement)
        {
            Medication med = new Medication();
            med.Type = Medication.MedicationType.OUTPATIENT.Code;
            med.Id = fields[1];
            med.Facility = cxn.DataSource.SiteId;
            med.Name = fields[2];
            med.Refills = fields[5];
            med.OrderId = fields[8];
            med.Status = fields[9];
            med.LastFillDate = VistaTimestamp.toUtcString(fields[10]);
            med.DaysSupply = fields[11];
            med.Quantity = fields[12];
            med.IsOutpatient = true;

            string[] textFields = StringUtils.split(textBlob, StringUtils.CRLF);
            if (textFields.Length > 0)
            {
                int index = 0;
                while (!textFields[index].StartsWith("\\"))
                {
                    med.Detail += textFields[index++] + StringUtils.CRLF;
                }

                while (index < textFields.Length && textFields[index] != "")
                {
                    med.Sig += textFields[index++];
                }

                med.Detail = med.Detail.Trim();
                med.Sig = med.Sig.Trim();
            }

            // add the rdv supplemented fields
            // the med id from the rdv call is numeric only, so we have to remove the R;O to find it
            string numericMedId = StringUtils.removeNonNumericChars(med.Id);
            if (rdvSupplement.ContainsKey(numericMedId))
            {
                Medication supplement = rdvSupplement[numericMedId];
                med.RxNumber = supplement.RxNumber;
                med.Drug = supplement.Drug;
                med.Cost = supplement.Cost;
                med.StopDate = supplement.StopDate;
                med.ExpirationDate = supplement.ExpirationDate;
                med.IssueDate = supplement.IssueDate;
                med.Provider = supplement.Provider;
                med.Sig = supplement.Sig;
            }

            return med;
        }
示例#50
0
        public void StatusDateTest()
        {
            Medication target = new Medication();

            DateTime val = new DateTime(2007, 1, 2); 
            target.StatusDate = val;
            Assert.AreEqual(val, target.StatusDate, "NhsCui.Toolkit.Web.Medication.StatusDate was not set correctly.");            
        }
示例#51
0
		///<summary>Updates one Medication in the database.</summary>
		public static void Update(Medication medication){
			string command="UPDATE medication SET "
				+"MedName      = '"+POut.String(medication.MedName)+"', "
				+"GenericNum   =  "+POut.Long  (medication.GenericNum)+", "
				+"Notes        = '"+POut.String(medication.Notes)+"', "
				//DateTStamp can only be set by MySQL
				+"RxCui        =  "+POut.Long  (medication.RxCui)+" "
				+"WHERE MedicationNum = "+POut.Long(medication.MedicationNum);
			Db.NonQ(command);
		}
示例#52
0
        internal Medication[] toIvMedsRdv(string response)
        {
            if (response == "")
            {
                return null;
            }
            string[] lines = StringUtils.split(response, StringUtils.CRLF);
            ArrayList list = new ArrayList();
            Medication rec = null;
            string additives = "";
            string solution = "";
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    continue;
                }
                string[] flds = StringUtils.split(lines[i], StringUtils.CARET);
                int fldnum = Convert.ToInt32(flds[0]);
                switch (fldnum)
                {
                    case 1:
                        if (rec != null)
                        {
                            rec.Additives = additives;
                            rec.Solution = solution;
                            rec.IsInpatient = true;
                            rec.IsIV = true;
                            rec.Type = "IV";
                            list.Add(rec);
                        }
                        rec = new Medication();
                        additives = "";
                        solution = "";
                        if (flds.Length == 2)
                        {
                            string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                            if (parts.Length == 2)
                            {
                                rec.Facility = new SiteId(parts[1], parts[0]);
                            }
                            else if (flds[1] != "")
                            {
                                rec.Facility = new SiteId(cxn.DataSource.SiteId.Id, flds[1]);
                            }
                            else
                            {
                                rec.Facility = cxn.DataSource.SiteId;
                            }
                        }
                        break;
                    case 2:
                        if (flds.Length == 2)
                        {
                            additives += !String.IsNullOrEmpty(additives) ? "\n" : "";
                            additives += flds[1];

                            // we decided that "  " separates the dose from the drug
                            rec.Dose = flds[1].Substring(flds[1].LastIndexOf("  ") + 2);
                        }
                        break;
                    case 3:
                        if (flds.Length == 2)
                        {
                            solution += !String.IsNullOrEmpty(solution) ? "\n" : "";
                            solution += flds[1];
                        }
                        break;
                    case 4:
                        if (flds.Length == 2)
                        {
                            rec.Rate = flds[1];
                        }
                        break;
                    case 5:
                        if (flds.Length == 2)
                        {
                            rec.Schedule = flds[1];
                        }
                        break;
                    case 6:
                        if (flds.Length == 2)
                        {
                            rec.StartDate = VistaTimestamp.toUtcFromRdv(flds[1]);
                        }
                        break;
                    case 7:
                        if (flds.Length == 2)
                        {
                            rec.StopDate = VistaTimestamp.toUtcFromRdv(flds[1]);
                        }
                        break;
                }
            }
            if (rec != null)
            {
                rec.Additives = additives;
                rec.Solution = solution;
                rec.IsInpatient = true;
                rec.IsIV = true;
                rec.Type = "IV";
                list.Add(rec);
            }

            return (Medication[])list.ToArray(typeof(Medication));
        }
示例#53
0
        public void FrequencyTest()
        {
            Medication target = new Medication();

            string val = "frequency"; 

            target.Frequency = val;
            Assert.AreEqual(val, target.Frequency, "NhsCui.Toolkit.Web.Medication.Frequency was not set correctly.");            
        }
示例#54
0
        public void IsSelectedTest()
        {
            Medication target = new Medication();

            bool val = false; 
            target.IsSelected = val;
            Assert.AreEqual(val, target.IsSelected, "NhsCui.Toolkit.Web.Medication.IsSelected was not set correctly.");            
        }
示例#55
0
        public void RouteTest()
        {
            Medication target = new Medication();

            string val = "route"; 
            target.Route = val;
            Assert.AreEqual(val, target.Route, "NhsCui.Toolkit.Web.Medication.Route was not set correctly.");            
        }
示例#56
0
        /// <summary>
        /// Parse the XML document
        /// </summary>
        /// <param name="filter">Enum StatusFilter</param>
        /// <param name="familyName">Family Name of the Patien</param>
        /// <returns>Collection of Medication</returns>
        public Medication[] Parse(StatusFilter filter, string familyName)
        {
            List<Medication> medicationList = new List<Medication>();

            ////XmlNodeList medicationNodes = this.xmlDom.SelectNodes("/Patients/Patient/Medications/Medication");
            ////Get medications for a specific patient
            XmlNodeList medicationNodes = this.xmlDom.SelectNodes("//Medication[ancestor::*/@FamilyName='" + familyName + "']");
            bool medicationValid = false;

            int index = 1;
            if (medicationNodes.Count > 0)
            {
                foreach (XmlNode medicationNode in medicationNodes)
                {
                    switch (filter)
                    {
                        case StatusFilter.Full:
                            medicationValid = true;
                            break;
                        case StatusFilter.Active:
                            if ((MedicationStatus)Enum.Parse(typeof(MedicationStatus), this.GetAttribute(medicationNode, "Status")) == MedicationStatus.Active)
                            {
                                medicationValid = true;
                            }

                            break;
                        case StatusFilter.Suspended:
                            if ((MedicationStatus)Enum.Parse(typeof(MedicationStatus), this.GetAttribute(medicationNode, "Status")) == MedicationStatus.Suspended)
                            {
                                medicationValid = true;
                            }

                            break;
                    }

                    if (medicationValid)
                    {
                        Medication medication = new Medication();
                        XmlNodeList medicationNameNodes = medicationNode.SelectNodes("MedicationNames/MedicationName");
                        foreach (XmlNode medicationNameNode in medicationNameNodes)
                        {
                            medication.MedicationNames.Add(new MedicationName(this.GetAttribute(medicationNameNode, "Name"), this.GetAttribute(medicationNameNode, "Information")));
                            index++;
                        }

                        medication.CriticalAlertGraphic = this.GetAttribute(medicationNode, "CriticalAlertGraphic");
                        medication.IndicatorGraphic = this.GetAttribute(medicationNode, "IndicatorGraphic");
                        medication.Dose = this.GetAttribute(medicationNode, "Dose");
                        medication.Form = this.GetAttribute(medicationNode, "Form");
                        medication.Frequency = this.GetAttribute(medicationNode, "Frequency");
                        medication.Reason = this.GetAttribute(medicationNode, "Reason");
                        medication.Route = this.GetAttribute(medicationNode, "Route");
                        medication.MedicationTooltip = this.GetAttribute(medicationNode, "ToolTip");

                        medication.StartDate = DateTime.ParseExact(
                                                                    this.GetAttribute(medicationNode, "StartDate"),
                                                                    new string[] { "dd-MMM-yy", "dd/mm/yyyy" },
                                                                    CultureInfo.CurrentCulture,
                                                                    DateTimeStyles.None);

                        string statusDate = this.GetAttribute(medicationNode, "StatusDate");
                        if (!string.IsNullOrEmpty(statusDate))
                        {
                            medication.StatusDate = DateTime.ParseExact(
                                                                    statusDate,
                                                                    new string[] { "dd-MMM-yy", "dd/mm/yyyy" },
                                                                    CultureInfo.CurrentCulture,
                                                                    DateTimeStyles.None);
                        }

                        medication.Status = (MedicationStatus)Enum.Parse(typeof(MedicationStatus), this.GetAttribute(medicationNode, "Status"));
                        medicationList.Add(medication);
                    }

                    medicationValid = false;
                }
            }

            return medicationList.ToArray();
        }
示例#57
0
		///<summary>Converts one Medication object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
		internal static Medicationm ConvertToM(Medication medication){
			Medicationm medicationm=new Medicationm();
			//CustomerNum cannot be set.  Remains 0.
			medicationm.MedicationNum=medication.MedicationNum;
			medicationm.MedName      =medication.MedName;
			medicationm.GenericNum   =medication.GenericNum;
			medicationm.RxCui        =medication.RxCui;
			return medicationm;
		}
 public void SaveMedication(Medication medication)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             medication.UniqueIdentifier = this.uniqueGuid;
             dataContext.Medications.Add(medication);
             dataContext.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
     }
 }
示例#59
0
 internal Medication[] toOtherMedsRdv(string response)
 {
     if (response == "")
     {
         return null;
     }
     string[] lines = StringUtils.split(response, StringUtils.CRLF);
     ArrayList list = new ArrayList();
     Medication rec = null;
     string sig = "";
     string comment = "";
     for (int i = 0; i < lines.Length; i++)
     {
         if (lines[i] == "")
         {
             continue;
         }
         string[] flds = StringUtils.split(lines[i], StringUtils.CARET);
         int fldnum = Convert.ToInt32(flds[0]);
         switch (fldnum)
         {
             case 1:
                 if (rec != null)
                 {
                     rec.Comment = comment;
                     rec.Sig = sig;
                     rec.Type = "NV";
                     list.Add(rec);
                 }
                 rec = new Medication();
                 rec.IsOutpatient = true;
                 rec.IsNonVA = true;
                 sig = "";
                 comment = "";
                 if (flds.Length == 2)
                 {
                     string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                     if (parts.Length == 2)
                     {
                         rec.Facility = new SiteId(parts[1], parts[0]);
                     }
                     else if (flds[1] != "")
                     {
                         rec.Facility = new SiteId(cxn.DataSource.SiteId.Id, flds[1]);
                     }
                     else
                     {
                         rec.Facility = cxn.DataSource.SiteId;
                     }
                 }
                 break;
             case 2:
                 if (flds.Length == 2)
                 {
                     rec.Name = flds[1];
                 }
                 break;
             case 3:
                 if (flds.Length == 2)
                 {
                     rec.Status = flds[1];
                 }
                 break;
             case 4:
                 if (flds.Length == 2)
                 {
                     rec.StartDate = VistaTimestamp.toUtcFromRdv(flds[1]);
                 }
                 break;
             case 5:
                 if (flds.Length == 2)
                 {
                     rec.DateDocumented = VistaTimestamp.toUtcFromRdv(flds[1]);
                 }
                 break;
             case 6:
                 if (flds.Length == 2)
                 {
                     rec.Documentor = new Author("", flds[1], "");
                 }
                 break;
             case 7:
                 if (flds.Length == 2)
                 {
                     rec.StopDate = VistaTimestamp.toUtcFromRdv(flds[1]);
                 }
                 break;
             case 8:
                 if (flds.Length == 2)
                 {
                     sig += !String.IsNullOrEmpty(sig) ? "\n" : "";
                     sig += flds[1];
                 }
                 break;
             case 10:
                 if (flds.Length == 2)
                 {
                     comment += !String.IsNullOrEmpty(comment) ? "\n" : "";
                     comment += flds[1];
                 }
                 break;
         }
     }
     if (rec != null)
     {
         rec.Comment = comment;
         rec.Sig = sig;
         rec.Type = "NV";
         list.Add(rec);
     }
     return (Medication[])list.ToArray(typeof(Medication));
 }
示例#60
0
 public void StatusTest()
 {
     Medication target = new Medication();            
     MedicationStatus val = MedicationStatus.Suspended;            
     target.Status = val;
     Assert.AreEqual(val, target.Status, "NhsCui.Toolkit.Web.Medication.Status was not set correctly.");            
 }