public ActionResult GetPatientsWithTests() { var patients = patientService.GetAllPatients().ToList(); var formulas = testService.GetFormulas().ToList(); foreach (var patient in patients) { patient.GenderNavigation = otherService.GetGenders().ToList()?.Find(x => x.Id == patient.Gender); patient.Initial = otherService.GetInitials().ToList()?.Find(x => x.Id == patient.InitialId); patient.PatientFullName = $"{patient.Initial.Initial} {patient.FirstName}"; if (!string.IsNullOrEmpty(patient.MiddleName)) { patient.PatientFullName += $" {patient.MiddleName}"; } if (!string.IsNullOrEmpty(patient.LastName)) { patient.PatientFullName += $" {patient.LastName}"; } patient.CivilStatusNavigation = maintenanceService.GetFieldOptions().FieldOptions?.Find(x => x.Id == patient.CivilStatus); if (patient.ReferredBy.HasValue) { patient.ReferredByNavigation = dhlRegistrationService.GetDhlRegistrations().HdlRegistrations?.Find(x => x.Id == patient.ReferredBy); if (patient.ReferredByNavigation != null) { if (patient.ReferredByNavigation.RegistrationTypeId == 1) { patient.ReferredByFullName = $"Dr. {patient.ReferredByNavigation.Name}"; } else { patient.ReferredByFullName = patient.ReferredByNavigation.Name; } } } } var responseModel = new TestResultsResponseModel(); responseModel.Patients = patients; responseModel.Signatures = maintenanceService.GetSignatures().Signatures; if (responseModel != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, responseModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No patients found", "Please register a patient")))); } }
public ActionResult GetFormulas() { var formulasResponseModel = new FormulasResponseModel(); formulasResponseModel.OtherTests = testsService.GetOtherTests().ToList(); formulasResponseModel.Groups = testsService.GetTestGroups().ToList(); formulasResponseModel.Titles = testsService.GetTestTitles().ToList(); formulasResponseModel.Formulas = testsService.GetFormulas().ToList(); if (formulasResponseModel != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, formulasResponseModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No formula found", "Please add a formula")))); } }