// GET: Patient/Edit/5
        public ActionResult Create(FormCollection collection)
        {
            string MedicineName = collection.Get("name");
            var    patient      = (Patient)TempData["patient"];
            var    doctor       = (Doctor)TempData["doctor"];

            DateTime          start             = DateTime.Parse(collection.Get("start"));
            DateTime          end               = DateTime.Parse(collection.Get("end"));
            var               prescription      = (Prescription)TempData["prescription"];
            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();

            MedicineTimes        medicine  = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);
            List <MedicineTimes> medicines = new List <MedicineTimes>();


            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames    = MedicinesNames;
            TempData["viewModel"]    = viewModel;
            TempData["prescription"] = prescription;
            TempData["doctor"]       = doctor;
            TempData["medicines"]    = medicines;
            return(RedirectToAction("Edit"));
        }
        public ActionResult Edit(FormCollection collection)
        {
            var      doctor       = (Doctor)TempData["doctor"];
            var      patient      = (Patient)TempData["patient"];
            var      medicines    = (List <MedicineTimes>)TempData["medicines"];
            var      prescription = (Prescription)TempData["prescription"];
            string   MedicineName = collection.Get("name");
            DateTime start        = new DateTime();
            DateTime end          = new DateTime();

            if (!DateTime.TryParse(collection.Get("start"), out start) && !DateTime.TryParse(collection.Get("end"), out end) || MedicineName == "" && Request.Form["Add"] == null)
            {
                TempData["prescription"] = prescription;
                TempData["medicines"]    = medicines;
                return(RedirectToAction("Check", "Interactions"));
            }

            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();
            MedicineTimes     medicine          = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);

            //PrescriptionMedicine rm = new PrescriptionMedicine(patient.TZ,MedicineNames, start, end);
            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames = MedicinesNames;
            TempData["viewModel"] = viewModel;

            return(RedirectToAction("Edit"));
        }
示例#3
0
 public void AddMedicine(List <MedicineTimes> medicines, MedicineTimes medicine)
 {
     medicines.Add(medicine);
 }
示例#4
0
 public PrescriptionMedicineViewModel(MedicineTimes rm)
 {
     this.prescriptionMedicine = rm;
 }
示例#5
0
        public List <string> Getinteractions(List <MedicineTimes> medicines, Prescription prescription)
        {
            List <string> ndc          = new List <string>();
            List <string> descriptions = new List <string>();
            //List<PrescriptionMedicine> medicines = new List<PrescriptionMedicine>();
            List <Medicine> OverlapMedicines = new List <Medicine>();
            //foreach (var item in medicines)
            //{
            //    medicines.Add(item);
            //}
            Patient    patient = new Patient();
            PatientDal dal     = new PatientDal();

            patient = dal.GetPatientByTZ(prescription.PatientTZ);
            List <MedicineTimes> medicineTimes = new List <MedicineTimes>(medicines);

            foreach (var item in GetPatientMedicines(patient))
            {
                MedicineTimes medicine = new MedicineTimes(GetMedicineByName(item.Name), item.StartTime, item.EndTime);
                medicineTimes.Add(medicine);
            }

            foreach (var item1 in medicines)
            {
                bool overlapping = false;
                foreach (var item2 in medicines)
                {
                    if (item1 != item2 && item1.StartTime <= item2.EndTime && item1.EndTime >= item2.StartTime)
                    {
                        overlapping = true;
                        Medicine medicine = new Medicine(GetMedicineByName(item2.MyMedicine.ProprietaryName));
                        OverlapMedicines.Add(medicine);
                    }
                }
                if (overlapping)
                {
                    Medicine medicine = new Medicine(GetMedicineByName(item1.MyMedicine.ProprietaryName));
                    OverlapMedicines.Add(medicine);
                }
            }

            foreach (var item in OverlapMedicines)
            {
                var httpRequest = (HttpWebRequest)WebRequest.Create("https://rxnav.nlm.nih.gov/REST/rxcui?idtype=NDC&id=" + item.NDC);

                //geting the response from the request url
                var response = (HttpWebResponse)httpRequest.GetResponse();

                //create a stream to hold the contents of the response (in this case it is the contents of the XML file
                var receiveStream = response.GetResponseStream();

                //creating XML document
                var mySourceDoc = new XmlDocument();

                //load the file from the stream
                mySourceDoc.Load(receiveStream);

                //close the stream
                receiveStream.Close();
                XmlNodeList elemList = mySourceDoc.GetElementsByTagName("rxnormId");
                ndc.Add(elemList[0].InnerText);
            }

            string url = "https://rxnav.nlm.nih.gov/REST/interaction/list?rxcuis=";

            foreach (var item in ndc)
            {
                url += (item + "+");
            }
            url = url.Substring(0, url.Length - 1);
            var HttpRequest   = (HttpWebRequest)WebRequest.Create(url);
            var Response      = (HttpWebResponse)HttpRequest.GetResponse();
            var ReceiveStream = Response.GetResponseStream();
            var MySourceDoc   = new XmlDocument();

            MySourceDoc.Load(ReceiveStream);
            ReceiveStream.Close();
            XmlNodeList ElemList = MySourceDoc.GetElementsByTagName("description");

            for (int i = 0; i < ElemList.Count; i++)
            {
                descriptions.Add(ElemList[i].InnerText);
            }
            List <string> interactions = descriptions.Distinct().ToList();

            return(interactions);
        }
 public void AddMedicine(List <MedicineTimes> medicine, MedicineTimes prescription)
 {
     bl.AddMedicine(medicine, prescription);
 }