public ActionResult GetOPDsByHospitalId() { try { m_log.Info($"orgunit/opdList endpoint called with hospital id - {m_user.HospitalId}"); var opdResponse = m_orgUnitsService.GetOPDListByHospitalId(m_user.HospitalId, m_user.SecurityToken); return(Ok(opdResponse)); } catch (Exception e) { m_log.ErrorException("Exception thrown at GetOPDsByHospitalId ", e); throw; } }
public List <OPDListItem> GetOPDListForRuleSetId(long?departmentId, long hospitalId, Guid ruleSetId, Guid SecurityToken) { if (ruleSetId == null || ruleSetId == Guid.Empty) { throw new UserInputValidationException("RuleSetId cant't be null or empty"); } if (departmentId == 0) { throw new UserInputValidationException("Departmentid is not valid.0 is not a valid department id."); } List <OPDListItem> opdList = departmentId != null ? m_orgService.GetOPDListByDepartmentId((long)departmentId, SecurityToken) : m_orgService.GetOPDListByHospitalId((long)hospitalId, SecurityToken); var ruleSet = GetRuleSetById((Guid)ruleSetId); if (ruleSet.ExcludeOrgUnits.Count == 0) { return(opdList); } var newOPDList = new List <OPDListItem>(); foreach (var opd in opdList) { bool isAvailable = false; foreach (var _ in ruleSet.ExcludeOrgUnits.Where(unit => opd.UnitGid == unit.UnitID).Select(unit => new { })) { isAvailable = true; } if (!isAvailable) { newOPDList.Add(opd); } } return(newOPDList); }