/// <summary>
 /// The get tariffs.
 /// </summary>
 /// <param name="startYearAndMonth">
 /// The start Year And Month.
 /// </param>
 /// <param name="fileName">
 /// The file Name.
 /// </param>
 /// <param name="tariffAction">
 /// The tariff Action.
 /// </param>
 public static void ProcessTariffs(string startYearAndMonth, string fileName, TariffAction tariffAction)
 {
     using (var dataAccessHelper = new TariffsDataAccessHelper())
     {
         var tariffs = dataAccessHelper.GetTariff(startYearAndMonth, fileName, tariffAction);
         Process(tariffs, fileName, tariffAction, dataAccessHelper, startYearAndMonth);
     }
 }
        /// <summary>
        /// Inserts the new tariff script.
        /// </summary>
        /// <param name="practitionerTypeIds">
        /// The practitioner type ids.
        /// </param>
        /// <param name="fileItemCode">
        /// The file item code.
        /// </param>
        /// <param name="fileDoctorRecommendedUnit">
        /// The file doctor recommended unit.
        /// </param>
        /// <param name="tariffBaseUnitCost">
        /// The tariff base unit cost.
        /// </param>
        /// <param name="newTariffNotLoadedPath">
        /// The new tariff not loaded path.
        /// </param>
        /// <param name="dataAccessHelper">
        /// The data access helper.
        /// </param>
        private static void InsertNewTariffScript(
            string practitionerTypeIds, 
            string fileItemCode, 
            decimal fileDoctorRecommendedUnit, 
            TariffBaseUnitCost tariffBaseUnitCost, 
            string newTariffNotLoadedPath, 
            TariffsDataAccessHelper dataAccessHelper)
        {
            if (string.IsNullOrEmpty(practitionerTypeIds))
            {
                return;
            }

            var pathologyPractitionerTypes = practitionerTypeIds.Split(',');

            var units = fileDoctorRecommendedUnit.ToString(CultureInfo.InvariantCulture).Replace(',', '.');

            var section = dataAccessHelper.GetTariff(fileItemCode);

            /*DateTime? validFrom = tariffBaseUnitCost.ValidFrom;
            var currentDateTime = DateTime.Now;
            DateTime? validTo = tariffBaseUnitCost.ValidTo;
            
            if (validFrom != null && validFrom.Value.Year < currentDateTime.Year)
            {
                var financialEnd = FinancialYearHelper.GetFinancialYearEnd(validFrom.Value);
                 validTo = DateTime.Parse(financialEnd);
            }*/
            foreach (var practitionerTypeId in pathologyPractitionerTypes)
            {
                var sectionId = 0;

                if (section != null)
                {
                    sectionId = section.SectionID;
                }

                var validfromDate = tariffBaseUnitCost.ValidFrom;

                var financialStart = string.Empty;
                var financialEnd = string.Empty;

                if (validfromDate.HasValue)
                {
                    financialStart = FinancialYearHelper.GetFinancialYearStart(validfromDate.Value);
                    financialEnd =
                        FinancialYearHelper.GetFinancialYearEnd(
                            DateTime.ParseExact(financialStart, Constant.DateFormat, null));
                }

                var scriptLine =
                    string.Format(
                        "EXEC Medical.USP_MaintainMedicalTariff '{0}',{1},{2},{3},'{4}','{5}',{6},{7},{8},NULL,'{9}','{10}'", 
                        fileItemCode, 
                        Constant.CoidTariffTypeId, 
                        units, 
                        tariffBaseUnitCost.TariffBaseUnitCostID, 
                        financialStart, 
                        financialEnd, 
                        practitionerTypeId, 
                        Constant.VatConstId, 
                        sectionId, 
                        "Tariff Upload - Gazzette", 
                        DateTime.Now);

                newTariffNotLoadedPath.WriteToFile(scriptLine);
            }
        }