private List <Patient> GetPatientDtosWithBill() { var patients = patientService.GetAllPatients().ToList(); foreach (var patient in patients) { patient.TestResults = testService.GetTestResultsFromView().Where(x => x.PatientId == patient.Id).ToList(); patient.GenderNavigation = otherService.GetGenders().ToList()?.Find(x => x.Id == patient.Gender); 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); } var testResults = testService.GetTestResults().Where(x => x.PatientId == patient.Id).ToList(); patient.TestTitles = new List <TestTitles>(); if (testResults != null && testResults.Count > 0) { foreach (var testResult in testResults) { var testTitle = testService.GetTestTitle(testResult.TitleId); if (!patient.TestTitles.Contains(testTitle)) { testTitle.Group = testService.GetTestGroup(testTitle.GroupId); patient.TestTitles.Add(testTitle); } } } var bill = patientService.GetPatientBill()?.ToList()?.Find(x => x.PatientId == patient.Id); patient.Bill = bill; } return(patients); }
public ActionResult UpdateTestGroup(TestGroupDto testGroupDto) { if (testGroupDto != null) { try { var testGroupFromDb = testsService.GetTestGroup(testGroupDto.Id); if (testGroupFromDb != null) { var convertedTestGroup = testGroupDto.GetTestGroup(testGroupFromDb, testGroupDto); testsService.UpdateTestGroup(convertedTestGroup); } else { throw new Exception("The test group does not exist"); } } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while updating the test group")))); } return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS))); } else { return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper test group details")))); } }