public SpecializedLabReportResponseModel GetSpecializedLabReport(SpecializedLabReportResponseModel model) { if (model.FromDate == null || model.ToDate == null) { throw new Exception("Please enter valid date range"); } var patients = patientsRepository.GetAll().Where(x => { if ((x.RegistrationDate >= model.FromDate) && (x.RegistrationDate <= model.ToDate)) { return(true); } else { return(false); } })?.ToList(); var responseModel = new SpecializedLabReportResponseModel(); responseModel.Labs = hdlRegisrationRepository.GetAll()?.ToList()?.FindAll(x => x.RegistrationTypeId == 3); if (patients != null && patients.Count > 0) { responseModel.FromDate = model.FromDate; responseModel.ToDate = model.ToDate; foreach (var patient in patients) { var samples = specializedLabSamplesRepository.GetAll()?.Where(x => x.PatientId == patient.Id)?.ToList(); if (samples != null) { foreach (var sample in samples) { var labSample = new SpecializedLabModelDto(); var testTitle = testTitlesRepository.Get(sample.TestTitleId); var lab = hdlRegisrationRepository.Get(sample.LabId); var _patient = patient; var rateList = specializedLabRateListRepository.GetAll()?.ToList()?.Find(x => x.HdlId == lab.Id && x.TestTitleId == testTitle.Id); labSample.TestTitleId = testTitle.Id; labSample.TestGroupId = testTitle.GroupId; labSample.TestName = testTitle.Name; labSample.RegistrationDate = patient.RegistrationDate; labSample.PatientName = patient.FirstName + " " + patient.LastName; labSample.PatientCode = patient.PatientCode; labSample.PatientId = patient.Id; labSample.OutGoingLabName = lab.Name; labSample.OutGoingLabId = lab.Id; labSample.OriginalCharge = testTitle.Charges; labSample.LabCharge = (float)rateList.Charges; responseModel.SpecializedLabsSamples.Add(labSample); } } } } return(responseModel); }
public ActionResult GetSpecializedLabReport(SpecializedLabReportResponseModel requestModel) { try { var resposeModel = patientService.GetSpecializedLabReport(requestModel); if (resposeModel != null) { return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, resposeModel))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No lab samples found", "Something went wrong!")))); } } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", e.Message)))); } }
public async Task <SpecializedLabReportResponseModel> GetSpecializedLabReport(SpecializedLabReportResponseModel model) { var url = URLBuilder.GetURL(Controllers.PATIENT, EndPoint.PATIENT_GET_SPECIALIZED_LAB_SAMPLES_REPORT); return(await requestProvider.PostAsync(url, model)); }