internal InsuranceEditVM Transform(Domain2.Insurances.Insurance n)
        {
            InsuranceEditVM r = new InsuranceEditVM();

            r.ID   = n.ID;
            r.Name = n.Name;
            r.RequireCredentialsForBCBA = n.RequireCredentialsForBCBA.GetValueOrDefault(false);
            return(r);
        }
Example #2
0
        public Domain2.Insurances.Insurance Copy(Domain2.Insurances.Insurance source, string newInsuranceName)
        {
            var existingInsuranceByName = _context.Insurances.Where(x => x.Name == newInsuranceName).FirstOrDefault();

            if (existingInsuranceByName != null)
            {
                throw new InvalidOperationException("Insurance name already exists");
            }

            var ins = new Domain2.Insurances.Insurance();

            ins.Name   = newInsuranceName;
            ins.Active = true;
            ins.RequireCredentialsForBCBA = source.RequireCredentialsForBCBA;
            ins.AuthorizationMatchRules   = new List <Domain2.Authorizations.AuthorizationMatchRule>();
            ins.Services = new List <InsuranceService>();

            var rules    = source.AuthorizationMatchRules;
            var services = source.Services;

            foreach (var rule in rules)
            {
                ins.AuthorizationMatchRules.Add(new Domain2.Authorizations.AuthorizationMatchRule()
                {
                    AllowOverlapping         = rule.AllowOverlapping,
                    BillingMethod            = rule.BillingMethod,
                    FinalAuthorizationID     = rule.FinalAuthorizationID,
                    FinalMinimumMinutes      = rule.FinalMinimumMinutes,
                    FinalUnitSize            = rule.FinalUnitSize,
                    InitialAuthorizationID   = rule.InitialAuthorizationID,
                    InitialMinimumMinutes    = rule.InitialMinimumMinutes,
                    InitialUnitSize          = rule.InitialUnitSize,
                    ProviderTypeID           = rule.ProviderTypeID,
                    RequiresAuthorizedBCBA   = rule.RequiresAuthorizedBCBA,
                    RequiresPreAuthorization = rule.RequiresPreAuthorization,
                    ServiceID = rule.ServiceID
                });
            }

            foreach (var svc in services)
            {
                ins.Services.Add(new InsuranceService()
                {
                    DefectiveDate  = svc.DefectiveDate,
                    EffectiveDate  = svc.EffectiveDate,
                    ProviderTypeID = svc.ProviderTypeID,
                    ServiceID      = svc.ServiceID
                });
            }

            _context.Insurances.Add(ins);
            _context.SaveChanges();

            return(ins);
        }
        //[TestMethod]
        //public void AuthResolverRemovesExistingBreakdowns() {

        //}

        //[TestMethod]
        //public void AuthResolverNoAuthsIfNoInsurance() {

        //}

        //[TestMethod]
        //public void AuthResolveNoAuthsIfNoInsuranceAuthMatchRules() {

        //}

        //[TestMethod]
        //public void AuthResolverMatchesRulesOnServiceAndProviderType() {

        //}

        private static Mock<IResolutionServiceRepository> CreateMockResolutionServiceRepository()
        {
            var repoMock = new Mock<IResolutionServiceRepository>();
            var c = new Domain2.Cases.Case();
            var patient = new Domain2.Patients.Patient();
            var insurance = new Domain2.Insurances.Insurance();

            c.Patient = patient;
            patient.Insurance = insurance;

            repoMock.Setup(x => x.GetCase(It.IsAny<int>())).Returns(c);
            repoMock.Setup(x => x.GetActiveInsurance(It.IsAny<int>(), It.IsAny<DateTime>())).Returns(c.Patient.Insurance);
            return repoMock;
        }
Example #4
0
        private static Insurance MapInsurance(Domain2.Insurances.Insurance source)
        {
            if (source == null)
            {
                return(null);
            }
            var result = new Insurance
            {
                ID            = source.ID,
                InsuranceName = source.Name
            };

            return(result);
        }
Example #5
0
        public List <Service> GetServices(Domain2.Insurances.Insurance insurance, int providerTypeID, DateTime refDate)
        {
            if (insurance == null)
            {
                return(new List <Service>());
            }

            var serviceIDs = insurance.Services
                             .Where(x => (x.EffectiveDate == null || x.EffectiveDate <= refDate) &&
                                    (x.DefectiveDate == null || x.DefectiveDate >= refDate) &&
                                    x.ProviderTypeID == providerTypeID)
                             .Select(x => x.ServiceID)
                             .ToArray();

            return(_context.Services.Where(x => serviceIDs.Contains(x.ID)).ToList());
        }
