public ActionResult InsertNewPatient(PatientDto patientRequestModel) { if (patientRequestModel != null) { try { if (patientRequestModel.Patient != null) { patientService.InsertPatient(patientRequestModel.Patient); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Patient details are missing")))); } //Insert the selected tests if (patientRequestModel.SelectedTestTitles != null && patientRequestModel.SelectedTestTitles.Count > 0) { foreach (var title in patientRequestModel.SelectedTestTitles) { var otherTests = testService.GetOtherTests().Where(otherTest => otherTest.TestGroupId == title.GroupId && otherTest.TestTitleId == title.Id).ToList(); if (otherTests != null && otherTests.Count > 0) { foreach (var test in otherTests) { testService.InsertTestResult(new TestResults().GetTestResult(test, patientRequestModel.Patient)); } } } } } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while registering new patient")))); } return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS))); } else { return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper patient details")))); } }
public ActionResult GetOtherTests() { var testResponseModel = new TestResponseModel(); var otherTests = testsService.GetOtherTests().ToList(); List <OtherTestDto> otherTestDtos = new List <OtherTestDto>(); otherTests.ForEach(otherTest => otherTestDtos.Add((new OtherTestDto()).GetOtherTestDto(otherTest))); testResponseModel.OtherTests = otherTestDtos; testResponseModel.Groups = GetTestGroupTypeDtos(testsService.GetTestGroups().ToList()); testResponseModel.Titles = GetTestTitleTypeDtos(testsService.GetTestTitles().ToList()); if (otherTestDtos != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, testResponseModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No other test found", "Please add an other test")))); } }
public ActionResult GetAllTestReagentRelations() { var relations = _reagentService.GetTestReagentRelations().ToList(); var reagents = _reagentService.GetReagents().ToList(); var tests = _testsService.GetOtherTests().ToList(); var responseModel = new ReagentResponseModel { TestReagentRelations = relations, Reagents = reagents, Tests = tests }; if (responseModel != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, responseModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No test reagent relation found", "Please add a new one")))); } }