예제 #1
0
        public JObject Fill(PrescriptionType pt)
        {
            if (pt is null)
            {
                return(null);
            }

            var prescriptionType = new JObject(
                new JProperty("id", pt.Id),
                new JProperty("name", pt.Name));

            return(prescriptionType);
        }
예제 #2
0
        public ActionResult AddPrescriptionType(AddPrescriptionTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var db   = new ApplicationDbContext();
            var type = new PrescriptionType
            {
                Type = model.Type
            };

            db.PrescriptionTypes.Add(type);
            db.SaveChanges();
            return(RedirectToAction("AddPrescription"));
        }
예제 #3
0
        public void RemoveWord(int length, int numberOfLetter, PrescriptionType prescriptionType)
        {
            foreach (ISentence sentence in this.GetSentences())
            {
                List <Word> words = sentence.Items.OfType <Word>()
                                    .Where(item => item.Length == length && item.Length > numberOfLetter).ToList();

                for (int i = 0; i < words.Count(); i++)
                {
                    AlphabetItem alphabetItem = Alphabet.GetAlpabetItem(words[i].Items[0]);
                    if (alphabetItem.Equals(default(AlphabetItem)) == false && alphabetItem.PrescriptionType == prescriptionType)
                    {
                        sentence.RemoveItem(words[i]);
                    }
                }
            }
        }
예제 #4
0
        public bool Remove()
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    Log.Info(TAG, "Remove: Attempting to Remove Medication with ID - " + ID.ToString());
                    var sql = @"DELETE FROM [Medication] WHERE ID = " + ID.ToString();
                    sqlDatabase.ExecSQL(sql);
                    Log.Info(TAG, "Remove: Removed Medication with ID " + ID.ToString());
                    if (MedicationSpread != null && MedicationSpread.Count > 0)
                    {
                        foreach (var spread in MedicationSpread)
                        {
                            Log.Info(TAG, "Remove: Removing Spread with ID - " + spread.ID.ToString());
                            spread.Remove();
                        }
                        if (PrescriptionType != null)
                        {
                            Log.Info(TAG, "Remove: Removing Prescription Type with ID - " + PrescriptionType.ID.ToString());
                            PrescriptionType.Remove();
                            PrescriptionType = new Prescription();
                        }
                        sqlDatabase.Close();
                        return(true);
                    }
                }
                Log.Error(TAG, "Remove: SQLite database is null or was not open - remove failed");
                return(false);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Remove: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
                return(false);
            }
        }
예제 #5
0
        public bool Save()
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null)
                {
                    if (sqlDatabase.IsOpen)
                    {
                        if (IsNew)
                        {
                            Log.Info(TAG, "Save: New Medication item to Save...");
                            ContentValues values = new ContentValues();
                            values.Put("MedicationName", MedicationName.Trim());
                            values.Put("TotalDailyDosage", TotalDailyDosage);
                            ID = (int)sqlDatabase.Insert("Medication", null, values);
                            Log.Info(TAG, "Save: Successfully saved - ID - " + ID.ToString());
                            IsNew   = false;
                            IsDirty = false;
                            if (MedicationSpread != null && MedicationSpread.Count > 0)
                            {
                                foreach (var spread in MedicationSpread)
                                {
                                    spread.Save(spread.ID, ID);
                                    Log.Info(TAG, "Save (insert): Saved Medication Spread with ID - " + spread.ID.ToString());
                                }
                            }
                            if (PrescriptionType != null)
                            {
                                PrescriptionType.Save(ID);
                                Log.Info(TAG, "Save (insert): Saved Prescription Type ID - " + ID.ToString());
                            }
                        }
                        if (IsDirty)
                        {
                            Log.Info(TAG, "LoadMedicationSpreads: Exisitng Medication to Update with ID - " + ID.ToString());
                            ContentValues values = new ContentValues();
                            values.Put("MedicationName", MedicationName.Trim());
                            values.Put("TotalDailyDosage", TotalDailyDosage);
                            string whereClause = "ID = ?";
                            sqlDatabase.Update("Medication", values, whereClause, new string[] { ID.ToString() });
                            Log.Info(TAG, "Save (update): Updated Medication with ID - " + ID.ToString());
                            IsDirty = false;
                            if (MedicationSpread != null && MedicationSpread.Count > 0)
                            {
                                foreach (var spread in MedicationSpread)
                                {
                                    spread.Save(spread.ID, ID);
                                    Log.Info(TAG, "Save (update): Saved Medication Spread with ID - " + spread.ID.ToString());
                                }
                            }
                            if (PrescriptionType != null)
                            {
                                PrescriptionType.Save(ID);
                                Log.Info(TAG, "Save (Update): Saved Prescription type with ID - " + PrescriptionType.ID.ToString());
                            }
                        }
                        sqlDatabase.Close();
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Save: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
                return(false);
            }
        }
예제 #6
0
 public Prescription(PrescriptionType type, string from, string to)
 {
     Type          = type;
     NamespaceFrom = from;
     NamespaceTo   = to;
 }
예제 #7
0
 public AlphabetItem(char item, LetterType letterType, PrescriptionType prescriptionType)
 {
     _item             = item;
     _letterType       = letterType;
     _prescriptionType = prescriptionType;
 }