text: from typing import Union, List, Optional
  
  from pyspark.sql.types import (
      StructType,
      StructField,
      StringType,
      ArrayType,
      BooleanType,
      DataType,
  )
  
  
  # This file is auto-generated by generate_schema so do not edit it manually
  # noinspection PyPep8Naming
  class ElementDefinition_SlicingSchema:
      """
      Captures constraints on each element within the resource, profile, or
      extension.
      """
  
      # noinspection PyDefaultArgument
      @staticmethod
      def get_schema(
          max_nesting_depth: Optional[int] = 6,
          nesting_depth: int = 0,
          nesting_list: List[str] = [],
          max_recursion_limit: Optional[int] = 2,
          include_extension: Optional[bool] = False,
          extension_fields: Optional[List[str]] = None,
          extension_depth: int = 0,
          max_extension_depth: Optional[int] = 2,
          include_modifierExtension: Optional[bool] = False,
          use_date_for: Optional[List[str]] = None,
          parent_path: Optional[str] = "",
      ) -> Union[StructType, DataType]:
          """
          Captures constraints on each element within the resource, profile, or
          extension.
  
  
          id: Unique id for the element within a resource (for internal references). This
              may be any string value that does not contain spaces.
  
          extension: May be used to represent additional information that is not part of the basic
              definition of the element. To make the use of extensions safe and manageable,
              there is a strict set of governance  applied to the definition and use of
              extensions. Though any implementer can define an extension, there is a set of
              requirements that SHALL be met as part of the definition of the extension.
  
          modifierExtension: May be used to represent additional information that is not part of the basic
              definition of the element and that modifies the understanding of the element
              in which it is contained and/or the understanding of the containing element's
              descendants. Usually modifier elements provide negation or qualification. To
              make the use of extensions safe and manageable, there is a strict set of
              governance applied to the definition and use of extensions. Though any
              implementer can define an extension, there is a set of requirements that SHALL
              be met as part of the definition of the extension. Applications processing a
              resource are required to check for modifier extensions.
  
              Modifier extensions SHALL NOT change the meaning of any elements on Resource
              or DomainResource (including cannot change the meaning of modifierExtension
              itself).
  
          discriminator: Designates which child elements are used to discriminate between the slices
              when processing an instance. If one or more discriminators are provided, the
              value of the child elements in the instance data SHALL completely distinguish
              which slice the element in the resource matches based on the allowed values
              for those elements in each of the slices.
  
          description: A human-readable text description of how the slicing works. If there is no
              discriminator, this is required to be present to provide whatever information
              is possible about how the slices can be differentiated.
  
          ordered: If the matching elements have to occur in the same order as defined in the
              profile.
  
          rules: Whether additional slices are allowed or not. When the slices are ordered,
              profile authors can also say that additional slices are only allowed at the
              end.
  
          """
          if extension_fields is None:
              extension_fields = [
                  "valueBoolean",
                  "valueCode",
                  "valueDate",
                  "valueDateTime",
                  "valueDecimal",
                  "valueId",
                  "valueInteger",
                  "valuePositiveInt",
                  "valueString",
                  "valueTime",
                  "valueUnsignedInt",
                  "valueUri",
                  "valueUrl",
                  "valueReference",
                  "valueCodeableConcept",
                  "valueAddress",
              ]
          from spark_fhir_schemas.r4.complex_types.extension import ExtensionSchema
          from spark_fhir_schemas.r4.complex_types.elementdefinition_discriminator import (
              ElementDefinition_DiscriminatorSchema,
          )
  
          if (
              max_recursion_limit
              and nesting_list.count("ElementDefinition_Slicing") >= max_recursion_limit
          ) or (max_nesting_depth and nesting_depth >= max_nesting_depth):
              return StructType([StructField("id", StringType(), True)])
          # add my name to recursion list for later
          my_nesting_list: List[str] = nesting_list + ["ElementDefinition_Slicing"]
          my_parent_path = (
              parent_path + ".elementdefinition_slicing"
              if parent_path
              else "elementdefinition_slicing"
          )
          schema = StructType(
              [
                  # Unique id for the element within a resource (for internal references). This
                  # may be any string value that does not contain spaces.
                  StructField("id", StringType(), True),
                  # May be used to represent additional information that is not part of the basic
                  # definition of the element. To make the use of extensions safe and manageable,
                  # there is a strict set of governance  applied to the definition and use of
                  # extensions. Though any implementer can define an extension, there is a set of
                  # requirements that SHALL be met as part of the definition of the extension.
                  StructField(
                      "extension",
                      ArrayType(
                          ExtensionSchema.get_schema(
                              max_nesting_depth=max_nesting_depth,
                              nesting_depth=nesting_depth + 1,
                              nesting_list=my_nesting_list,
                              max_recursion_limit=max_recursion_limit,
                              include_extension=include_extension,
                              extension_fields=extension_fields,
                              extension_depth=extension_depth,
                              max_extension_depth=max_extension_depth,
                              include_modifierExtension=include_modifierExtension,
                              use_date_for=use_date_for,
                              parent_path=my_parent_path,
                          )
                      ),
                      True,
                  ),
                  # May be used to represent additional information that is not part of the basic
                  # definition of the element and that modifies the understanding of the element
                  # in which it is contained and/or the understanding of the containing element's
                  # descendants. Usually modifier elements provide negation or qualification. To
                  # make the use of extensions safe and manageable, there is a strict set of
                  # governance applied to the definition and use of extensions. Though any
                  # implementer can define an extension, there is a set of requirements that SHALL
                  # be met as part of the definition of the extension. Applications processing a
                  # resource are required to check for modifier extensions.
                  #
                  # Modifier extensions SHALL NOT change the meaning of any elements on Resource
                  # or DomainResource (including cannot change the meaning of modifierExtension
                  # itself).
                  StructField(
                      "modifierExtension",
                      ArrayType(
                          ExtensionSchema.get_schema(
                              max_nesting_depth=max_nesting_depth,
                              nesting_depth=nesting_depth + 1,
                              nesting_list=my_nesting_list,
                              max_recursion_limit=max_recursion_limit,
                              include_extension=include_extension,
                              extension_fields=extension_fields,
                              extension_depth=extension_depth,
                              max_extension_depth=max_extension_depth,
                              include_modifierExtension=include_modifierExtension,
                              use_date_for=use_date_for,
                              parent_path=my_parent_path,
                          )
                      ),
                      True,
                  ),
                  # Designates which child elements are used to discriminate between the slices
                  # when processing an instance. If one or more discriminators are provided, the
                  # value of the child elements in the instance data SHALL completely distinguish
                  # which slice the element in the resource matches based on the allowed values
                  # for those elements in each of the slices.
                  StructField(
                      "discriminator",
                      ArrayType(
                          ElementDefinition_DiscriminatorSchema.get_schema(
                              max_nesting_depth=max_nesting_depth,
                              nesting_depth=nesting_depth + 1,
                              nesting_list=my_nesting_list,
                              max_recursion_limit=max_recursion_limit,
                              include_extension=include_extension,
                              extension_fields=extension_fields,
                              extension_depth=extension_depth,
                              max_extension_depth=max_extension_depth,
                              include_modifierExtension=include_modifierExtension,
                              use_date_for=use_date_for,
                              parent_path=my_parent_path,
                          )
                      ),
                      True,
                  ),
                  # A human-readable text description of how the slicing works. If there is no
                  # discriminator, this is required to be present to provide whatever information
                  # is possible about how the slices can be differentiated.
                  StructField("description", StringType(), True),
                  # If the matching elements have to occur in the same order as defined in the
                  # profile.
                  StructField("ordered", BooleanType(), True),
                  # Whether additional slices are allowed or not. When the slices are ordered,
                  # profile authors can also say that additional slices are only allowed at the
                  # end.
                  StructField("rules", StringType(), True),
              ]
          )
          if not include_extension:
              schema.fields = [
                  c
                  if c.name != "extension"
                  else StructField("extension", StringType(), True)
                  for c in schema.fields
              ]
  
          if not include_modifierExtension:
              schema.fields = [
                  c
                  if c.name != "modifierExtension"
                  else StructField("modifierExtension", StringType(), True)
                  for c in schema.fields
              ]
  
          return schema
  