code: def generate_nhs_number_from_first_9_digits(first9digits: str) -> Optional[int]:
      
      if len(first9digits) != 9:
          log.warning("Not 9 digits")
          return None
      try:
          first9int = int(first9digits)
      except (TypeError, ValueError):
          log.warning("Not an integer")
          return None  # not an int
      if len(str(first9int)) != len(first9digits):
          # e.g. leading zeros, or some such
          log.warning("Leading zeros?")
          return None
      check_digit = nhs_check_digit(first9digits)
      if check_digit == 10:  # NHS numbers with this check digit are all invalid
          log.warning("Can't have check digit of 10")
          return None
      return int(first9digits + str(check_digit))
docs: Returns a valid NHS number, as an ``int``, given the first 9 digits.
      The particular purpose is to make NHS numbers that *look* fake (rather
      than truly random NHS numbers which might accidentally be real).
  
      For example:
  
      .. code-block:: none
  
          123456789_ : no; checksum 10
          987654321_ : yes, valid if completed to 9876543210
          999999999_ : yes, valid if completed to 9999999999