Example #6
0
        public Domain2.Insurances.Insurance Create(string insuranceName)
        {
            var existingInsuranceByName = _context.Insurances.Where(x => x.Name == insuranceName).FirstOrDefault();

            if (existingInsuranceByName != null)
            {
                throw new InvalidOperationException("Insurance name already exists");
            }

            var ins = new Domain2.Insurances.Insurance();

            ins.Name     = insuranceName;
            ins.Active   = true;
            ins.Services = getDefaultServices();

            _context.Insurances.Add(ins);
            _context.SaveChanges();

            return(ins);
        }
Example #7
0
        public void Initialize()
        {
            _serviceList.Add(new Service()
            {
                ID = 1, Code = "A", Type = ServiceTypes.Assessment
            });
            _serviceList.Add(new Service()
            {
                ID = 2, Code = "B", Type = ServiceTypes.Assessment
            });
            _serviceList.Add(new Service()
            {
                ID = 3, Code = "C", Type = ServiceTypes.Care
            });
            _serviceList.Add(new Service()
            {
                ID = 4, Code = "D", Type = ServiceTypes.Care
            });
            _serviceList.Add(new Service()
            {
                ID = 5, Code = "E", Type = ServiceTypes.General
            });

            _providerTypeServiceList.Add(new ProviderTypeService()
            {
                ProviderTypeID = 15, Service = new Service()
                {
                    ID = 1
                }
            });
            _providerTypeServiceList.Add(new ProviderTypeService()
            {
                ProviderTypeID = 15, Service = new Service()
                {
                    ID = 2
                }
            });
            _providerTypeServiceList.Add(new ProviderTypeService()
            {
                ProviderTypeID = 17, Service = new Service()
                {
                    ID = 3
                }
            });
            _providerTypeServiceList.Add(new ProviderTypeService()
            {
                ProviderTypeID = 17, Service = new Service()
                {
                    ID = 4
                }
            });
            _providerTypeServiceList.Add(new ProviderTypeService()
            {
                ProviderTypeID = 19, Service = new Service()
                {
                    ID = 5
                }
            });

            var insuranceA = new Domain2.Insurances.Insurance();
            var insuranceB = new Domain2.Insurances.Insurance();

            insuranceA.Services.Add(new InsuranceService()
            {
                Service = _serviceList.Where(x => x.ID == 1).Single()
            });
            insuranceA.Services.Add(new InsuranceService()
            {
                Service       = _serviceList.Where(x => x.ID == 2).Single(),
                EffectiveDate = new DateTime(2000, 1, 1),
                DefectiveDate = new DateTime(2010, 1, 1)
            });
            insuranceA.Services.Add(new InsuranceService()
            {
                Service       = _serviceList.Where(x => x.ID == 3).Single(),
                EffectiveDate = new DateTime(2010, 1, 1),
                DefectiveDate = new DateTime(2020, 1, 1)
            });

            insuranceB.Services.Add(new InsuranceService()
            {
                Service = _serviceList.Where(x => x.ID == 1).Single()
            });
            insuranceB.Services.Add(new InsuranceService()
            {
                Service       = _serviceList.Where(x => x.ID == 2).Single(),
                EffectiveDate = new DateTime(2000, 1, 1),
                DefectiveDate = new DateTime(2010, 1, 1)
            });
            insuranceB.Services.Add(new InsuranceService()
            {
                Service       = _serviceList.Where(x => x.ID == 3).Single(),
                EffectiveDate = new DateTime(2010, 1, 1),
                DefectiveDate = new DateTime(2020, 1, 1)
            });

            _insurances.Add(insuranceA);
            _insurances.Add(insuranceB);

            _dbMock.Object.Services             = GetQueryableMockDbSet(_serviceList.ToArray());
            _dbMock.Object.ProviderTypeServices = GetQueryableMockDbSet(_providerTypeServiceList.ToArray());

            _serviceProvider = new ServiceProvider(_dbMock.Object);
        }
Example #8
0
 public List <Service> GetServices(Domain2.Insurances.Insurance insurance, int providerTypeID)
 {
     return(GetServices(insurance, providerTypeID, DateTime.Now));
 }