Esempio n. 1
0
 public ActionResult GetOPDsByDepartmentId(long departmentId)
 {
     try
     {
         m_log.Info($"/department/opd endpoint called with department id - {departmentId}");
         var opdResponse = m_orgUnitsService.GetOPDListByDepartmentId(departmentId, m_user.SecurityToken);
         return(Ok(opdResponse));
     }
     catch (Exception e)
     {
         m_log.ErrorException("Exception thrown at GetOpdsByDepartmentId ", 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);
        }