////modified: ashim:25'July2018 Updated as per HAMS requirement YYMM000001 and incremental
        //public static string GetPatientCode(int patientNo, string connString)
        //{

        //    try
        //    {
        //        CoreDbContext coreDbContext = new CoreDbContext(connString);
        //        ParameterModel parameter = coreDbContext.Parameters
        //            .Where(a => a.ParameterName == "HospitalCode")
        //            .FirstOrDefault<ParameterModel>();
        //        if (parameter != null)
        //        {
        //            JObject paramValue = JObject.Parse(parameter.ParameterValue);
        //            return (string)paramValue["HospitalCode"] + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + String.Format("{0:D6}", patientNo);
        //        }
        //        else
        //        {
        //            throw new Exception("Invalid Paramenter Hospital Code");
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        throw new Exception(ex.Message);
        //    }
        //}


        public static PatientModel GetPatientModelFromPatientVM(GovInsurancePatientVM govPatientVM, string connString, PatientDbContext patDbContext)
        {
            //PatientModel retPat = new PatientModel();

            //GovInsurancePatientVM abc = new GovInsurancePatientVM()
            //{
            //    PatientId = 0,
            //    PatientNo = 0,
            //    PatientCode = null,
            //    FirstName = govPatientVM.FirstName,
            //    MiddleName = govPatientVM.MiddleName,
            //    LastName = govPatientVM.LastName,
            //    Age = govPatientVM.Age,
            //    Gender = govPatientVM.Gender,
            //    DateOfBirth = govPatientVM.DateOfBirth,
            //    Address = govPatientVM.Address,
            //    CountryId = govPatientVM.CountryId,
            //    CountrySubDivisionId = govPatientVM.CountrySubDivisionId,
            //    CountrySubDivisionName = govPatientVM.CountrySubDivisionName,
            //    MembershipTypeId = 0,
            //    PhoneNumber = govPatientVM.PhoneNumber
            //};


            PatientModel retPat = new PatientModel()
            {
                PatientId        = 0,
                PatientNo        = 0,
                PatientCode      = null,
                FirstName        = govPatientVM.FirstName,
                MiddleName       = govPatientVM.MiddleName,
                LastName         = govPatientVM.LastName,
                PatientNameLocal = govPatientVM.PatientNameLocal,
                Age                    = govPatientVM.Age,
                Gender                 = govPatientVM.Gender,
                DateOfBirth            = govPatientVM.DateOfBirth,
                Address                = govPatientVM.Address,
                CountryId              = govPatientVM.CountryId,
                CountrySubDivisionId   = govPatientVM.CountrySubDivisionId,
                CountrySubDivisionName = govPatientVM.CountrySubDivisionName,
                MembershipTypeId       = 0,
                PhoneNumber            = govPatientVM.PhoneNumber,
                IsActive               = govPatientVM.IsActive
            };



            NewPatientUniqueNumbersVM newPatientNumber = DanpheEMR.Controllers.PatientBL.GetPatNumberNCodeForNewPatient(connString);

            retPat.PatientNo   = newPatientNumber.PatientNo;
            retPat.PatientCode = newPatientNumber.PatientCode;

            if (retPat.MembershipTypeId == null || retPat.MembershipTypeId == 0)
            {
                var membership = patDbContext.MembershipTypes.Where(i => i.MembershipTypeName == "General").FirstOrDefault();
                retPat.MembershipTypeId = membership.MembershipTypeId;
            }

            return(retPat);
        }
        public static InsuranceModel GetInsuranceModelFromInsPatientVM(GovInsurancePatientVM govPatientVM)
        {
            InsuranceModel retInsInfo = new InsuranceModel()
            {
                InsuranceProviderId = govPatientVM.InsuranceProviderId,
                InsuranceName       = govPatientVM.InsuranceName,
                IMISCode            = govPatientVM.IMISCode,
                CreatedOn           = DateTime.Now,
                InitialBalance      = govPatientVM.InitialBalance,
                CurrentBalance      = govPatientVM.CurrentBalance
            };

            return(retInsInfo);
        }