text: from typing import Union, List, Optional
  
  from pyspark.sql.types import StructType, StructField, StringType, ArrayType, DataType
  
  
  # This file is auto-generated by generate_schema so do not edit it manually
  # noinspection PyPep8Naming
  class Contract_ValuedItemSchema:
      """
      Legally enforceable, formally recorded unilateral or bilateral directive i.e.,
      a policy or agreement.
      """
  
      # 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]] = [
              "valueBoolean",
              "valueCode",
              "valueDate",
              "valueDateTime",
              "valueDecimal",
              "valueId",
              "valueInteger",
              "valuePositiveInt",
              "valueString",
              "valueTime",
              "valueUnsignedInt",
              "valueUri",
              "valueUrl",
          ],
          extension_depth: int = 0,
          max_extension_depth: Optional[int] = 2,
          include_modifierExtension: Optional[bool] = False,
      ) -> Union[StructType, DataType]:
          """
          Legally enforceable, formally recorded unilateral or bilateral directive i.e.,
          a policy or agreement.
  
  
          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).
  
          entityCodeableConcept: Specific type of Contract Valued Item that may be priced.
  
          entityReference: Specific type of Contract Valued Item that may be priced.
  
          identifier: Identifies a Contract Valued Item instance.
  
          effectiveTime: Indicates the time during which this Contract ValuedItem information is
              effective.
  
          quantity: Specifies the units by which the Contract Valued Item is measured or counted,
              and quantifies the countable or measurable Contract Valued Item instances.
  
          unitPrice: A Contract Valued Item unit valuation measure.
  
          factor: A real number that represents a multiplier used in determining the overall
              value of the Contract Valued Item delivered. The concept of a Factor allows
              for a discount or surcharge multiplier to be applied to a monetary amount.
  
          points: An amount that expresses the weighting (based on difficulty, cost and/or
              resource intensiveness) associated with the Contract Valued Item delivered.
              The concept of Points allows for assignment of point values for a Contract
              Valued Item, such that a monetary amount can be assigned to each point.
  
          net: Expresses the product of the Contract Valued Item unitQuantity and the
              unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per
              Point) * factor Number  * points = net Amount. Quantity, factor and points are
              assumed to be 1 if not supplied.
  
          payment: Terms of valuation.
  
          paymentDate: When payment is due.
  
          responsible: Who will make payment.
  
          recipient: Who will receive payment.
  
          linkId: Id  of the clause or question text related to the context of this valuedItem
              in the referenced form or QuestionnaireResponse.
  
          securityLabelNumber: A set of security labels that define which terms are controlled by this
              condition.
  
          """
          from spark_fhir_schemas.r4.complex_types.extension import ExtensionSchema
          from spark_fhir_schemas.r4.complex_types.codeableconcept import (
              CodeableConceptSchema,
          )
          from spark_fhir_schemas.r4.complex_types.reference import ReferenceSchema
          from spark_fhir_schemas.r4.complex_types.identifier import IdentifierSchema
          from spark_fhir_schemas.r4.simple_types.datetime import dateTimeSchema
          from spark_fhir_schemas.r4.complex_types.quantity import QuantitySchema
          from spark_fhir_schemas.r4.complex_types.money import MoneySchema
          from spark_fhir_schemas.r4.simple_types.decimal import decimalSchema
          from spark_fhir_schemas.r4.simple_types.unsignedint import unsignedIntSchema
  
          if (
              max_recursion_limit
              and nesting_list.count("Contract_ValuedItem") >= 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 + ["Contract_ValuedItem"]
          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,
                          )
                      ),
                      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,
                          )
                      ),
                      True,
                  ),
                  # Specific type of Contract Valued Item that may be priced.
                  StructField(
                      "entityCodeableConcept",
                      CodeableConceptSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Specific type of Contract Valued Item that may be priced.
                  StructField(
                      "entityReference",
                      ReferenceSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Identifies a Contract Valued Item instance.
                  StructField(
                      "identifier",
                      IdentifierSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Indicates the time during which this Contract ValuedItem information is
                  # effective.
                  StructField(
                      "effectiveTime",
                      dateTimeSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Specifies the units by which the Contract Valued Item is measured or counted,
                  # and quantifies the countable or measurable Contract Valued Item instances.
                  StructField(
                      "quantity",
                      QuantitySchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # A Contract Valued Item unit valuation measure.
                  StructField(
                      "unitPrice",
                      MoneySchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # A real number that represents a multiplier used in determining the overall
                  # value of the Contract Valued Item delivered. The concept of a Factor allows
                  # for a discount or surcharge multiplier to be applied to a monetary amount.
                  StructField(
                      "factor",
                      decimalSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # An amount that expresses the weighting (based on difficulty, cost and/or
                  # resource intensiveness) associated with the Contract Valued Item delivered.
                  # The concept of Points allows for assignment of point values for a Contract
                  # Valued Item, such that a monetary amount can be assigned to each point.
                  StructField(
                      "points",
                      decimalSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Expresses the product of the Contract Valued Item unitQuantity and the
                  # unitPriceAmt. For example, the formula: unit Quantity * unit Price (Cost per
                  # Point) * factor Number  * points = net Amount. Quantity, factor and points are
                  # assumed to be 1 if not supplied.
                  StructField(
                      "net",
                      MoneySchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Terms of valuation.
                  StructField("payment", StringType(), True),
                  # When payment is due.
                  StructField(
                      "paymentDate",
                      dateTimeSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Who will make payment.
                  StructField(
                      "responsible",
                      ReferenceSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Who will receive payment.
                  StructField(
                      "recipient",
                      ReferenceSchema.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 + 1,
                          max_extension_depth=max_extension_depth,
                          include_modifierExtension=include_modifierExtension,
                      ),
                      True,
                  ),
                  # Id  of the clause or question text related to the context of this valuedItem
                  # in the referenced form or QuestionnaireResponse.
                  StructField("linkId", ArrayType(StringType()), True),
                  # A set of security labels that define which terms are controlled by this
                  # condition.
                  StructField(
                      "securityLabelNumber",
                      ArrayType(
                          unsignedIntSchema.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,
                          )
                      ),
                      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
  