public AccountController(EyadtakContext eyadtakDbContext, IJwt jwt, IEmail email, IConfiguration configuration)
 {
     _eyadtakDbContext = eyadtakDbContext;
     _jwt           = jwt;
     _email         = email;
     _configuration = configuration;
 }
Beispiel #2
0
        public MedicinesController(EyadtakContext eyadtakDbContext, IConfiguration configuration)
        {
            _eyadtakDbContext = eyadtakDbContext;
            _configuration    = configuration;

            if (Medicines == null)
            {
                Medicines = _eyadtakDbContext.Medicines.ToList();
            }
        }
Beispiel #3
0
        public AllergiesController(EyadtakContext eyadtakDbContext, IConfiguration configuration)
        {
            _eyadtakDbContext = eyadtakDbContext;
            _configuration    = configuration;

            if (Allergies == null)
            {
                Allergies = _eyadtakDbContext.Allergies.ToList();
            }
        }
        public SignsController(EyadtakContext eyadtakDbContext, IConfiguration configuration)
        {
            _eyadtakDbContext = eyadtakDbContext;
            _configuration    = configuration;

            if (Signs == null)
            {
                Signs = _eyadtakDbContext.Signs.ToList();
            }
        }
        public DiagnosesController(EyadtakContext eyadtakDbContext, IConfiguration configuration)
        {
            _eyadtakDbContext = eyadtakDbContext;
            _configuration    = configuration;

            if (Diagnoses == null)
            {
                Diagnoses = _eyadtakDbContext.Diagnoses.ToList();
            }
        }
 public HomeController(EyadtakContext eyadtakDbContext, IConfiguration configuration)
 {
     _eyadtakDbContext = eyadtakDbContext;
     _configuration    = configuration;
 }
