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); }
public CohortRuleResponse Run(CareTeam careTeam, CohortRuleCheckData data) { var response = new CohortRuleResponse(); try { if (careTeam == null) { throw new ArgumentNullException("careTeam"); } //Check if any of the members have active core PCM role. if (!_cohortRuleUtil.CheckIfCareTeamHasActiveCorePCM(careTeam)) { //Add to UnAssigned PCM. var isSuccessful = _contactEndpointUtil.RemovePCMCohortPatientView(data.PatientId, data.Version, data.ContractNumber, data.UserId); response.IsSuccessful = isSuccessful; } } catch (Exception ex) { response.IsSuccessful = false; response.ErrorCode = "UnAssignedPCMRule.Cohort.Error"; response.Message = ex.Message; _logger.Log(ex); } return(response); }
public CohortRuleResponse Run(CareTeam careTeam, CohortRuleCheckData data) { var response = new CohortRuleResponse(); try { if (careTeam == null) { throw new ArgumentNullException("careTeam"); } //For each member in the careteam that is a user, add an ATO cohort for the referenced individual var contactIdsToAdd = new List <string>(); foreach (var member in careTeam.Members) { if (member.StatusId == (int)CareTeamMemberStatus.Active) { if (data.UsersContactIds.Contains(member.ContactId)) { contactIdsToAdd.Add(member.ContactId); } } } _contactEndpointUtil.AssignContactsToCohortPatientView(data.PatientId, contactIdsToAdd.Distinct().ToList(), data.Version, data.ContractNumber, data.UserId); response.IsSuccessful = true; } catch (Exception ex) { response.IsSuccessful = false; response.ErrorCode = "AssignedToMeRule.Cohort.Error"; response.Message = ex.Message; _logger.Log(ex); } return(response); }