original_docstring: 
          Given a list of claims, group claims that share diagnosis codes together into episodes.
  
          To avoid duplication, each claim is assigned to at most one episode of care.
  
          Args:
              claims (list(Claim)): list of claims to be grouped into episodes of care.
          Returns:
              list(list(Claim)), where each inner list forms a single episode.
          
docstring: Given a list of claims, group claims that share diagnosis codes together into episodes.
  To avoid duplication, each claim is assigned to at most one episode of care.
docstring_tokens: Given a list of claims group claims that share diagnosis codes together into episodes . To avoid duplication each claim is assigned to at most one episode of care .
code: def group_claims_by_common_diagnosis(self, claims):
          """
          Given a list of claims, group claims that share diagnosis codes together into episodes.
  
          To avoid duplication, each claim is assigned to at most one episode of care.
  
          Args:
              claims (list(Claim)): list of claims to be grouped into episodes of care.
          Returns:
              list(list(Claim)), where each inner list forms a single episode.
          """
          logger.debug('Group claims by common diagonisis.')
          claims_by_common_diagnosis = []
          for claim in claims:
              claim_dx_codes = self._get_relevant_diagnosis_codes([claim])
              # For each subset of claims we've already seen, check to see if the current claim
              # has any overlapping diagnosis codes.
              for claim_subset in claims_by_common_diagnosis:
                  other_dx_codes = self._get_relevant_diagnosis_codes(claim_subset)
                  # If a common code is present, add the current claim to the existing subset.
                  # If there were no common codes, use the current claim to start a new subset.
                  # Break to ensure that each claim is assigned to at most one subset.
                  if not claim_dx_codes.isdisjoint(other_dx_codes):
                      claim_subset.append(claim)
                      break
                  else:
                      claims_by_common_diagnosis.append([claim])
                      break
              # If no claims have been seen yet, start with a single subset.
              if claims_by_common_diagnosis == []:
                  claims_by_common_diagnosis.append([claim])
  
          return claims_by_common_diagnosis
code_tokens: def group_claims_by_common_diagnosis ( self , claims ) : logger . debug ( 'Group claims by common diagonisis.' ) claims_by_common_diagnosis = [ ] for claim in claims : claim_dx_codes = self . _get_relevant_diagnosis_codes ( [ claim ] ) for claim_subset in claims_by_common_diagnosis : other_dx_codes = self . _get_relevant_diagnosis_codes ( claim_subset ) if not claim_dx_codes . isdisjoint ( other_dx_codes ) : claim_subset . append ( claim ) break else : claims_by_common_diagnosis . append ( [ claim ] ) break if claims_by_common_diagnosis == [ ] : claims_by_common_diagnosis . append ( [ claim ] ) return claims_by_common_diagnosis
short_docstring: Given a list of claims, group claims that share diagnosis codes together into episodes.
short_docstring_tokens: Given a list of claims group claims that share diagnosis codes together into episodes .
comment: """
          Given a list of claims, group claims that share diagnosis codes together into episodes.
  
          To avoid duplication, each claim is assigned to at most one episode of care.
  
          Args:
              claims (list(Claim)): list of claims to be grouped into episodes of care.
          Returns:
              list(list(Claim)), where each inner list forms a single episode.
          """$SEP$# For each subset of claims we've already seen, check to see if the current claim$SEP$# has any overlapping diagnosis codes.$SEP$# If a common code is present, add the current claim to the existing subset.$SEP$# If there were no common codes, use the current claim to start a new subset.$SEP$# Break to ensure that each claim is assigned to at most one subset.$SEP$# If no claims have been seen yet, start with a single subset.