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 manually
  # noinspection PyPep8Naming
  class DeviceComponentSchema:
      """
      The characteristics, operational status and capabilities of a medical-related
      component of a medical device.
      """
  
      # 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",
              "valueQuantity",
          ],
          extension_depth: int = 0,
          max_extension_depth: Optional[int] = 2,
      ) -> Union[StructType, DataType]:
          """
          The characteristics, operational status and capabilities of a medical-related
          component of a medical device.
  
  
          id: The logical id of the resource, as used in the URL for the resource. Once
              assigned, this value never changes.
  
          extension: May be used to represent additional information that is not part of the basic
              definition of the resource. In order 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 is allowed to define an extension,
              there is a set of requirements that SHALL be met as part of the definition of
              the extension.
  
          meta: The metadata about the resource. This is content that is maintained by the
              infrastructure. Changes to the content may not always be associated with
              version changes to the resource.
  
          implicitRules: A reference to a set of rules that were followed when the resource was
              constructed, and which must be understood when processing the content.
  
          language: The base language in which the resource is written.
  
          text: A human-readable narrative that contains a summary of the resource, and may be
              used to represent the content of the resource to a human. The narrative need
              not encode all the structured data, but is required to contain sufficient
              detail to make it "clinically safe" for a human to just read the narrative.
              Resource definitions may define what content should be represented in the
              narrative to ensure clinical safety.
  
          contained: These resources do not have an independent existence apart from the resource
              that contains them - they cannot be identified independently, and nor can they
              have their own independent transaction scope.
  
          resourceType: This is a DeviceComponent resource
  
          identifier: The locally assigned unique identification by the software. For example:
              handle ID.
  
          type: The component type as defined in the object-oriented or metric nomenclature
              partition.
  
          lastSystemChange: The timestamp for the most recent system change which includes device
              configuration or setting change.
  
          source: The link to the source Device that contains administrative device information
              such as manufacture, serial number, etc.
  
          parent: The link to the parent resource. For example: Channel is linked to its VMD
              parent.
  
          operationalStatus: The current operational status of the device. For example: On, Off, Standby,
              etc.
  
          parameterGroup: The parameter group supported by the current device component that is based on
              some nomenclature, e.g. cardiovascular.
  
          measurementPrinciple: The physical principle of the measurement. For example: thermal, chemical,
              acoustical, etc.
  
          productionSpecification: The production specification such as component revision, serial number, etc.
  
          languageCode: The language code for the human-readable text string produced by the device.
              This language code will follow the IETF language tag. Example: en-US.
  
          """
          from spark_fhir_schemas.stu3.complex_types.extension import ExtensionSchema
          from spark_fhir_schemas.stu3.complex_types.meta import MetaSchema
          from spark_fhir_schemas.stu3.complex_types.narrative import NarrativeSchema
          from spark_fhir_schemas.stu3.simple_types.resourcelist import ResourceListSchema
          from spark_fhir_schemas.stu3.complex_types.identifier import IdentifierSchema
          from spark_fhir_schemas.stu3.complex_types.codeableconcept import (
              CodeableConceptSchema,
          )
          from spark_fhir_schemas.stu3.complex_types.reference import ReferenceSchema
          from spark_fhir_schemas.stu3.complex_types.devicecomponent_productionspecification import (
              DeviceComponent_ProductionSpecificationSchema,
          )
  
          if (
              max_recursion_limit
              and nesting_list.count("DeviceComponent") >= 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 + ["DeviceComponent"]
          schema = StructType(
              [
                  # The logical id of the resource, as used in the URL for the resource. Once
                  # assigned, this value never changes.
                  StructField("id", StringType(), True),
                  # May be used to represent additional information that is not part of the basic
                  # definition of the resource. In order 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 is allowed to 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,
                          )
                      ),
                      True,
                  ),
                  # The metadata about the resource. This is content that is maintained by the
                  # infrastructure. Changes to the content may not always be associated with
                  # version changes to the resource.
                  StructField(
                      "meta",
                      MetaSchema.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,
                      ),
                      True,
                  ),
                  # A reference to a set of rules that were followed when the resource was
                  # constructed, and which must be understood when processing the content.
                  StructField("implicitRules", StringType(), True),
                  # The base language in which the resource is written.
                  StructField("language", StringType(), True),
                  # A human-readable narrative that contains a summary of the resource, and may be
                  # used to represent the content of the resource to a human. The narrative need
                  # not encode all the structured data, but is required to contain sufficient
                  # detail to make it "clinically safe" for a human to just read the narrative.
                  # Resource definitions may define what content should be represented in the
                  # narrative to ensure clinical safety.
                  StructField(
                      "text",
                      NarrativeSchema.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,
                      ),
                      True,
                  ),
                  # These resources do not have an independent existence apart from the resource
                  # that contains them - they cannot be identified independently, and nor can they
                  # have their own independent transaction scope.
                  StructField(
                      "contained",
                      ArrayType(
                          ResourceListSchema.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,
                          )
                      ),
                      True,
                  ),
                  # This is a DeviceComponent resource
                  StructField("resourceType", StringType(), True),
                  # The locally assigned unique identification by the software. For example:
                  # handle ID.
                  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,
                      ),
                      True,
                  ),
                  # The component type as defined in the object-oriented or metric nomenclature
                  # partition.
                  StructField(
                      "type",
                      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,
                      ),
                      True,
                  ),
                  # The timestamp for the most recent system change which includes device
                  # configuration or setting change.
                  StructField("lastSystemChange", StringType(), True),
                  # The link to the source Device that contains administrative device information
                  # such as manufacture, serial number, etc.
                  StructField(
                      "source",
                      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,
                      ),
                      True,
                  ),
                  # The link to the parent resource. For example: Channel is linked to its VMD
                  # parent.
                  StructField(
                      "parent",
                      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,
                      ),
                      True,
                  ),
                  # The current operational status of the device. For example: On, Off, Standby,
                  # etc.
                  StructField(
                      "operationalStatus",
                      ArrayType(
                          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,
                              max_extension_depth=max_extension_depth,
                          )
                      ),
                      True,
                  ),
                  # The parameter group supported by the current device component that is based on
                  # some nomenclature, e.g. cardiovascular.
                  StructField(
                      "parameterGroup",
                      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,
                      ),
                      True,
                  ),
                  # The physical principle of the measurement. For example: thermal, chemical,
                  # acoustical, etc.
                  StructField("measurementPrinciple", StringType(), True),
                  # The production specification such as component revision, serial number, etc.
                  StructField(
                      "productionSpecification",
                      ArrayType(
                          DeviceComponent_ProductionSpecificationSchema.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,
                          )
                      ),
                      True,
                  ),
                  # The language code for the human-readable text string produced by the device.
                  # This language code will follow the IETF language tag. Example: en-US.
                  StructField(
                      "languageCode",
                      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,
                      ),
                      True,
                  ),
              ]
          )
          if not include_extension:
              schema.fields = [
                  c
                  if c.name != "extension"
                  else StructField("extension", StringType(), True)
                  for c in schema.fields
              ]
  
          return schema
  