public PatientWithRateListChargesRequest GetPatientWithRateListCharges(PatientWithRateListChargesRequest model)
        {
            var response = model;

            if (model.FromDate == null || model.ToDate == null)
            {
                throw new Exception("Please enter valid from and to dates");
            }

            var patients = patientsRepository.GetAll().Where(x => x.RegistrationDate >= model.FromDate && x.RegistrationDate <= model.ToDate).ToList();

            if (patients != null && patients.Count > 0)
            {
                var patientsOfHdls = patients.Where(x => x.ReferredBy == model.HdlId)?.ToList();
                if (patientsOfHdls != null && patientsOfHdls.Count > 0)
                {
                    model.Patients = new List <Models.Dto.PatientWithRateListTestCharges>();
                    foreach (var patientOfHdl in patientsOfHdls)
                    {
                        var testResults = testResultsRepository.GetAll().Where(x => x.PatientId == patientOfHdl.Id).ToList();
                        var hdl         = hdlRegisrationRepository.Get((int)patientOfHdl.ReferredBy);
                        var rates       = monthlyRateListRepository.GetAll()?.Where(x => x.HdlId == hdl.Id)?.ToList();
                        patientOfHdl.TestTitles = new List <TestTitles>();
                        if (testResults != null && testResults.Count > 0)
                        {
                            foreach (var testResult in testResults)
                            {
                                var testTitle = testTitlesRepository.Get(testResult.TitleId);
                                if (!patientOfHdl.TestTitles.Contains(testTitle))
                                {
                                    var rate = rates.Find(x => x.TestTitleId == testTitle.Id);
                                    if (rate != null)
                                    {
                                        testTitle.Charges = (int)(rate.Charges);
                                    }
                                    testTitle.Group = testGroupsRepository.Get(testTitle.GroupId);
                                    patientOfHdl.TestTitles.Add(testTitle);
                                }
                            }
                        }

                        var patientModel = new Models.Dto.PatientWithRateListTestCharges
                        {
                            PatientCode = patientOfHdl.PatientCode,
                            PatientId   = patientOfHdl.Id,
                            PatientName = $"{patientOfHdl.FirstName} {patientOfHdl.LastName}"
                        };
                        patientModel.TestTitles.AddRange(patientOfHdl.TestTitles);

                        model.Patients.Add(patientModel);
                    }
                }
            }

            return(response);
        }
        public ActionResult GetPatientWithTestsWithRateListCharges(PatientWithRateListChargesRequest requestModel)
        {
            var resposeModel = patientService.GetPatientWithRateListCharges(requestModel);

            if (resposeModel != null)
            {
                return(Ok(GetResponse(ResponseType.OBJECT, ResponseStatusCode.SUCCESS, resposeModel)));
            }
            else
            {
                return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "No patients found", "Please register a patient"))));
            }
        }
예제 #3
0
        public async Task <PatientWithRateListChargesRequest> GetPatientWithRateListCharges(PatientWithRateListChargesRequest model)
        {
            var url = URLBuilder.GetURL(Controllers.PATIENT, EndPoint.PATIENT_GET_WITH_RATE_LIST_CHARGES);

            return(await requestProvider.PostAsync(url, model));
        }