private List <MedicationFollowupDto> GetTimings(MedicationDto medication, MedicationFollowupDto followup, IList <MedicationFollowupDto> followups = null)
        {
            var timingRecords = new List <MedicationFollowupDto>();

            var(intTimings, timingList) = MedicationHelper.GetMedicationFrequentyInNumber(medication.Frenquency);

            if (timingList == null)
            {
                timingRecords.Add(followup);
            }

            foreach (var timingItem in timingList)
            {
                var item = new MedicationFollowupDto
                {
                    MedicationId = medication.Id,
                    //  Status = (int)MedicationFollowupStatus.NOTTAKEN,
                    TakenDate = followup.TakenDate,
                    TakenTime = timingItem
                };
                var takenRecords = followups?.Where(x => x.TakenTime == timingItem).FirstOrDefault();
                if (takenRecords != null)
                {
                    timingRecords.Add(takenRecords);
                }
                else
                {
                    item.Status = (int)MedicationFollowupStatus.NOTTAKEN;
                    timingRecords.Add(item);
                }
            }
            return(timingRecords);
        }
        private List <MedicationFollowupDto> GetDefaultFollowupWithTimings(MedicationDto medication, IList <MedicationFollowupDto> followups = null)
        {
            List <MedicationFollowupDto> medicationFollowupList = new List <MedicationFollowupDto>();

            if (medication.EffectiveDate == null)
            {
                return(null);
            }
            var startDate = medication.EffectiveDate.GetValueOrDefault();
            var endDate   = startDate.AddDays(medication.Duration);

            for (int i = 0; i < medication.Duration; i++)
            {
                MedicationFollowupDto result = new MedicationFollowupDto();
                result.MedicationId = medication.Id;
                result.Status       = (int)MedicationFollowupStatus.NOTTAKEN;
                result.TakenDate    = startDate.AddDays(i);
                result.TakenTime    = string.Empty;

                //Get timings


                if (followups != null)
                {
                    var originalRecord = followups.Where(x => x.TakenDate.Day == result.TakenDate.Day && x.TakenDate.Month == result.TakenDate.Month &&
                                                         x.TakenDate.Year == result.TakenDate.Year).ToList();
                    if (originalRecord.Any())
                    {
                        //  medicationFollowupList.AddRange(originalRecord);
                        var filterItems = GetTimings(medication, result, originalRecord);
                        medicationFollowupList.AddRange(filterItems);
                    }
                    else
                    {
                        // medicationFollowupList.Add(result);
                        var filterItems = GetTimings(medication, result, null);
                        medicationFollowupList.AddRange(filterItems);
                    }
                }
                else
                {
                    //   medicationFollowupList.Add(result);
                    var filterItems = GetTimings(medication, result, null);
                    medicationFollowupList.AddRange(filterItems);
                }
            }
            return(medicationFollowupList);
        }