Example #1
0
        public CohortRuleResponse Run(CareTeam careTeam, CohortRuleCheckData data)
        {
            var response = new CohortRuleResponse();

            if (careTeam == null)
            {
                throw new ArgumentNullException("careTeam");
            }

            try
            {
                var activeCorePCM = _cohortRuleUtil.GetCareTeamActiveCorePCM(careTeam);

                if (activeCorePCM != null)
                {
                    //We need to add Active Core PCM from the CohortPatientView for the referenced individual
                    if (!data.UsersContactIds.IsNullOrEmpty())
                    {
                        _contactEndpointUtil.AddPCMToCohortPatientView(data.PatientId, activeCorePCM.ContactId, data.Version, data.ContractNumber, data.UserId, data.UsersContactIds.Contains(activeCorePCM.ContactId));
                    }
                }

                response.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                response.IsSuccessful = false;
                response.ErrorCode    = "UnAssignedPCMRule.Cohort.Error";
                response.Message      = ex.Message;

                _logger.Log(ex);
            }
            return(response);
        }