Example #1
0
        // GET: Presciption REST API
        public ActionResult DisplayAllMedication()
        {
            try
            {
                var requestUrl = $"https://localhost:44315/api/Medications";
                var result     = new WebClient().DownloadString(requestUrl);
                var jo         = JArray.Parse(result);
                List <MedicationViewModel> ListOfMedication = new List <MedicationViewModel>();

                for (int i = 0; i < jo.Count; i++)
                {
                    MedicationViewModel medication = new MedicationViewModel();
                    medication.Id          = Convert.ToInt32(jo[i]["Id"]);
                    medication.Name        = jo[i]["Name"].ToString();
                    medication.Description = jo[i]["Description"].ToString();
                    medication.SideEffect  = jo[i]["SideEffect"].ToString();
                    medication.TimeOfDay   = jo[i]["TimeOfDay"].ToString();
                    medication.Treatment   = jo[i]["Treatment"].ToString();
                    ListOfMedication.Add(medication);
                }
                return(View(ListOfMedication));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public ActionResult CreateMedication(int recNo)
        {
            var medication = _patientrecordservices.GetMedication(recNo);

            var medicationModel = new MedicationViewModel()
            {
                RecordNo     = recNo,
                RecordedDate = DateTime.Now,
                Medication   = medication != null ? medication.MedicationDesc : String.Empty
            };

            if (medication != null)
            {
                medicationModel.operation = 1;
                medicationModel.Id        = (int)medication.MidNo;
            }
            else
            {
                medicationModel.operation = 0;
            }

            //medicationModel.operation = medication != null ? 1 : 0;

            return(PartialView("_CreateMedication", medicationModel));
        }
Example #3
0
        public ActionResult CreateMedication(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
            };

            if (viewModel.operation == 0)
            {
                _patientrecordservices.AddMedication(medication);
            }
            else
            {
                _patientrecordservices.UpdateMedication(medication);
            }

            _unitofwork.Commit();

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public ActionResult Medication()
        {
            int     patientId = _identityProvider.GetAuthenticatedUserId();
            Patient patient   = _patientRepository.GetPatient(patientId);
            IEnumerable <Visitation> visitationsForPatient = _visitationManagementService.GetVisitationsForPatient(patientId);
            MedicationViewModel      medicationViewModel   = new MedicationViewModel {
                Patient = patient, Medications = new List <SingleMedicationModel>()
            };

            foreach (Visitation visitation in visitationsForPatient)
            {
                IEnumerable <Medication> medicationsForVisitation = _visitationManagementService.GetMedicationsForVisitation(visitation.VisitationId);
                foreach (Medication medication in medicationsForVisitation)
                {
                    SingleMedicationModel singleMedication = new SingleMedicationModel
                    {
                        DateTime   = visitation.DateTime,
                        Reason     = visitation.Reason,
                        Medication = medication
                    };
                    medicationViewModel.Medications.Add(singleMedication);
                }
            }
            return(View(medicationViewModel));
        }
Example #5
0
        public async Task <IActionResult> Upsert(int?id)
        {
            ViewBag.residentId = TempData["id"];
            IEnumerable <Resident> residentList = await _reRepo.GetAllAsync(SD.ResidentAPIPath, HttpContext.Session.GetString("JWToken"));

            MedicationViewModel objVM = new MedicationViewModel()
            {
                ResidentList = residentList.Select(i => new SelectListItem()
                {
                    Text  = i.FirstName + " " + i.LastName,
                    Value = i.Id.ToString()
                }),
                Medication = new Medication()
            };

            if (id == null)
            {
                // This will be true for Insert / Create
                return(View(objVM));
            }
            // Flow will come here for Update
            objVM.Medication = await _meRepo.GetAsync(SD.MedicationAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (objVM.Medication == null)
            {
                return(NotFound());
            }
            return(View(objVM));
        }
Example #6
0
        public async Task <IActionResult> Upsert(MedicationViewModel obj)
        {
            if (ModelState.IsValid)
            {
                if (obj.Medication.Id == 0)
                {
                    await _meRepo.CreateAsync(SD.MedicationAPIPath, obj.Medication, HttpContext.Session.GetString("JWToken"));
                }
                else
                {
                    await _meRepo.UpdateAsync(SD.MedicationAPIPath + obj.Medication.Id, obj.Medication, HttpContext.Session.GetString("JWToken"));
                }
                if (TempData["residentId"] != null)
                {
                    return(RedirectToAction("Index", "Medications", new { residentId = TempData["residentId"] }));
                }
                else
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            IEnumerable <Resident> residentList = await _reRepo.GetAllAsync(SD.ResidentAPIPath, HttpContext.Session.GetString("JWToken"));

            MedicationViewModel objVM = new MedicationViewModel()
            {
                ResidentList = residentList.Select(i => new SelectListItem()
                {
                    Text  = i.FirstName + " " + i.LastName,
                    Value = i.Id.ToString()
                }),
                Medication = new Medication()
            };

            return(View(objVM));
        }
Example #7
0
        public ActionResult Edit(int id, int medicalRecordId)
        {
            MedicationViewModel medicationViewModel = medicationRepository.GetById(id).ToViewModel();

            medicationViewModel.MedicalRecordEntryViewModel = medicalRecordEntryRepository.GetById(medicalRecordId).ToViewModel();
            AddMedicalRecordToTempData(medicalRecordId);
            return(View(medicationViewModel));
        }
Example #8
0
        public ActionResult Create(int medicalRecordId)
        {
            AddMedicalRecordToTempData(medicalRecordId);
            TempData.Keep();
            MedicationViewModel medicationViewModel = new MedicationViewModel {
                MedicalRecordEntryViewModel = medicalRecordEntryRepository.GetById(medicalRecordId).ToViewModel()
            };

            return(View(medicationViewModel));
        }
Example #9
0
        public IActionResult Post([FromBody] MedicationViewModel medicationViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _medicationService.InsertMedication(medicationViewModel);

            return(Ok(medicationViewModel));
        }
        public static Medication ToDomainModel(this MedicationViewModel medicationViewModel)
        {
            Medication medication = new Medication();

            medication.Id                 = medicationViewModel.Id;
            medication.Prescribed         = medicationViewModel.Prescribed;
            medication.Administered       = medicationViewModel.Administered;
            medication.Renewed            = medicationViewModel.Renewed;
            medication.Allergies          = medicationViewModel.Allergies;
            medication.MedicalRecordEntry = medicationViewModel.MedicalRecordEntryViewModel.ToDomainModel();

            return(medication);
        }
Example #11
0
        public static MedicationEntryViewModel CreateTriggerEntry()
        {
            var dat = new MedicationViewModel { MediType = "StandigeMedikamente" };
            dat.Fields["Verordnetab"] = DateTime.Now.AddDays(-10);

            var mediEntry = new MedicationEntryViewModel
            {
                Medications =
                    new ObservableCollection<MedicationViewModel> { dat }
            };

            return mediEntry;
        }
Example #12
0
 public ActionResult Create(MedicationViewModel medicationViewModel)
 {
     medicationViewModel.MedicalRecordEntryViewModel = medicalRecordEntryRepository.GetById((int)TempData["medicalRecordId"]).ToViewModel();
     AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);
     TempData.Keep();
     if (ModelState.IsValid)
     {
         AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);
         medicationRepository.Add(medicationViewModel.ToDomainModel());
         return(RedirectToAction("Index", new { medicalRecordId = medicationViewModel.MedicalRecordEntryViewModel.Id }));
     }
     AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);
     return(View(medicationViewModel));
 }
Example #13
0
        public ActionResult Edit(MedicationViewModel medicationViewModel, int medicalRecordId)
        {
            medicationViewModel.MedicalRecordEntryViewModel = medicalRecordEntryRepository.GetById(medicalRecordId).ToViewModel();
            AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);

            if (ModelState.IsValid)
            {
                AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);
                medicationRepository.Update(medicationViewModel.ToDomainModel());
                return(RedirectToAction("Index", new { medicalRecordId = medicationViewModel.MedicalRecordEntryViewModel.Id }));
            }
            AddMedicalRecordToTempData(medicationViewModel.MedicalRecordEntryViewModel.Id);
            return(View(medicationViewModel));
        }
        public ActionResult Medications(string ID)
        {
            SearchViewModel            m = new SearchViewModel();
            List <MedicationViewModel> medicationList = new List <MedicationViewModel>();

            var client = new FhirClient("http://fhirtest.uhn.ca/baseDstu1");

            //search patients based on patientID clicked
            Bundle resultsPatients = client.Search <Patient>(new string[] { "_id=" + ID });


            //gets patient based on ID
            foreach (var entry in resultsPatients.Entries)
            {
                ResourceEntry <Patient> patient = (ResourceEntry <Patient>)entry;

                m = getPatientInfo(patient);
            }

            Bundle resultsMedications = client.Search <MedicationPrescription>(new string[] { "patient._id=" + ID });

            foreach (var entry in resultsMedications.Entries)
            {
                m.MedicationCount++;
                MedicationViewModel meds = new MedicationViewModel();
                ResourceEntry <MedicationPrescription> medication = (ResourceEntry <MedicationPrescription>)entry;

                //get name of medication
                meds.MedicationName = medication.Resource.Medication.Display;

                //get date medication was prescribed
                if (medication.Resource.DateWrittenElement == null)
                {
                    meds.IsActive = "Unknown";
                }
                else
                {
                    meds.IsActive = medication.Resource.DateWrittenElement.Value;
                }
                medicationList.Add(meds);
            }

            m.Medications = medicationList;

            patients.Add(m);

            return(View(patients));
        }
        //This method add medication to patient


        public ActionResult Create(int patientId)
        {
            var thePatient = _context.Patients.SingleOrDefault(p => p.Id == patientId);

            if (thePatient == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new MedicationViewModel
            {
                Patient = thePatient
            };

            return(View("MedicationForm", viewModel));
        }
Example #16
0
        public static MedicationEntryViewModel CreateSampleEntry()
        {
            var dat = new MedicationViewModel {
                MediType = "StandigeMedikamente"
            };

            dat.Fields["Verordnetab"] = DateTime.Now.AddDays(-10);

            var mediEntry = new MedicationEntryViewModel
            {
                Medications =
                    new System.Collections.ObjectModel.ObservableCollection <MedicationViewModel> {
                    dat
                }
            };

            return(mediEntry);
        }
        public ActionResult Edit(int patientId, int medicationId)
        {
            var medication = _context.Medications.SingleOrDefault(m => m.Id == medicationId);
            var patient    = _context.Patients.SingleOrDefault(p => p.Id == patientId);

            //check if medicaion exists
            if (medication == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new MedicationViewModel
            {
                Medication = medication,
                Patient    = patient
            };

            return(View("MedicationForm", viewModel));
        }
        public async Task <IActionResult> Details(long id)
        {
            if (!IsLoggedIn())
            {
                return(RedirectToPage("/Account/Login"));
            }

            Medication medication = await context.Medications.Include(m => m.Infant).FirstOrDefaultAsync(m => m.MedicationId == id);

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

            Infant infant             = medication.Infant;
            MedicationViewModel model = MedicationViewModelFactory.Details(medication, infant);

            return(View("MedicationEditor", model));
        }
Example #19
0
        public void ShouldFailIfQuantityIsLessThanOne()
        {
            //Arrange
            MedicationViewModel medicationViewModel = new MedicationViewModel()
            {
                CreationDate = DateTime.Now,
                Quantity     = 0
            };


            MedicationController controller = new MedicationController(_medicationService);

            var result = controller.Post(medicationViewModel);


            //Act

            //Assert
        }
Example #20
0
        public MedicationViewModel Convert(Drug drug)
        {
            try
            {
                MedicationViewModel medicationViewModel = null;

                if (drug != null)
                {
                    medicationViewModel            = new MedicationViewModel();
                    medicationViewModel.DrugId     = drug.Id;
                    medicationViewModel.DrugName   = drug.DrugName;
                    medicationViewModel.LexiDrugId = drug.LexiDrugId;
                }

                return(medicationViewModel);
            }
            catch (Exception exception)
            {
                throw new Exception("Convert drug > medicationViewModel failed!", exception);
            }
        }
Example #21
0
        public void UpdateMedication(MedicationViewModel medication)
        {
            var map = _autoMapper.Map <Medication>(medication);

            _medicationRepository.UpdateMedication(map);
        }
Example #22
0
 public MedicationPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new MedicationViewModel();
 }
Example #23
0
        public IActionResult UpdateMedication([FromBody] MedicationViewModel medicationViewModel)
        {
            _medicationService.UpdateMedication(medicationViewModel);

            return(NoContent());
        }
Example #24
0
        private static FrameworkElement BuildMediView(MedicationViewModel medication)
        {
            if (medication == null)
                return new TextBlock { Text = "Dont support this Type " + DateTime.Now };
            if (medication.MediType == "StandigeMedikamente")
            {
                //var path = @"E:\PROMOVA\src\trunk_espas_newPrcs\Promova.DynamicXaml\ModernMedication\StandigeMedikamente.xaml";
                

                //var stream = File.OpenRead(path
                //    );
                //var control = XamlReader.Load(stream);

                //return control as FrameworkElement;

                
                return new StandigeMedikamente { DataContext = medication };
            }

            return new TextBlock { Text = "Dont support this Type" };
        }