Operation Details
Description: Operation to read the number of related cases based on a relatedCaseID.
Sterotype: ns
SQL
SELECT
  COUNT(*)
INTO
  :count 
FROM
  CaseRelationship 
WHERE 
  (
    
    (
      caseID = :caseID 
      OR relatedCaseID = :caseID 
    ) 
    AND 
    (
      relatedCaseID = :relatedCaseID 
      OR caseID = :relatedCaseID 
    ) 
  ) 
  AND 
  (
    statusCode = :statusCode 
    OR statusCode IS NULL 
  ) 
  AND 
  (
    
    (
      endDate >= :startDate 
      OR endDate IS NULL 
    ) 
    AND 
    (
      startDate <= :endDate 
      OR :endDate IS NULL 
    ) 
  ) 
  AND 
  (
    caseRelationshipID <> :caseRelationshipID 
    OR :caseRelationshipIDIsNull <> '0' 
  )