public async Task <IActionResult> Edit(int id, [Bind("Recommandations,TypeO,DateC,Id")] Ordonnance ordonnance) { if (id != ordonnance.Id) { return(NotFound()); } if (ModelState.IsValid) { try { CliniqueDbContext context = _contextFactory.CreateDbContext(); context.Update(ordonnance); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdonnanceExists(ordonnance.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(ordonnance)); }
private async Task AddQuickPrescription(string documentPath) { var ordannance = new Ordonnance() { Id = Guid.NewGuid().ToString(), CreatedAt = DateTime.UtcNow, IsSynced = false, UpdatedAt = null, First_Care_At = 0, Attachments = new List <string>() { documentPath }, Frequencies = new List <Frequency>(), Patient = Patient, PatientId = Patient.Id, PatientName = Patient.Fullname }; await new StorageService <Ordonnance>().AddAsync(ordannance); if (App.IsConnected()) { UserDialogs.Instance.ShowLoading("Chargement..."); new StorageService <Ordonnance>().PushOrdonnance(ordannance, true); UserDialogs.Instance.HideLoading(); } BindData(); await ToastService.Show("Votre ordonnance a bien été enregistrée !"); }
private async void DoAsyncActions() { while (this.BindingContext == null) { await Task.Delay(100); } _ordonnance = (BindingContext as OrdonnanceCreateEditViewModel).Ordonnance; //if ((BindingContext as OrdonnanceCreateEditViewModel).SaveLabel == "Enregistrer") //VisualiserSection.IsVisible = false; MyDatePicker.Date = Ordonnance.ConvertFromUnixTimestamp(_ordonnance.First_Care_At); MyDatePicker.DateSelected += MyDatePickerOnDateSelected; SelectedDate.Text = $"Premier soin: {Ordonnance.ConvertFromUnixTimestamp(_ordonnance.First_Care_At).ToString("dd-MM-yyyy")}"; if (_ordonnance.Frequencies != null) { UpdateFrequenciesViewCellHeight(new ObservableCollection <Frequency>(_ordonnance.Frequencies)); } else { UpdateFrequenciesViewCellHeight(new ObservableCollection <Frequency>()); } if (string.IsNullOrEmpty(_ordonnance.Comments)) { MyEditor.Text = "Ecrivez quelque chose"; MyEditor.TextColor = Color.Gray; } else { MyEditor.Text = _ordonnance.Comments; } StatusLabel.Text = "Statut: " + _ordonnance.StatusString; if (!(BindingContext as OrdonnanceCreateEditViewModel).Creating) { StatusLabel.Text = "Statut: " + _ordonnance.StatusString; } if ((BindingContext as OrdonnanceCreateEditViewModel).Ordonnance?.Status == Enums.StatusEnum.refused.ToString()) { statusIcon.Source = "cancel.png"; StatusLabel.TextColor = Color.Red; StatusLabel.Text = "Refusé : " + (BindingContext as OrdonnanceCreateEditViewModel).Ordonnance?.RefusedReason; } else if ((BindingContext as OrdonnanceCreateEditViewModel).Ordonnance?.Status == Enums.StatusEnum.valid.ToString()) { statusIcon.Source = "send.png"; this.Footer = null; StatusLabel.Text = "Traité le " + (BindingContext as OrdonnanceCreateEditViewModel).Ordonnance?.StatusChangedAt.ToString("dd/MM/yyyy"); } if (_ordonnance.First_Care_At == 0) { FirstCareCell.IsVisible = false; } }
public override void Init(object initData) { base.Init(initData); if (initData != null) { Ordonnance = initData as Ordonnance; } }
public async Task <IActionResult> Create([Bind("Recommandations,TypeO,DateC,Id")] Ordonnance ordonnance) { if (ModelState.IsValid) { CliniqueDbContext context = _contextFactory.CreateDbContext(); context.Add(ordonnance); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ordonnance)); }
private async Task AddPrescription(Patient patient) { if (typeDoc == "ordonnance") { var ordannance = new Ordonnance() { Id = Guid.NewGuid().ToString(), CreatedAt = DateTime.UtcNow, IsSynced = false, UpdatedAt = null, First_Care_At = 0, Attachments = new List <string>() { _documentPath }, Frequencies = new List <Frequency>(), Patient = patient, PatientId = patient.Id, PatientName = patient.Fullname }; await new StorageService <Ordonnance>().AddAsync(ordannance); if (App.IsConnected()) { //UserDialogs.Instance.ShowLoading("Chargement..."); new StorageService <Ordonnance>().PushOrdonnance(ordannance, true); //UserDialogs.Instance.HideLoading(); } ShowMessage(); } else { var document = new Document() { Id = Guid.NewGuid().ToString(), CreatedAt = DateTime.UtcNow, IsSynced = false, UpdatedAt = null, Reference = DateTime.UtcNow.Ticks, AddDate = DateTime.UtcNow, Patient = patient, PatientId = patient.Id, AttachmentPath = _documentPath, }; await Task.Delay(1000); await CoreMethods.PushPageModel <AddDocumentViewModel>(document, true, false); } }
public static Ordonnance GetOrdonnanceById(string id) { string json = File.ReadAllText("./MockSNIRAM/Ordonnance.json"); Ordonnance ordonnance = JsonConvert.DeserializeObject <Ordonnance>(json); if (ordonnance.NumeroOrdonance == id) { return(ordonnance); } else { return(null); } }
public ActionResult <string> Mock(string ClassName) { string destinationFile = "./MockSNIRAM/"; if (ClassName == "Patient") { destinationFile += ClassName + ".json"; Patient JohnDoe = new Patient() { NumeroSecuriteSociale = "123", Prenom = "John", Nom = "Doe", DateNaissance = new DateTime(1970, 01, 01) }; string json = JsonConvert.SerializeObject(JohnDoe, Formatting.Indented); System.IO.File.WriteAllText(destinationFile, json); } else if (ClassName == "Ordonnance") { destinationFile += ClassName + ".json"; List <string> listeMedicamentsId = new List <string>(); listeMedicamentsId.Add("123"); List <Medicament> medicaments = new List <Medicament>(); medicaments.Add(DataAccess.GetMedicamentById("123")); Ordonnance OrdonnanceJohnDoe = new Ordonnance() { NumeroOrdonance = "123", medicaments = medicaments, patient = Patient.GetPatientByNumeroSecuriteSociale("123") }; string json = JsonConvert.SerializeObject(OrdonnanceJohnDoe, Formatting.Indented); System.IO.File.WriteAllText(destinationFile, json); } else if (ClassName == "Medicament") { destinationFile += ClassName + ".json"; List <string> listeMedicamentsId = new List <string>(); listeMedicamentsId.Add("123"); Medicament medicamentQuiPoseProbleme = new Medicament() { NumeroBDM = "123", Nom = "Problématix" }; string json = JsonConvert.SerializeObject(medicamentQuiPoseProbleme, Formatting.Indented); System.IO.File.WriteAllText(destinationFile, json); } return("Mock data created in file " + destinationFile); }
public ActionResult Create([Bind(Include = "ID_Consultation,dateCreation,motif,note,poids,taille,temperature,systol,diastol,diagnostique,maladie,ID_Patient,ID_Staff")] Consultation consultation) { Vaccin vaccin = new Vaccin(); Ordonnance ordonnance = new Ordonnance(); Antecedent antecedentConsultation = new Antecedent(); if (ModelState.IsValid) { db.Consultations.Add(consultation); string prescription = Request["prescription"].ToString(); string medicament = Request["medicament"].ToString(); string vac = Request["vac"].ToString(); string antecedent = Request["ant"]; if (!string.IsNullOrEmpty(antecedent)) { antecedentConsultation.ID_Consultation = consultation.ID_Consultation; antecedentConsultation.ID_Patient = consultation.ID_Patient; antecedentConsultation.description = antecedent; db.Antecedents.Add(antecedentConsultation); } if (!string.IsNullOrEmpty(vac)) { vaccin.ID_Consultation = consultation.ID_Consultation; vaccin.ID_PATIENT = consultation.ID_Patient; vaccin.description = vac; vaccin.date = DateTime.Now; db.Vaccins.Add(vaccin); } if (!string.IsNullOrEmpty(medicament)) { ordonnance.ID_Consultation = consultation.ID_Consultation; ordonnance.medicament = medicament; ordonnance.prescription = !string.IsNullOrEmpty(prescription) ? prescription : ""; db.Ordonnances.Add(ordonnance); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_Patient = new SelectList(db.Patients, "ID_Patient", "nom", consultation.ID_Patient); ViewBag.ID_Staff = new SelectList(db.Staffs, "ID_Staff", "nom", consultation.ID_Staff); return(View(consultation)); }
public Ordonnance GetOrdonnance(int idConsultation) { Ordonnance ord = new Ordonnance(); using (var cp = new Clinic2Entities()) { var obj = cp.Ordonnances .Where(ordonnance => ordonnance.ID_Consultation == idConsultation) .Select(st => new { Prescription = st.prescription, Medicament = st.medicament }); ord.prescription = obj.Select(x => x.Prescription).DefaultIfEmpty("").First(); ord.medicament = obj.Select(x => x.Medicament).DefaultIfEmpty("").First(); } return(ord); }
public ActionResult Create([Bind(Include = "ID_Consultation,creatieDate,createBy,changeDate,changeBy,motif,note,poids,taille,temperature,systol,diastol,diagnostique,maladie,antecedent,statut,ID_Patient,ID_Staff")] Consultation consultation) { if (ModelState.IsValid) { //---------------------------------------------------------- https://stackoverflow.com/questions/22246538/access-claim-values-in-controller-in-mvc-5 //Get the current claims principal var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; // Get the claims values var name = identity.Claims.Where(c => c.Type == ClaimTypes.Name) .Select(c => c.Value).SingleOrDefault(); var uid = identity.Claims.Where(c => c.Type == ClaimTypes.Sid) .Select(c => c.Value).SingleOrDefault(); var role = identity.Claims.Where(c => c.Type == ClaimTypes.Role) .Select(c => c.Value).SingleOrDefault(); //----------------------------------------------------------------- Ordonnance ordonnance = new Ordonnance(); Vaccin vaccin = new Vaccin(); consultation.createBy = name + " - ID: " + uid + " - Role:" + role; consultation.creatieDate = DateTime.Now; consultation.ID_Staff = Int32.Parse(uid); consultation.ID_Patient = Int32.Parse(Request["ID_Patient"].ToString()); if (!string.IsNullOrEmpty(Request["medicament"].ToString()) || !string.IsNullOrEmpty(Request["prescription"].ToString())) { ordonnance.medicament = Request["medicament"].ToString(); ordonnance.prescription = Request["prescription"].ToString(); ordonnance.ID_Consultation = consultation.ID_Consultation; db.Ordonnances.Add(ordonnance); } if (string.IsNullOrEmpty(Request["vac"].ToString())) { vaccin.date = DateTime.Now; vaccin.description = Request["vac"].ToString(); vaccin.ID_Consultation = consultation.ID_Consultation; db.Vaccins.Add(vaccin); } db.Consultations.Add(consultation); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(consultation)); }
public OrdonnanceCreateEditViewModel() { Attachments = new ObservableCollection <string>(); Frequencies = new ObservableCollection <Frequency>(); Ordonnance = new Ordonnance { Id = Guid.NewGuid().ToString(), CreatedAt = DateTime.UtcNow, Attachments = new List <string>(), Frequencies = new List <Frequency>(), First_Care_At = App.ConvertToUnixTimestamp(DateTime.UtcNow) }; SubscribeMessages(); MessagingCenter.Unsubscribe <PatientListViewModel, Patient>(this, Events.OrdonnancePageSetPatientForOrdonnance); MessagingCenter.Subscribe <PatientListViewModel, Patient>(this, Events.OrdonnancePageSetPatientForOrdonnance, (sender, patient) => { if (patient != null && Ordonnance != null && PatientLabel != null) { Ordonnance.Patient = patient; Ordonnance.PatientId = patient.Id; Ordonnance.PatientName = patient.Fullname; PatientLabel = patient.Fullname; } }); MessagingCenter.Unsubscribe <DetailsPatientListViewModel, Patient>(this, Events.PatientDetailsPageSetPatientToOrdonnance); MessagingCenter.Subscribe <DetailsPatientListViewModel, Patient>(this, Events.PatientDetailsPageSetPatientToOrdonnance, (sender, patient) => { if (patient != null && Ordonnance != null && PatientLabel != null) { Ordonnance.Patient = patient; Ordonnance.PatientId = patient.Id; Ordonnance.PatientName = patient.Fullname; PatientLabel = patient.Fullname; } }); }
public ActionResult Edit([Bind(Include = "ID_Consultation,dateCreation,motif,note,poids,taille,temperature,systol,diastol,diagnostique,maladie,ID_Patient,ID_Staff")] Consultation consultation /*[Bind(Include = "id_audit,ID_Consultation,ID_Staff,change_date,change_by")] Audit_Consultation ac*/) { //string medicament = (from o in db.Ordonnances where o.ID_Consultation == consultation.ID_Consultation select new { o.medicament }).Single().medicament; //string prescription = (from o in db.Ordonnances where o.ID_Consultation == consultation.ID_Consultation select new { o.prescription }).Single().prescription; //string vaccin = (from v in db.Vaccins where v.ID_Consultation == consultation.ID_Consultation select new { v.description }).Single().description; //consultation.vaccin.description = getVaccin(consultation.ID_Consultation); //consultation.ordonnance.prescription = getPrecription(consultation.ID_Consultation); //consultation.ordonnance.medicament = getMedicament(consultation.ID_Consultation); if (ModelState.IsValid) { db.Entry(consultation).State = EntityState.Modified; //ac.ID_Consultation = consultation.ID_Consultation; //ac.ID_Staff = consultation.ID_Staff; //ac.change_date = DateTime.Now; Vaccin v = new Vaccin(); Ordonnance o = new Ordonnance(); Antecedent ant = new Antecedent(); var changeBy = (from s in db.Staffs where s.ID_Staff == consultation.ID_Staff select new { s.nom, s.prenom }).Single(); consultation.changeBy = changeBy.nom + " " + changeBy.prenom; consultation.changeDate = DateTime.Now; //db.Audit_Consultation.Add(ac); string viewAntecedent = Request["antecedent.description"].ToString(); string viewVaccin = Request["vaccin.description"].ToString(); string viewPrescription = Request["ordonnance.prescription"].ToString(); string viewMedicament = Request["ordonnance.medicament"].ToString(); int idVac = db.Vaccins.Where(id => id.ID_Consultation == consultation.ID_Consultation).Select(x => x.ID_Vaccin).DefaultIfEmpty(0).First(); int idOrd = db.Ordonnances.Where(id => id.ID_Consultation == consultation.ID_Consultation).Select(x => x.ID_Ordonnance).DefaultIfEmpty(0).First(); int idAnt = db.Antecedents.Where(id => id.ID_Consultation == consultation.ID_Consultation).Select(x => x.ID_Antecedent).DefaultIfEmpty(0).First(); if (idAnt > 0) { if (!string.IsNullOrEmpty(viewAntecedent)) { db.Database.ExecuteSqlCommand("Update Antecedents set description='" + viewAntecedent + "' where ID_Antecedent =" + idAnt); } } if (idAnt == 0) { if (!string.IsNullOrEmpty(viewAntecedent)) { ant.description = viewAntecedent.ToString(); ant.ID_Consultation = consultation.ID_Consultation; ant.ID_Patient = consultation.ID_Patient; db.Antecedents.Add(ant); } } if (idVac > 0) { if (!string.IsNullOrEmpty(viewVaccin)) { db.Database.ExecuteSqlCommand("Update Vaccins set description='" + viewVaccin.ToString() + "' where ID_Vaccin =" + idVac); } } if (idVac == 0) { if (!string.IsNullOrEmpty(viewVaccin)) { v.description = viewVaccin.ToString(); v.ID_Consultation = consultation.ID_Consultation; v.ID_PATIENT = consultation.ID_Patient; v.date = DateTime.Now; db.Vaccins.Add(v); } } if (idOrd > 0) { if (!string.IsNullOrEmpty(viewPrescription)) { db.Database.ExecuteSqlCommand("Update Ordonnances set prescription='" + viewPrescription.ToString() + "' where ID_Ordonnance =" + idOrd); } //else //{ // db.Database.ExecuteSqlCommand("Update Ordonnances set prescription='' where ID_Ordonnance =" + idOrd); //} if (!string.IsNullOrEmpty(viewMedicament)) { db.Database.ExecuteSqlCommand("Update Ordonnances set medicament='" + viewMedicament.ToString() + "' where ID_Ordonnance =" + idOrd); } } if (idOrd == 0) { if (!string.IsNullOrEmpty(viewPrescription)) { o.prescription = viewPrescription.ToString(); o.ID_Consultation = consultation.ID_Consultation; db.Ordonnances.Add(o); } if (!string.IsNullOrEmpty(viewMedicament)) { o.medicament = viewMedicament.ToString(); o.ID_Consultation = consultation.ID_Consultation; db.Ordonnances.Add(o); } } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_Patient = new SelectList(db.Patients, "ID_Patient", "nom", consultation.ID_Patient); ViewBag.ID_Staff = new SelectList(db.Staffs, "ID_Staff", "nom", consultation.ID_Staff); return(View(consultation)); }
public string Get(string ClassName, string id) { try{ if (ClassName == "Patient") { Patient patient = Patient.GetPatientByNumeroSecuriteSociale(id); if (patient != null) { return(JsonConvert.SerializeObject(patient, Formatting.Indented)); } else { return("Aucun patient trouvé pour le numéro de sécurité sociale " + id); } } else if (ClassName == "EM") { List <ErreurMedicamenteuse> EMs = ErreurMedicamenteuse.GetEMByRPPS(id); if (EMs.Count > 0) { return(JsonConvert.SerializeObject(EMs, Formatting.Indented)); } else { return("Aucune donnée d'EM déclarées par le soignant " + id + " trouvées pour le numéro de sécurité sociale."); } } else if (ClassName == "Medicament") { if (id.ToLower() == "all") { return(JsonConvert.SerializeObject(DataAccess.GetMedicamentsFromApi(), Formatting.Indented)); } else { return(JsonConvert.SerializeObject(DataAccess.GetMedicamentsFromApi().Where(m => m.NumeroBDM == id).FirstOrDefault(), Formatting.Indented)); } } else if (ClassName == "Ordonnance") { Ordonnance ordonnance = Ordonnance.GetOrdonnanceById(id); if (ordonnance != null) { string result = JsonConvert.SerializeObject(ordonnance, Formatting.Indented); if (ordonnance.ExisteRisque()) { result += ordonnance.MessageATransmettre(); return(result); } else { return(result); } } else { return("Aucune ordonnance n'existe avec l'id " + id + "."); } } return("Aucune table ne correspond à " + ClassName); } catch (Exception ex) { return("Erreur au sein de l'appel API : " + ex.StackTrace); } }
public ActionResult Edit([Bind(Include = "ID_Consultation,creatieDate,createBy,changeDate,changeBy,motif,note,poids,taille,temperature,systol,diastol,diagnostique,maladie,antecedent,statut,ID_Patient,ID_Staff")] Consultation consultation) { if (ModelState.IsValid) { db.Entry(consultation).State = EntityState.Modified; Ordonnance ordonnance = new Ordonnance(); Vaccin vaccin = new Vaccin(); string currentOrdPrescription = db.Ordonnances.Where(x => x.ID_Consultation == consultation.ID_Consultation).Select(x => x.prescription).DefaultIfEmpty("").First(); string currentOrdMedicament = db.Ordonnances.Where(x => x.ID_Consultation == consultation.ID_Consultation).Select(x => x.medicament).DefaultIfEmpty("").First(); string currentVacDescription = db.Vaccins.Where(x => x.ID_Consultation == consultation.ID_Consultation).Select(x => x.description).DefaultIfEmpty("").First(); string ordPrescription = Request["ordonnance.prescription"]; string ordMedicament = Request["ordonnance.medicament"]; string vacDescription = Request["vaccin.description"]; int idOrdonnance = db.Ordonnances.Where(x => x.ID_Consultation == consultation.ID_Consultation).Select(x => x.ID_Ordonnance).DefaultIfEmpty(0).First(); int idVaccin = db.Vaccins.Where(x => x.ID_Consultation == consultation.ID_Consultation).Select(x => x.ID_Vaccin).DefaultIfEmpty(0).First(); if (idOrdonnance > 0) { if (!string.IsNullOrEmpty(ordPrescription) || !string.IsNullOrEmpty(ordMedicament)) { db.Database.ExecuteSqlCommand("Update Ordonnance set prescription='" + ordPrescription + "',medicament='" + ordMedicament + "' where ID_Consultation =" + consultation.ID_Consultation); } } else { ordonnance.prescription = ordPrescription; ordonnance.medicament = ordMedicament; ordonnance.ID_Consultation = consultation.ID_Consultation; db.Ordonnances.Add(ordonnance); } if (idVaccin > 0) { if (!string.IsNullOrEmpty(vacDescription)) { db.Database.ExecuteSqlCommand("Update Vaccin set description='" + vacDescription + "' where ID_Consultation =" + consultation.ID_Consultation); } } else { vaccin.description = vacDescription; vaccin.ID_Consultation = consultation.ID_Consultation; db.Vaccins.Add(vaccin); } //---------------------------------------------------------- https://stackoverflow.com/questions/22246538/access-claim-values-in-controller-in-mvc-5 //Get the current claims principal var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; // Get the claims values var name = identity.Claims.Where(c => c.Type == ClaimTypes.Name) .Select(c => c.Value).SingleOrDefault(); var uid = identity.Claims.Where(c => c.Type == ClaimTypes.Sid) .Select(c => c.Value).SingleOrDefault(); var role = identity.Claims.Where(c => c.Type == ClaimTypes.Role) .Select(c => c.Value).SingleOrDefault(); //----------------------------------------------------------------- consultation.changeBy = name + " - ID: " + uid + " - Role:" + role; consultation.changeDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(consultation)); }
public async Task PushOrdonnance(Ordonnance ordonnanceObject, bool isNew) { try { var localId = ordonnanceObject.Id; var ordonnance = await App.OrdonnanceManager.SaveOrUpdateAsync(ordonnanceObject.Id, ordonnanceObject, ordonnanceObject.UpdatedAt == null); if (ordonnance != null) { ordonnance.UpdatedAt = DateTime.UtcNow; await DeleteItemAsync(typeof(Ordonnance).Name + "_" + localId); await UpdateAsync(ordonnance as TModel, typeof(Ordonnance).Name + "_" + ordonnance.Id); var attachments = new Dictionary <string, string>(); foreach (var attachment in ordonnance.Attachments) { if (!attachment.StartsWith("PatientDocuments") && !attachment.StartsWith("Ordonnance")) { var res = await FileUpload.UploadFile(attachment, "Ordonnance", ordonnance.Id); if (res) { attachments.Add(attachment, $"Ordonnance/{ordonnance.Id}/{Path.GetFileName(attachment)}"); } } } if (attachments.Keys.Count > 0) { foreach (var key in attachments.Keys) { ordonnance.Attachments[ordonnance.Attachments.IndexOf(key)] = attachments[key]; } } var ordonnanceUpdated = await App.OrdonnanceManager.SaveOrUpdateAsync(ordonnance.Id, ordonnance, false); if (ordonnanceUpdated != null && attachments.Count == ordonnance.Attachments.Count) { ordonnance = ordonnanceUpdated; ordonnance.IsSynced = true; ordonnance.UpdatedAt = DateTime.UtcNow; } else { ordonnance.IsSynced = false; } await UpdateAsync(ordonnance as TModel, typeof(Ordonnance).Name + "_" + ordonnance.Id); MessagingCenter.Send(this, "RefreshOrdonanceList"); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }