code: def is_valid_nhs_number(n: int) -> bool:
        # noqa
      if not isinstance(n, int):
          log.debug("is_valid_nhs_number: parameter was not of integer type")
          return False
  
      s = str(n)
      # Not 10 digits long?
      if len(s) != 10:
          log.debug("is_valid_nhs_number: not 10 digits")
          return False
  
      main_digits = [int(s[i]) for i in range(9)]
      actual_check_digit = int(s[9])  # tenth digit
      expected_check_digit = nhs_check_digit(main_digits)
      if expected_check_digit == 10:
          log.debug("is_valid_nhs_number: calculated check digit invalid")
          return False
      if expected_check_digit != actual_check_digit:
          log.debug("is_valid_nhs_number: check digit mismatch")
          return False
      # Hooray!
      return True
docs: Validates an integer as an NHS number.
      
      Args:
          n: NHS number
  
      Returns:
          valid?
  
      Checksum details are at
      http://www.datadictionary.nhs.uk/version2/data_dictionary/data_field_notes/n/nhs_number_de.asp