public IActionResult Put(int id, [FromBody] MedicationPlan value) { //Check for bad request if (value == null || value.MedicationPlanId != id) { return(BadRequest()); } //Get plan from collection MedicationPlan plan = _plans.GetPlan(id); if (plan == null) { return(NotFound()); } //Update values plan.PatientId = value.PatientId; plan.PhysicianId = value.PhysicianId; plan.SteadyMedId = value.SteadyMedId; plan.HourlyInterval = value.HourlyInterval; plan.PillsPerInterval = value.PillsPerInterval; plan.Completed = value.Completed; return(new NoContentResult()); }
public async Task <IActionResult> CreateMedicationPlan(PatientViewModel model) { if (model == null) { RedirectToAction("Index", "Physician"); } MedicationPlan plan = new MedicationPlan(); plan.MedicationPlanId = 10; plan.PhysicianId = model.PhysicianId; plan.PatientId = model.PatientId; plan.Medication = model.NewMedPlan.Medication; plan.HourlyInterval = model.NewMedPlan.HourlyInterval; plan.PillsPerInterval = model.NewMedPlan.PillsPerInterval; plan.Completed = false; var jsonRequest = JsonConvert.SerializeObject(plan); var buffer = System.Text.Encoding.UTF8.GetBytes(jsonRequest); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); var result = _client.PostAsync(MEDICATION_PLAN_URL, byteContent); return(RedirectToAction("Index", "Physician")); }
public Boolean CreateMedicationPlan(MedicationPlan createPlan) { var jsonRequest = JsonConvert.SerializeObject(createPlan); var buffer = System.Text.Encoding.UTF8.GetBytes(jsonRequest); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); var result = _client.PostAsync(MEDICATION_PLAN_URL, byteContent); return(result.IsCompletedSuccessfully ? true : false); }
//Index that retrieves the medication plan and then creates and returns the view model. public async Task <IActionResult> Index(int medicationPlanId) { HttpResponseMessage response = await _client.GetAsync(MEDICATION_PLAN_SERVICE_URL); if (response.IsSuccessStatusCode) { var responseBody = await response.Content.ReadAsStringAsync(); MedicationPlan medicationPlan = JsonConvert.DeserializeObject <MedicationPlan>(responseBody); return(View(medicationPlan)); } return(NotFound()); }
public IActionResult Post([FromBody] MedicationPlan plan) { if (plan == null) { return(BadRequest()); } if (!_plans.AddPlan(plan)) { return(BadRequest()); } return(CreatedAtRoute("GetPlan", new { id = plan.MedicationPlanId }, plan)); }
public void SaveData() { MedicationPlan medPlan = new MedicationPlan(); medPlan.TokenId = SelectedToken.Id; medPlan.CompartmentNbr = Compartment; medPlan.Critical = Critical; medPlan.DeviceId = SelectedDevice.Id; medPlan.DosageId = SelectedDosage.Id; medPlan.ValidFrom = ValidFrom; medPlan.Validto = ValidTo; using (var context = new MedicalDataManagerDataBaseContainer()) { context.MedicationPlans.Add(medPlan); context.SaveChanges(); } }
//[Authorize] public async Task <IActionResult> CreateMedicationPlan(PatientViewModel model) { if (model == null) { RedirectToAction("Index", "Physician"); } MedicationPlan plan = new MedicationPlan(); plan.MedicationPlanId = 10; plan.PhysicianId = model.CurrentPhysician.ID; plan.PatientId = model.PatientId; plan.SteadyMedId = model.NewMedPlan.SteadyMedId; plan.Medication = model.NewMedPlan.Medication; plan.HourlyInterval = model.NewMedPlan.HourlyInterval; plan.PillsPerInterval = model.NewMedPlan.PillsPerInterval; plan.Completed = false; new GatewayController().CreateMedicationPlan(plan); return(RedirectToAction("Details", "Physician", new { id = model.CurrentPhysician.ID })); }
public async Task <IActionResult> CreateMedicationPlan(PatientViewModel model) { if (model == null) { return(View(model)); } MedicationPlan plan = new MedicationPlan(); plan.PhysicianId = model.CurrentPhysician.UserId; plan.PatientId = model.Patient.UserId; plan.Patient = model.Patient; plan.Medication = model.NewMedPlan.Medication; plan.SteadyMedId = model.Patient.SteadyMedsOwned.FirstOrDefault(); plan.HourlyInterval = model.NewMedPlan.HourlyInterval; plan.PillsPerInterval = model.NewMedPlan.PillsPerInterval; //Add plan to database/service return(RedirectToAction("Details", new { id = model.Patient.UserId })); }
/// <summary> /// Add Medication Plan to connection /// </summary> /// <param name="plan">MedicationPlan to add</param> /// <returns>True if successful, false otherwise</returns> public bool AddPlan(MedicationPlan plan) { bool result = _plans.TryAdd(_plans.Keys.Count + 1, plan); return(result); }
public void AddMedicationPlan(int patientId, MedicationPlan medicationPlan) { medicationPlan.PatientId = patientId; _unitOfWork.MedicationPlanRepository.Insert(medicationPlan); }
public void Update(MedicationPlan medicationPlan) { _unitOfWork.MedicationPlanRepository.Update(medicationPlan); _unitOfWork.Save(); }
public void Insert(MedicationPlan medicationPlan) { _unitOfWork.MedicationPlanRepository.Insert(medicationPlan); _unitOfWork.Save(); }
public void UpdateMedicationPlan(MedicationPlan medicationPlan) { _medicationPlanService.Update(medicationPlan); }
public void InsertMedicationPlan(MedicationPlan medicationPlan) { _medicationPlanService.Insert(medicationPlan); }