Beispiel #7
0
        public IActionResult SavePatientHistory([FromBody] SavePatientHistory savePatientHistory)
        {
            try
            {
                List <Allergie> newAllergies = savePatientHistory.Allergies.Where(x => x.Id == 0).Select(x => new Allergie {
                    Name = x.Name, NumberOfUse = 0
                }).ToList();
                List <Sign> newSigns = savePatientHistory.Signs.Where(x => x.Id == 0).Select(x => new Sign {
                    Name = x.Name, NumberOfUse = 0
                }).ToList();
                List <Symptom> newSymptoms = savePatientHistory.Symptoms.Where(x => x.Id == 0).Select(x => new Symptom {
                    Name = x.Name, NumberOfUse = 0
                }).ToList();
                List <Diagnosis> newDiagnoses = savePatientHistory.Diagnoses.Where(x => x.Id == 0).Select(x => new Diagnosis {
                    Name = x.Name, NumberOfUse = 0
                }).ToList();
                List <Medicine> newMedicines = savePatientHistory.Medicines.Where(x => x.Id == 0).Select(x => new Medicine {
                    Name = x.Name, NumberOfUse = 0
                }).ToList();

                if (newAllergies.Count > 0)
                {
                    _eyadtakDbContext.Allergies.AddRange(newAllergies);
                }
                if (newSigns.Count > 0)
                {
                    _eyadtakDbContext.Signs.AddRange(newSigns);
                }
                if (newSymptoms.Count > 0)
                {
                    _eyadtakDbContext.Symptoms.AddRange(newSymptoms);
                }
                if (newDiagnoses.Count > 0)
                {
                    _eyadtakDbContext.Diagnoses.AddRange(newDiagnoses);
                }
                if (newMedicines.Count > 0)
                {
                    _eyadtakDbContext.Medicines.AddRange(newMedicines);
                }

                if (newAllergies.Count > 0 || newSigns.Count > 0 || newSymptoms.Count > 0 || newDiagnoses.Count > 0 || newMedicines.Count > 0)
                {
                    _eyadtakDbContext.SaveChanges();
                }

                AllergiesController.AddAllergies(newAllergies);
                DiagnosesController.AddDiagnoses(newDiagnoses);
                MedicinesController.AddMedicines(newMedicines);
                SignsController.AddSigns(newSigns);
                SymptomsController.AddSymptoms(newSymptoms);

                PatientHistory patientHistory = new PatientHistory
                {
                    Note           = savePatientHistory.Note,
                    CheifComplaint = savePatientHistory.Complaint,
                    InsertDate     = DateTime.Now,
                    PatientId      = savePatientHistory.PatientId,
                };

                newAllergies.AddRange(savePatientHistory.Allergies.Where(x => x.Id != 0).Select(x => new Allergie {
                    AllergieId = x.Id, Name = x.Name
                }));
                patientHistory.PatientHistoryAllergies = newAllergies.Select(x => new PatientHistoryAllergie {
                    InsertTime = DateTime.Now, AllergieId = x.AllergieId, PatientHistoryId = patientHistory.PatientHistoryId
                }).ToList();

                newSigns.AddRange(savePatientHistory.Signs.Where(x => x.Id != 0).Select(x => new Sign {
                    SignId = x.Id, Name = x.Name
                }));
                patientHistory.PatientHistorySigns = newSigns.Select(x => new PatientHistorySign {
                    InsertTime = DateTime.Now, SignId = x.SignId, PatientHistoryId = patientHistory.PatientHistoryId
                }).ToList();

                newSymptoms.AddRange(savePatientHistory.Symptoms.Where(x => x.Id != 0).Select(x => new Symptom {
                    SymptomId = x.Id, Name = x.Name
                }));
                patientHistory.PatientHistorySymptoms = newSymptoms.Select(x => new PatientHistorySymptom {
                    InsertTime = DateTime.Now, SymptomId = x.SymptomId, PatientHistoryId = patientHistory.PatientHistoryId
                }).ToList();

                newDiagnoses.AddRange(savePatientHistory.Diagnoses.Where(x => x.Id != 0).Select(x => new Diagnosis {
                    DiagnosisId = x.Id, Name = x.Name
                }));
                patientHistory.PatientHistoryDiagnoses = newDiagnoses.Select(x => new PatientHistoryDiagnosis {
                    InsertTime = DateTime.Now, DiagnosisId = x.DiagnosisId, PatientHistoryId = patientHistory.PatientHistoryId
                }).ToList();

                newMedicines.AddRange(savePatientHistory.Medicines.Where(x => x.Id != 0).Select(x => new Medicine {
                    MedicineId = x.Id, Name = x.Name
                }));
                patientHistory.PatientHistoryMedicines = newMedicines.Select(x => new PatientHistoryMedicine {
                    InsertTime = DateTime.Now, MedicineId = x.MedicineId, PatientHistoryId = patientHistory.PatientHistoryId
                }).ToList();

                _eyadtakDbContext.PatientHistory.Add(patientHistory);
                _eyadtakDbContext.SaveChanges();

                Task.Run(() =>
                {
                    var options           = new DbContextOptionsBuilder <EyadtakContext>().UseSqlServer(_configuration.GetConnectionString("EyadtakDbConnectionString")).Options;
                    var _eyadtakDbContext = new EyadtakContext(options);

                    var allergies = _eyadtakDbContext.Allergies.Where(x => newAllergies.Select(x => x.AllergieId).Contains(x.AllergieId)).ToList();
                    foreach (var allergie in allergies)
                    {
                        allergie.NumberOfUse += 1;
                    }

                    var signs = _eyadtakDbContext.Signs.Where(x => newSigns.Select(x => x.SignId).Contains(x.SignId)).ToList();
                    foreach (var sign in signs)
                    {
                        sign.NumberOfUse += 1;
                    }

                    var symptoms = _eyadtakDbContext.Symptoms.Where(x => newSymptoms.Select(x => x.SymptomId).Contains(x.SymptomId)).ToList();
                    foreach (var symptom in symptoms)
                    {
                        symptom.NumberOfUse += 1;
                    }

                    var diagnoses = _eyadtakDbContext.Diagnoses.Where(x => newDiagnoses.Select(x => x.DiagnosisId).Contains(x.DiagnosisId)).ToList();
                    foreach (var diagnosis in diagnoses)
                    {
                        diagnosis.NumberOfUse += 1;
                    }

                    var medicines = _eyadtakDbContext.Medicines.Where(x => newMedicines.Select(x => x.MedicineId).Contains(x.MedicineId)).ToList();
                    foreach (var medicine in medicines)
                    {
                        medicine.NumberOfUse += 1;
                    }

                    _eyadtakDbContext.SaveChanges();
                });

                return(Ok(new { message = "Patient history saved successfully", ErrorHappen = false }));
            }
            catch (Exception e)
            {
                return(Ok(new { message = "Something went wrong", ErrorHappen = true }));

                throw e;
            }
        }
Beispiel #8
0
 public AuthorizedAbility(IJwt jwt, EyadtakContext eyadtakDbContext)
 {
     _jwt = jwt;
     _eyadtakDbContext = eyadtakDbContext;
 }
 public RolesController(EyadtakContext eyadtakDbContext)
 {
     _eyadtakDbContext = eyadtakDbContext;
 }