Esempio n. 1
0
        public IActionResult ImportPatientCredentials(ImportPatientCredentials importPatientCredentials)
        {
            // if all goes well, redirect to import patients with a success message
            // otherwise, r
            if (!CsvProcessor.IsCsv(importPatientCredentials.File))
            {
                ViewData["ErrorMessage"] = "Could not upload patients, the file provided was not a CSV file.";
                return(View(viewName: "ImportPatients"));
            }

            List <string>  errorMessages = new List <string>();
            List <Patient> patients      = CsvProcessor.ReadPatients(importPatientCredentials.File, errorMessages);

            // No patients parsed then return with errors. If there are patients parsed but the user does not want to upload
            // if there are errors, then simply return with errors
            if (patients.Count == 0 || (errorMessages.Count > 0 && !importPatientCredentials.UploadWithErrors))
            {
                ViewData["ErrorMessage"] = "No patients were uploaded, check the file matches the format required.";
                return(View(viewName: "ImportPatients"));
            }

            int successfulInserts = PatientProcessor.SavePatients(Patient.Convert(patients), errorMessages);

            if (errorMessages.Count != 0)
            {
                ViewData["ErrorMessages"] = errorMessages;
            }

            ViewData["SuccessMessage"] = $"{successfulInserts} Patients were uploaded successfully.";
            return(View(viewName: "ImportPatients"));
        }
Esempio n. 2
0
        public IActionResult DisplayBatchCalculations(BatchCalculation batchCalculation)
        {
            // if all goes well, redirect to import patients with a success message
            // otherwise, r

            if (!CsvProcessor.IsCsv(batchCalculation.File))
            {
                ViewData["ErrorMessage"] = "Could not upload patients, the file provided was not a CSV file.";
                return(View(viewName: "BatchCalculation"));
            }
            var errorMessages = CsvProcessor.ReadBatchPatientData(batchCalculation.File, out List <ListCalculations> calculatedPatients);

            if (errorMessages.Count != 0)
            {
                ViewData["ErrorMessages"] = errorMessages;
            }
            return(View(viewName: "DisplayBatchCalculations", model: calculatedPatients));
        }
Esempio n. 3
0
        public IActionResult Index(ImportClinicianCredentials clinicianCredentials)
        {
            ClinicianManagerModel clinicianManagerModel = new ClinicianManagerModel();

            if (clinicianCredentials.File == null)
            {
                ViewData["ErrorMessage"]         = "Could not upload clinicians, no file was provided.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            if (!CsvProcessor.IsCsv(clinicianCredentials.File))
            {
                ViewData["ErrorMessage"]         = "Could not upload clinicians, the file provided was not a CSV file.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            var errorMessages = CsvProcessor.GetClinicianCredentials(clinicianCredentials.File, out List <Clinician> clinicians);

            if (clinicians.Count == 0 || (errorMessages.Count > 0 && !clinicianCredentials.UploadWithErrors))
            {
                ViewData["ErrorMessage"]         = "No clinicians were uploaded, check the file matches the format required.";
                clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
                return(View(clinicianManagerModel));
            }

            int successfulInserts = ClinicianProcessor.SaveClinicians(Clinician.Convert(clinicians), errorMessages);

            if (errorMessages.Count != 0)
            {
                ViewData["ErrorMessages"] = errorMessages;
            }

            ViewData["SuccessMessage"]       = $"{successfulInserts} Clinicians were uploaded successfully.";
            clinicianManagerModel.Clinicians = Clinician.Convert(ClinicianProcessor.GetAllClinicians());
            return(View(clinicianManagerModel));
        }