text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: comprehendmedical
using AWS.Compat
using AWS.UUIDs

"""
    describe_entities_detection_v2_job(job_id)
    describe_entities_detection_v2_job(job_id, params::Dict{String,<:Any})

Gets the properties associated with a medical entities detection job. Use this operation to
get the status of a detection job.

# Arguments
- `job_id`: The identifier that Amazon Comprehend Medical generated for the job. The
  StartEntitiesDetectionV2Job operation returns this identifier in its response.

"""
describe_entities_detection_v2_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeEntitiesDetectionV2Job", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
describe_entities_detection_v2_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeEntitiesDetectionV2Job", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    describe_icd10_cminference_job(job_id)
    describe_icd10_cminference_job(job_id, params::Dict{String,<:Any})

Gets the properties associated with an InferICD10CM job. Use this operation to get the
status of an inference job.

# Arguments
- `job_id`: The identifier that Amazon Comprehend Medical generated for the job. The
  StartICD10CMInferenceJob operation returns this identifier in its response.

"""
describe_icd10_cminference_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeICD10CMInferenceJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
describe_icd10_cminference_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeICD10CMInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    describe_phidetection_job(job_id)
    describe_phidetection_job(job_id, params::Dict{String,<:Any})

Gets the properties associated with a protected health information (PHI) detection job. Use
this operation to get the status of a detection job.

# Arguments
- `job_id`: The identifier that Amazon Comprehend Medical generated for the job. The
  StartPHIDetectionJob operation returns this identifier in its response.

"""
describe_phidetection_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribePHIDetectionJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
describe_phidetection_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribePHIDetectionJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    describe_rx_norm_inference_job(job_id)
    describe_rx_norm_inference_job(job_id, params::Dict{String,<:Any})

Gets the properties associated with an InferRxNorm job. Use this operation to get the
status of an inference job.

# Arguments
- `job_id`: The identifier that Amazon Comprehend Medical generated for the job. The
  StartRxNormInferenceJob operation returns this identifier in its response.

"""
describe_rx_norm_inference_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeRxNormInferenceJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
describe_rx_norm_inference_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DescribeRxNormInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    detect_entities(text)
    detect_entities(text, params::Dict{String,<:Any})

The DetectEntities operation is deprecated. You should use the DetectEntitiesV2 operation
instead.  Inspects the clinical text for a variety of medical entities and returns specific
information about them such as entity category, location, and confidence score on that
information .

# Arguments
- `text`:  A UTF-8 text string containing the clinical content being examined for entities.
  Each string must contain fewer than 20,000 bytes of characters.

"""
detect_entities(Text; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectEntities", Dict{String, Any}("Text"=>Text); aws_config=aws_config)
detect_entities(Text, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectEntities", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Text"=>Text), params)); aws_config=aws_config)

"""
    detect_entities_v2(text)
    detect_entities_v2(text, params::Dict{String,<:Any})

Inspects the clinical text for a variety of medical entities and returns specific
information about them such as entity category, location, and confidence score on that
information. Amazon Comprehend Medical only detects medical entities in English language
texts. The DetectEntitiesV2 operation replaces the DetectEntities operation. This new
action uses a different model for determining the entities in your medical text and changes
the way that some entities are returned in the output. You should use the DetectEntitiesV2
operation in all new applications. The DetectEntitiesV2 operation returns the Acuity and
Direction entities as attributes instead of types.

# Arguments
- `text`: A UTF-8 string containing the clinical content being examined for entities. Each
  string must contain fewer than 20,000 bytes of characters.

"""
detect_entities_v2(Text; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectEntitiesV2", Dict{String, Any}("Text"=>Text); aws_config=aws_config)
detect_entities_v2(Text, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectEntitiesV2", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Text"=>Text), params)); aws_config=aws_config)

"""
    detect_phi(text)
    detect_phi(text, params::Dict{String,<:Any})

 Inspects the clinical text for protected health information (PHI) entities and returns the
entity category, location, and confidence score for each entity. Amazon Comprehend Medical
only detects entities in English language texts.

# Arguments
- `text`:  A UTF-8 text string containing the clinical content being examined for PHI
  entities. Each string must contain fewer than 20,000 bytes of characters.

"""
detect_phi(Text; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectPHI", Dict{String, Any}("Text"=>Text); aws_config=aws_config)
detect_phi(Text, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("DetectPHI", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Text"=>Text), params)); aws_config=aws_config)

"""
    infer_icd10_cm(text)
    infer_icd10_cm(text, params::Dict{String,<:Any})

InferICD10CM detects medical conditions as entities listed in a patient record and links
those entities to normalized concept identifiers in the ICD-10-CM knowledge base from the
Centers for Disease Control. Amazon Comprehend Medical only detects medical entities in
English language texts.

# Arguments
- `text`: The input text used for analysis. The input for InferICD10CM is a string from 1
  to 10000 characters.

"""
infer_icd10_cm(Text; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("InferICD10CM", Dict{String, Any}("Text"=>Text); aws_config=aws_config)
infer_icd10_cm(Text, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("InferICD10CM", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Text"=>Text), params)); aws_config=aws_config)

"""
    infer_rx_norm(text)
    infer_rx_norm(text, params::Dict{String,<:Any})

InferRxNorm detects medications as entities listed in a patient record and links to the
normalized concept identifiers in the RxNorm database from the National Library of
Medicine. Amazon Comprehend Medical only detects medical entities in English language
texts.

# Arguments
- `text`: The input text used for analysis. The input for InferRxNorm is a string from 1 to
  10000 characters.

"""
infer_rx_norm(Text; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("InferRxNorm", Dict{String, Any}("Text"=>Text); aws_config=aws_config)
infer_rx_norm(Text, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("InferRxNorm", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Text"=>Text), params)); aws_config=aws_config)

"""
    list_entities_detection_v2_jobs()
    list_entities_detection_v2_jobs(params::Dict{String,<:Any})

Gets a list of medical entity detection jobs that you have submitted.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Filter"`: Filters the jobs that are returned. You can filter jobs based on their names,
  status, or the date and time that they were submitted. You can only set one filter at a
  time.
- `"MaxResults"`: The maximum number of results to return in each page. The default is 100.
- `"NextToken"`: Identifies the next page of results to return.
"""
list_entities_detection_v2_jobs(; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListEntitiesDetectionV2Jobs"; aws_config=aws_config)
list_entities_detection_v2_jobs(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListEntitiesDetectionV2Jobs", params; aws_config=aws_config)

"""
    list_icd10_cminference_jobs()
    list_icd10_cminference_jobs(params::Dict{String,<:Any})

Gets a list of InferICD10CM jobs that you have submitted.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Filter"`: Filters the jobs that are returned. You can filter jobs based on their names,
  status, or the date and time that they were submitted. You can only set one filter at a
  time.
- `"MaxResults"`: The maximum number of results to return in each page. The default is 100.
- `"NextToken"`: Identifies the next page of results to return.
"""
list_icd10_cminference_jobs(; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListICD10CMInferenceJobs"; aws_config=aws_config)
list_icd10_cminference_jobs(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListICD10CMInferenceJobs", params; aws_config=aws_config)

"""
    list_phidetection_jobs()
    list_phidetection_jobs(params::Dict{String,<:Any})

Gets a list of protected health information (PHI) detection jobs that you have submitted.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Filter"`: Filters the jobs that are returned. You can filter jobs based on their names,
  status, or the date and time that they were submitted. You can only set one filter at a
  time.
- `"MaxResults"`: The maximum number of results to return in each page. The default is 100.
- `"NextToken"`: Identifies the next page of results to return.
"""
list_phidetection_jobs(; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListPHIDetectionJobs"; aws_config=aws_config)
list_phidetection_jobs(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListPHIDetectionJobs", params; aws_config=aws_config)

"""
    list_rx_norm_inference_jobs()
    list_rx_norm_inference_jobs(params::Dict{String,<:Any})

Gets a list of InferRxNorm jobs that you have submitted.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Filter"`: Filters the jobs that are returned. You can filter jobs based on their names,
  status, or the date and time that they were submitted. You can only set one filter at a
  time.
- `"MaxResults"`: Identifies the next page of results to return.
- `"NextToken"`: Identifies the next page of results to return.
"""
list_rx_norm_inference_jobs(; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListRxNormInferenceJobs"; aws_config=aws_config)
list_rx_norm_inference_jobs(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("ListRxNormInferenceJobs", params; aws_config=aws_config)

"""
    start_entities_detection_v2_job(data_access_role_arn, input_data_config, language_code, output_data_config)
    start_entities_detection_v2_job(data_access_role_arn, input_data_config, language_code, output_data_config, params::Dict{String,<:Any})

Starts an asynchronous medical entity detection job for a collection of documents. Use the
DescribeEntitiesDetectionV2Job operation to track the status of a job.

# Arguments
- `data_access_role_arn`: The Amazon Resource Name (ARN) of the AWS Identity and Access
  Management (IAM) role that grants Amazon Comprehend Medical read access to your input data.
  For more information, see  Role-Based Permissions Required for Asynchronous Operations.
- `input_data_config`: Specifies the format and location of the input data for the job.
- `language_code`: The language of the input documents. All documents must be in the same
  language.
- `output_data_config`: Specifies where to send the output files.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ClientRequestToken"`: A unique identifier for the request. If you don't set the client
  request token, Amazon Comprehend Medical generates one.
- `"JobName"`: The identifier of the job.
- `"KMSKey"`: An AWS Key Management Service key to encrypt your output files. If you do not
  specify a key, the files are written in plain text.
"""
start_entities_detection_v2_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartEntitiesDetectionV2Job", Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())); aws_config=aws_config)
start_entities_detection_v2_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartEntitiesDetectionV2Job", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())), params)); aws_config=aws_config)

"""
    start_icd10_cminference_job(data_access_role_arn, input_data_config, language_code, output_data_config)
    start_icd10_cminference_job(data_access_role_arn, input_data_config, language_code, output_data_config, params::Dict{String,<:Any})

Starts an asynchronous job to detect medical conditions and link them to the ICD-10-CM
ontology. Use the DescribeICD10CMInferenceJob operation to track the status of a job.

# Arguments
- `data_access_role_arn`: The Amazon Resource Name (ARN) of the AWS Identity and Access
  Management (IAM) role that grants Amazon Comprehend Medical read access to your input data.
  For more information, see  Role-Based Permissions Required for Asynchronous Operations.
- `input_data_config`: Specifies the format and location of the input data for the job.
- `language_code`: The language of the input documents. All documents must be in the same
  language.
- `output_data_config`: Specifies where to send the output files.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ClientRequestToken"`: A unique identifier for the request. If you don't set the client
  request token, Amazon Comprehend Medical generates one.
- `"JobName"`: The identifier of the job.
- `"KMSKey"`: An AWS Key Management Service key to encrypt your output files. If you do not
  specify a key, the files are written in plain text.
"""
start_icd10_cminference_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartICD10CMInferenceJob", Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())); aws_config=aws_config)
start_icd10_cminference_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartICD10CMInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())), params)); aws_config=aws_config)

"""
    start_phidetection_job(data_access_role_arn, input_data_config, language_code, output_data_config)
    start_phidetection_job(data_access_role_arn, input_data_config, language_code, output_data_config, params::Dict{String,<:Any})

Starts an asynchronous job to detect protected health information (PHI). Use the
DescribePHIDetectionJob operation to track the status of a job.

# Arguments
- `data_access_role_arn`: The Amazon Resource Name (ARN) of the AWS Identity and Access
  Management (IAM) role that grants Amazon Comprehend Medical read access to your input data.
  For more information, see  Role-Based Permissions Required for Asynchronous Operations.
- `input_data_config`: Specifies the format and location of the input data for the job.
- `language_code`: The language of the input documents. All documents must be in the same
  language.
- `output_data_config`: Specifies where to send the output files.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ClientRequestToken"`: A unique identifier for the request. If you don't set the client
  request token, Amazon Comprehend Medical generates one.
- `"JobName"`: The identifier of the job.
- `"KMSKey"`: An AWS Key Management Service key to encrypt your output files. If you do not
  specify a key, the files are written in plain text.
"""
start_phidetection_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartPHIDetectionJob", Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())); aws_config=aws_config)
start_phidetection_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartPHIDetectionJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())), params)); aws_config=aws_config)

"""
    start_rx_norm_inference_job(data_access_role_arn, input_data_config, language_code, output_data_config)
    start_rx_norm_inference_job(data_access_role_arn, input_data_config, language_code, output_data_config, params::Dict{String,<:Any})

Starts an asynchronous job to detect medication entities and link them to the RxNorm
ontology. Use the DescribeRxNormInferenceJob operation to track the status of a job.

# Arguments
- `data_access_role_arn`: The Amazon Resource Name (ARN) of the AWS Identity and Access
  Management (IAM) role that grants Amazon Comprehend Medical read access to your input data.
  For more information, see  Role-Based Permissions Required for Asynchronous Operations.
- `input_data_config`: Specifies the format and location of the input data for the job.
- `language_code`: The language of the input documents. All documents must be in the same
  language.
- `output_data_config`: Specifies where to send the output files.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ClientRequestToken"`: A unique identifier for the request. If you don't set the client
  request token, Amazon Comprehend Medical generates one.
- `"JobName"`: The identifier of the job.
- `"KMSKey"`: An AWS Key Management Service key to encrypt your output files. If you do not
  specify a key, the files are written in plain text.
"""
start_rx_norm_inference_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartRxNormInferenceJob", Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())); aws_config=aws_config)
start_rx_norm_inference_job(DataAccessRoleArn, InputDataConfig, LanguageCode, OutputDataConfig, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StartRxNormInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DataAccessRoleArn"=>DataAccessRoleArn, "InputDataConfig"=>InputDataConfig, "LanguageCode"=>LanguageCode, "OutputDataConfig"=>OutputDataConfig, "ClientRequestToken"=>string(uuid4())), params)); aws_config=aws_config)

"""
    stop_entities_detection_v2_job(job_id)
    stop_entities_detection_v2_job(job_id, params::Dict{String,<:Any})

Stops a medical entities detection job in progress.

# Arguments
- `job_id`: The identifier of the medical entities job to stop.

"""
stop_entities_detection_v2_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopEntitiesDetectionV2Job", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
stop_entities_detection_v2_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopEntitiesDetectionV2Job", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    stop_icd10_cminference_job(job_id)
    stop_icd10_cminference_job(job_id, params::Dict{String,<:Any})

Stops an InferICD10CM inference job in progress.

# Arguments
- `job_id`: The identifier of the job.

"""
stop_icd10_cminference_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopICD10CMInferenceJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
stop_icd10_cminference_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopICD10CMInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    stop_phidetection_job(job_id)
    stop_phidetection_job(job_id, params::Dict{String,<:Any})

Stops a protected health information (PHI) detection job in progress.

# Arguments
- `job_id`: The identifier of the PHI detection job to stop.

"""
stop_phidetection_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopPHIDetectionJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
stop_phidetection_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopPHIDetectionJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)

"""
    stop_rx_norm_inference_job(job_id)
    stop_rx_norm_inference_job(job_id, params::Dict{String,<:Any})

Stops an InferRxNorm inference job in progress.

# Arguments
- `job_id`: The identifier of the job.

"""
stop_rx_norm_inference_job(JobId; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopRxNormInferenceJob", Dict{String, Any}("JobId"=>JobId); aws_config=aws_config)
stop_rx_norm_inference_job(JobId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = comprehendmedical("StopRxNormInferenceJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("JobId"=>JobId), params)); aws_config=aws_config)


text:
################################################################################
#                           _  _ ____ ___  ____ _  _                           #
#                           |\/| |  | |  \ |___ |\/|                           #
#                           |  | |__| |__/ |___ |  |                           #
################################################################################

type Modem
    modulation::Modulation
    samplesPerSymbol::Real
    txFilter::FIRFilter
    rxFilter::FIRFilter
end

function Modem( modulation::Modulation; samplesPerSymbol::Real = 2, pulseShape = rrcos, excessBandwidth = 0.35 )
    samplesPerSymbol >= 2 || error( "samplesPerSymbol must be greater than 2" )
    resampRate = isinteger( samplesPerSymbol ) ? int( samplesPerSymbol )//1 : samplesPerSymbol
    numTaps    = 32 * 10 * samplesPerSymbol
    span       = int( numTaps/samplesPerSymbol )
    taps       = pulseShape( excessBandwidth, span, samplesPerSymbol )
    txFilter   = FIRFilter( taps, resampRate )
    rxFilter   = FIRFilter( taps, 1/resampRate )

    Modem( modulation, samplesPerSymbol, txFilter, rxFilter )
end

function modulate( modem::Modem, data::AbstractVector )
    symbols       = modulate( modem.modulation, data )
    resampSymbols = filt( modem.txFilter, symbols )
end

function demodulate( modem::Modem, symbols::AbstractVector )
    resampSymbols = filt( modem.rxFilter, symbols )
    data          = demodulate( modem.modulation, resampSymbols )
end

ext: jl


text:
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
# ==============================================================================
#
#   Text cell to render an URL.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

export URLTextCell

"""
    URLTextCell

A text cell that contains a URL and is rendered using the ANSI escape sequence
`\\e8]`.

!!! warning
    Some terminals **do not** support this feature, leading to a layout problem
    in the printed table.

# Fields

**Public**

- `text::String`: The label of the URL.
- `url::String`: The URL.

**Private**

- `_crop::Int`: Number of characters in the text that must be cropped when
    rendering the URL.
- `_left_pad::Int`: Number of spaces to be added to the left of the text when
    rendering the URL.
- `_right_pad::Int`: Number of spaces to be added to the right of the text when
    rendering the URL.
- `_suffix::String`: Suffix to be appended to the text when rendering the URL.
"""
mutable struct URLTextCell <: CustomTextCell
    # Public
    text::String
    url::String

    # Private
    _crop::Int
    _left_pad::Int
    _right_pad::Int
    _suffix::String
end

function URLTextCell(text::String, url::String)
    return URLTextCell(text, url, 0, 0, 0, "")
end

################################################################################
#                                     API
################################################################################

function get_printable_cell_line(c::URLTextCell, l::Int)
    if l == 1
        return " "^c._left_pad * c.text * " "^c._right_pad
    else
        return ""
    end
end

function get_rendered_line(c::URLTextCell, l::Int)
    if l == 1
        url_text_width = textwidth(c.text)
        printable_size = c._left_pad + url_text_width + c._right_pad
        rem_chars = printable_size - c._crop

        # Left padding
        # ======================================================================

        Δ = clamp(rem_chars, 0, c._left_pad)
        str = " " ^ Δ
        rem_chars ≤ c._left_pad && return str * c._suffix
        rem_chars -= c._left_pad

        # URL text
        # ======================================================================

        Δ = clamp(rem_chars, 0, url_text_width)
        proc_text = _crop_str(c.text, Δ)
        str *= "\e]8;;" * c.url * "\e\\" * proc_text * "\e]8;;\e\\"
        rem_chars ≤ url_text_width && return str * c._suffix
        rem_chars -= url_text_width

        # Right padding
        # ======================================================================

        Δ = clamp(rem_chars, 0, c._right_pad)
        str *= " " ^ Δ
        return str * c._suffix
    else
        return ""
    end
end

function append_suffix_to_line!(c::URLTextCell, l::Int, suffix::String)
    l == 1 && (c._suffix = suffix)
    return nothing
end

function apply_line_padding!(c::URLTextCell, l::Int, left_pad::Int, right_pad::Int)
    if l == 1
        c._left_pad = left_pad
        c._right_pad = right_pad
    end

    return nothing
end

function crop_line!(c::URLTextCell, l::Int, num::Int)
    l == 1 && (c._crop = num)
    return nothing
end

parse_cell_text(c::URLTextCell; kwargs...) = [c.text]

function reset!(c::URLTextCell)
    c._crop = 0
    c._left_pad = 0
    c._right_pad = 0
    c._suffix = ""

    return nothing
end


text:
#Gingrich stocking chart calculated using the original upland oak parameters
#for more information see:http://oak.snr.missouri.edu/silviculture/tools/gingrich.html

using RecipesBase

amd_convert(qmd) = -0.259 + 0.973qmd
get_tpa(j, i, a) = (1*j*10)/(a[1]+a[2]*amd_convert(i)+a[3]*i^2)

function stklines(stk, dia, a)
  tpa = get_tpa.(stk', dia, Ref(a))
  ba = pi * (dia ./ 24).^2 .* tpa
  tpa, ba
end

@userplot gingrich_chart
@recipe function f(dat::gingrich_chart)

  #define parameters
  a = [-0.0507, 0.1698, 0.0317]
  b = [0.175, 0.205, 0.06]
  ba_ticks= 0:20:160
  tpa_ticks= 0:50:450
  #QMD lines
  dia = [7, 8, 10, 12, 14, 16, 18, 20, 22]
  #stocking percent horizontal lines
  stk_percent= 20:10:110

  # plot attributes
  xlabel --> "Trees Per Acre"
  ylabel --> "Basal Area (sq ft./acre)"
  xticks --> 0:50:450
  yticks --> 0:20:200
  legend := false
  primary := false

  tpa, ba = stklines(stk_percent, dia, a)

  # horizontal lines
  @series begin
    linecolor := :black
    tpa, ba
  end

  # vertical lines
  @series begin
    linecolor := :black
    tpa', ba'
  end

  # upper red line
  @series begin
    linecolor := :red
    stklines([100], dia, a)
  end

  # lower red line
  @series begin
    linecolor := :red
    stklines([100], dia, b)
  end

  # the point and the annotations
  @series begin
    primary := true
    seriestype := :scatter
    annotations := (100:38:442, 20:10:110, ["$i%" for i in 20:10:110])

    a,b = dat.args
    [a], [b]
  end
end


text:
export SyncActor, sync, SyncActorTimedOutException

import Base: show, showerror, wait, lock, unlock, notify

mutable struct SyncActorProps
    iscompleted :: Bool
    isfailed    :: Bool
end

"""
    SyncActor{T, A}(actor::A; withlock::Bool = true, timeout::Int = -1) where { T, A }

Sync actor provides a synchronized interface to `wait` for an actor to be notified with a `complete` event.
By default creates a re-entrant lock for synchronizing `next!`, `error!` and `complete!` events.

See also: [`Actor`](@ref), [`sync`](@ref)
"""
struct SyncActor{T, A} <: Actor{T}
    lock      :: ReentrantLock
    condition :: Condition
    actor     :: A
    props     :: SyncActorProps
    withlock  :: Bool
    timeout   :: Int

    SyncActor{T, A}(actor::A; withlock::Bool = false, timeout::Int = -1) where { T, A } = begin
        return new(ReentrantLock(), Condition(), actor, SyncActorProps(false, false), withlock, timeout)
    end
end

Base.show(io::IO, actor::SyncActor{T, A}) where { T, A } = print(io, "SyncActor($A)")

iswithlock(actor::SyncActor) = actor.withlock

Base.lock(actor::SyncActor)   = lock(actor.lock)
Base.unlock(actor::SyncActor) = lock(actor.lock)

iscompleted(actor::SyncActor) = actor.props.iscompleted
isfailed(actor::SyncActor)    = actor.props.isfailed

setcompleted!(actor::SyncActor) = actor.props.iscompleted = true
setfailed!(actor::SyncActor)    = actor.props.isfailed = true

Base.notify(actor::SyncActor) = notify(getcondition(actor))

getcondition(actor::SyncActor) = actor.condition
gettimeout(actor::SyncActor)   = actor.timeout

macro check_lock(expr)
    output = quote
        if iswithlock(actor)
            lock(actor)
        end
        $(expr)
        if iswithlock(actor)
            unlock(actor)
        end
    end
    return esc(output)
end

function on_next!(actor::SyncActor{T}, data::T) where T
    @check_lock begin
        next!(actor.actor, data)
    end
end

function on_error!(actor::SyncActor, err)
    @check_lock begin
        setfailed!(actor)
        error!(actor.actor, err)
        notify(actor)
    end
end

function on_complete!(actor::SyncActor)
    @check_lock begin
        setcompleted!(actor)
        complete!(actor.actor)
        notify(actor)
    end
end

function Base.wait(actor::SyncActor)
    if !isfailed(actor) && !iscompleted(actor)
        timeout = gettimeout(actor) / MILLISECONDS_IN_SECOND
        if timeout >= 0.001
            @async begin
                try
                    sleep(timeout)
                    if !isfailed(actor) && !iscompleted(actor)
                        notify(getcondition(actor), SyncActorTimedOutException(), error = true)
                    end
                catch exception
                    @warn "Exception in Base.wait(actor::SyncActor): $exception"
                end
            end
        end
        wait(getcondition(actor))
    end
end

struct SyncActorTimedOutException <: Exception end

mutable struct SyncActorFactoryProps
    actors :: Vector{SyncActor}
end

struct SyncActorFactory{F} <: AbstractActorFactory
    factory  :: F
    withlock :: Bool
    timeout  :: Int
    props    :: SyncActorFactoryProps

    SyncActorFactory{F}(factory::F; withlock::Bool = false, timeout::Int = -1) where { F <: AbstractActorFactory } = begin
        return new(factory, withlock, timeout, SyncActorFactoryProps(Vector{SyncActor}()))
    end
end

function create_actor(::Type{L}, factory::SyncActorFactory{F}) where { L, F }
    actor = sync(create_actor(L, factory.factory), withlock = factory.withlock, timeout = factory.timeout)
    push!(factory.props.actors, actor)
    return actor
end

function Base.wait(factory::SyncActorFactory)
    foreach(wait, factory.props.actors)
    factory.props.actors = Vector{SyncActor}()
end

"""
    sync(actor::A; withlock::Bool = true, timeout::Int = -1) where A
    sync(factory::F; withlock::Bool = true, timeout::Int = -1) where { F <: AbstractActorFactory }

Creation operator for the `SyncActor` actor.
Accepts optional named `timeout` argument which specifies maximum number of milliseconds to wait (throws SyncActorTimedOutException() on timeout).
Also accepts optional `withlock` boolean flag indicating that every `next!`, `error!` and `complete!` event should be guarded with `ReentrantLock`.

# Examples
```
using Rocket

actor  = keep(Int)
synced = sync(actor)

subscribe!(from(0:5, scheduler = AsyncScheduler()), synced)

yield()

wait(synced)
show(synced.actor.values)

# output
[0, 1, 2, 3, 4, 5]
```

Can also be used with an `<: AbstractActorFactory` as an argument. In this case `sync` function will return a special actor factory object, which
will store all created actors in array and wrap them with a `sync` function. `wait(sync_factory)` method will wait for all of the created actors to be completed in the order of creation (but only once for each of them).

```
using Rocket

values = Int[]

factory  = lambda(on_next = (d) -> push!(values, d))
synced   = sync(factory)

subscribe!(from(0:5, scheduler = AsyncScheduler()), synced)

yield()

wait(synced)
show(values)

# output
[0, 1, 2, 3, 4, 5]
```

See also: [`SyncActor`](@ref), [`AbstractActor`](@ref)
"""
sync(actor::A; withlock::Bool = false, timeout::Int = -1)   where A                             = as_sync(as_actor(A), actor, withlock, timeout)
sync(factory::F; withlock::Bool = false, timeout::Int = -1) where { F <: AbstractActorFactory } = SyncActorFactory{F}(factory; withlock = withlock, timeout = timeout)

as_sync(::InvalidActorTrait,       actor::A, withlock::Bool, timeout::Int) where { A }    = throw(InvalidActorTraitUsageError(actor))
as_sync(::BaseActorTrait{D},       actor::A, withlock::Bool, timeout::Int) where { D, A } = SyncActor{D, A}(actor; withlock = withlock, timeout = timeout)
as_sync(::NextActorTrait{D},       actor::A, withlock::Bool, timeout::Int) where { D, A } = SyncActor{D, A}(actor; withlock = withlock, timeout = timeout)
as_sync(::ErrorActorTrait{D},      actor::A, withlock::Bool, timeout::Int) where { D, A } = SyncActor{D, A}(actor; withlock = withlock, timeout = timeout)
as_sync(::CompletionActorTrait{D}, actor::A, withlock::Bool, timeout::Int) where { D, A } = SyncActor{D, A}(actor; withlock = withlock, timeout = timeout)


text:
ntime = 10

x0  = [1.]
dim = 1

ode = ODE(fx, x0)
sol = Solution(ode, Δt, ntime)
@test typeof(sol) <: SolutionODE
# @test length(sol) == dim*(ntime+1)
@test size(sol) == (dim, ntime+1, 1)
@test indices(sol, 1) == 1:dim
@test indices(sol, 2) == 0:ntime
@test indices(sol, 3) == 1:1

for i in 1:ntime
    sol[1,i] = i
end

@test sol.x[1,1,1] == sol[1,0,1]
@test sol.x[1:sol.nd,1,1] == sol[1:sol.nd,0,1]

@test typeof(Integrator(ODE(fx, [1.]), getTableauExplicitMidpoint(), Δt)) <: IntegratorERK

pode = PODE(fq, fp, [1.], [1.])
psol = Solution(pode, Δt, ntime)
@test typeof(psol) <: SolutionPODE
@test size(psol) == (2, dim, ntime+1, 1)
@test indices(psol, 1) == 1:2
@test indices(psol, 2) == 1:dim
@test indices(psol, 3) == 0:ntime
@test indices(psol, 4) == 1:1

for i in 1:ntime
    psol[1,1,i,1] = i
    psol[2,1,i,1] = i*i
end

@test psol.x[1,1,1,1] == psol[1,1,0,1]
@test psol.x[2,1,1,1] == psol[2,1,0,1]
@test psol.x[1:2,1:psol.nd,1,1] == psol[1:2,1:psol.nd,0,1]

dae = DAE(x -> x, (x, λ) -> [λ -λ], x -> x[2]-x[1], [1.; 1.], [0.])
@test typeof(Solution(dae, Δt, ntime)) <: SolutionDAE

pdae = PDAE(y -> y, x -> 2x, (x, y, λ) -> λ, (x, y, λ) -> -λ, (x, y) -> x[1]-y[1], [1.], [1.], [0.])
@test typeof(Solution(pdae, Δt, ntime)) <: SolutionPDAE


text:
"Written by Johnathan Bizzano"
module JuliaInterface

	export method_argnames, SharpField, SharpType, SharpConstructor, SharpObject, SharpMethod, free, pin, @T_str, @P_str, @G_str, @R_str, sharptype, sharpbox, sharpunbox, @netusing, makearray

	_SharpGetMethod = nothing
	_SharpGetGenericMethod = nothing
	_SharpGetConstructor = nothing
	_SharpGetGenericConstructor = nothing
	_SharpClass = nothing
	_SharpField = nothing
	_SharpInvoke = nothing
	_SharpPin = nothing
	_SharpFree = nothing
	_SharpGetType = nothing
	_SharpToString = nothing
	_SharpGetHashCode = nothing
	_SharpEquals = nothing
	_SharpBox = nothing
	_SharpUnBox = nothing

	function method_argnames(m::Method)
           argnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), m.slot_syms)
           isempty(argnames) && return argnames
           return [string(sym) for sym in argnames[1:m.nargs][2:end]]
    end

	"Container for a sharp field"
	struct SharpField
		ptr::Int

		SharpField(ptr::Int) = new(ptr)

		Base.getindex(sf::SharpField) = sf()
		Base.getindex(sf::SharpField, val) = sf(val)
		Base.setindex!(sf::SharpField, val) = sf(val)
		Base.setindex!(sf::SharpField, obj, val) = sf(obj, val)

		(sf::SharpField)() = _SharpInvoke(sf.ptr, Any[])
		(sf::SharpField)(obj) = _SharpInvoke(sf.ptr, Any[obj])
		(sf::SharpField)(obj, newVal) = _SharpInvoke(sf.ptr, Any[obj, newVal])

		Base.hash(so::SharpField) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpField) = _SharpToString(so.ptr)
		Base.print(io::IO, so::SharpField) = print(io, string(so))
		Base.show(io::IO, so::SharpField) = show(io, string(so))
	end

	"Container for a sharp type"
	struct SharpType
		ptr::Int

		SharpType(name::String) = _SharpClass(name)
		SharpType(ptr::Int) = new(ptr)

		function Base.getproperty(st::SharpType, sym::Symbol)
			if sym == :new
				return _SharpGetConstructor(st.ptr)
			elseif sym == :ptr
				return Base.getfield(st, :ptr)
			else
			    sm = _SharpGetMethod(st.ptr, string(sym))
				(sm.ptr != 0) && return sm
				return _SharpField(st.ptr, string(sym))
			end
		end

		Base.hash(so::SharpType) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpType) = _SharpToString(so.ptr)
		Base.print(io::IO, so::SharpType) = print(io, string(so))
		Base.show(io::IO, so::SharpType) = show(io, string(so))
	end

	"Container for a sharp constructor. Use [T,...] to pass generics. Can be invoked after passing generics (if needed)"
	struct SharpConstructor
		ptr::Int

		SharpConstructor(ptr::Int) = new(ptr)

		Base.getindex(so::SharpConstructor) = so
		Base.getindex(so::SharpConstructor, generic_types::SharpType...) = _SharpGetGenericConstructor(so.ptr, Any[gen_type.ptr for gen_type in generic_types])
		(sc::SharpConstructor)(parameters...) = _SharpInvoke(sc.ptr, Any[parameters...])

		Base.hash(so::SharpConstructor) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpConstructor) = _SharpToString(so.ptr)
		Base.print(io::IO, so::SharpConstructor) = print(io, string(so))
		Base.show(io::IO, so::SharpConstructor) = show(io, string(so))
	end

	"Container for a sharp method. Use [T,...] to pass generics. Can be invoked after passing generics (if needed)"
	struct SharpMethod
		ptr::Int

		SharpMethod(ptr::Int) = new(ptr)

		Base.getindex(so::SharpMethod) = so
		Base.getindex(so::SharpMethod, generic_types::SharpType...) = _SharpGetGenericMethod(so.ptr, Any[gen_type.ptr for gen_type in generic_types])
		(sc::SharpMethod)(parameters...) = _SharpInvoke(sc.ptr, Any[parameters...])

		Base.hash(so::SharpMethod) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpMethod) = _SharpToString(so.ptr)
		Base.print(io::IO, so::SharpMethod) = print(io, string(so))
		Base.show(io::IO, so::SharpMethod) = show(io, string(so))
	end

	"Get the Sharp Type"
	sharptype(so) = SharpType(_SharpGetType(so.ptr))

	"Container for sharp object"
	mutable struct SharpObject
		ptr::Int

		SharpObject(ptr::Int) = new(ptr)

		function Base.getproperty(st::SharpObject, sym::Symbol)
			if sym == :ptr
				return Base.getfield(st, :ptr)
			else
			    sm = SharpOwnerMethod(_SharpGetMethod(sharptype(st).ptr, string(sym)), st)
				(sm.method.ptr != 0) && return sm
				return SharpOwnerField(_SharpField(sharptype(st).ptr, string(sym)), st)
			end
		end

		Base.hash(so::SharpObject) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpObject) = _SharpToString(so.ptr)
		Base.print(io::IO, so::SharpObject) = print(io, string(so))
		Base.show(io::IO, so::SharpObject) = show(io, string(so))
	end

	"Container for a sharp owner field"
	struct SharpOwnerField
		field::SharpField
		owner::SharpObject

		SharpOwnerField(field::SharpField, owner::SharpObject) = new(field, owner)

		Base.getindex(sf::SharpOwnerField) = sf()
		Base.setindex!(sf::SharpOwnerField, val) = sf(val)

		(sf::SharpOwnerField)() = sf.field(sf.owner)
		(sf::SharpOwnerField)(obj) = sf.field(sf.owner, val)

		Base.hash(so::SharpOwnerField) = hash(so.field)
		Base.string(so::SharpOwnerField) = string(so.field)
		Base.print(io::IO, so::SharpOwnerField) = print(io, so.field)
		Base.show(io::IO, so::SharpOwnerField) = show(io, so.field)
	end

	"Container for a sharp method. Use [T,...] to pass generics. Can be invoked after passing generics (if needed)"
	struct SharpOwnerMethod
		method::SharpMethod
		owner::SharpObject

		SharpOwnerMethod(sm::SharpMethod, owner::SharpObject) = new(sm)

		Base.getindex(so::SharpOwnerMethod) = so
		Base.getindex(so::SharpOwnerMethod, generic_types::SharpType...) = SharpOwnerMethod(so(generic_types...), so.owner)
		(sc::SharpOwnerMethod)(parameters...) = so.method(sc.owner, parameters...)

		Base.hash(so::SharpOwnerMethod) = hash(so.method)
		Base.string(so::SharpOwnerMethod) = string(so.method)
		Base.print(io::IO, so::SharpOwnerMethod) = print(io, so.method)
		Base.show(io::IO, so::SharpOwnerMethod) = show(io, so.method)
	end

	"Container for sharp exceptions."
	struct SharpException <: Exception
		exp::SharpObject
		SharpException(obj::SharpObject) = new(obj)

		Base.showerror(io::IO, se::SharpException) = print(io, se.exp)
		Base.hash(so::SharpException) = hash(so.exp)
		Base.string(so::SharpException) = string(so.exp)
		Base.print(io::IO, so::SharpException) = print(io, se.exp)
		Base.show(io::IO, so::SharpException) = show(io, so.exp)
	end

	"Box the Julia type to sharp type"
	sharpbox(v::Any) = SharpObject(_SharpBox(v))

	"Unbox the sharp type to julia type"
	sharpunbox(ptr::Int) = _SharpUnBox(ptr)

	"Unbox the sharp container to julia type"
	sharpunbox(v::Any) = sharpunbox(v.ptr)

	"Free the Sharp GC Pin"
	function free(s)
			if !s.wasFreed
				s.wasFreed = true
				_SharpFree(s.ptr)
			end
	end

	"Pin the Sharp Object"
	pin(s) = _SharpPin(s.ptr)

	"Stub for the Sharp GC"
	mutable struct SharpStub
		ptr::Int
		wasFreed::Bool

		function SharpStub(ptr::Int)
			val = new(ptr, false)
			finalizer(free, val)
			val
		end

		Base.close(st::SharpStub) = free(st)
		Base.hash(so::SharpStub) = _SharpGetHashCode(so.ptr)
		Base.string(so::SharpStub) = _SharpToString(so.ptr)
	end

	function typefind(mod, type)
		if !hasproperty(mod, :NETNAMESPACE)
			Core.eval(mod, :(NETNAMESPACE = Symbol[]))
		end
		storage = getproperty(mod, :NETNAMESPACE)
		st = SharpType(string(type))
		for i in length(storage):-1:1
			(st.ptr != 0) && return st
			st = SharpType("$(storage[i]).$type")
		end
		return st
	end

	macro netusing(namespace)
		if !hasproperty(__module__, :NETNAMESPACE)
			Core.eval(__module__, :(NETNAMESPACE = Symbol[]))
		end
		storage = getproperty(__module__, :NETNAMESPACE)
		idx = findfirst(==(namespace), storage)
		if idx != nothing
			deleteat!(storage, idx)
		end
		push!(storage, namespace)
	end

    TypeMap = Dict{Symbol, SharpType}()

	"Perform a static lookup of the Sharp Type. If using the same type multiple times, use P,G & R version to store then remove from local storage"
	macro T_str(type)
		type = Symbol(type)
		return typefind(__module__, type)
	end

	"Push local type to local storage for fast lookup"
	macro P_str(type)
		type = Symbol(type)
		stype = typefind(__module__, type)
		TypeMap[type] = stype
		return stype
	end

	"Get type from local storage"
	macro G_str(type)
		return TypeMap[Symbol(type)]
	end

	"Remove type from local storage"
	macro R_str(type)
		return pop!(TypeMap, Symbol(type))
	end

	function gen_ccall(addr, ret, argtypes...)
		argSyms = [Symbol("arg$i") for i in 1:length(argtypes)]
		return Core.eval(Main.JuliaInterface, Expr(:(->), Expr(:tuple, argSyms...), Expr(:call, :ccall, addr, ret, Expr(:tuple, argtypes...), argSyms...)))
	end

	makearray(T, dims) = Array{T}(undef, dims...)

	function initialize_library(getClazz, getMethod, getGenericMethod, getConstructor, getGenericConstructor, getField,
			sharpInvoke, sharpPinGC, sharpFreeGC, sharpGetType, sharpEquals, sharpToString,
			sharpGetHash, sharpBox, sharpUnBox)

		global _SharpClass = gen_ccall(getClazz, Any, Cstring)
		global _SharpGetMethod = gen_ccall(getMethod, Any, Int, Cstring)
		global _SharpGetGenericMethod = gen_ccall(getGenericMethod, Any, Int, Cstring)
		global _SharpGetConstructor = gen_ccall(getConstructor, Any, Int)
		global _SharpGetGenericConstructor = gen_ccall(getGenericConstructor, Any, Int, Any)
		global _SharpField = gen_ccall(getField, Any, Int, Cstring)
		global _SharpInvoke = gen_ccall(sharpInvoke, Any, Int, Any)
		global _SharpPin = gen_ccall(sharpPinGC, Any, Int)
		global _SharpFree = gen_ccall(sharpFreeGC, Cvoid, Int)
		global _SharpGetType = gen_ccall(sharpGetType, Int, Int)
		global _SharpToString = gen_ccall(sharpToString, String, Int)
		global _SharpGetHashCode = gen_ccall(sharpGetHash, Int, Int)
		global _SharpEquals = gen_ccall(sharpEquals, Bool, Int, Int)
		global _SharpBox = gen_ccall(sharpBox, Int, Any)
		global _SharpUnBox = gen_ccall(sharpUnBox, Any, Int)
	end
end


text: Dict{String,Any}("group" => Dict{String,Any}("more" => Dict{String,Any}("value" => Any[Dict{String,Any}("value" => "42","type" => "integer"), Dict{String,Any}("value" => "42","type" => "integer")],"type" => "array"),"answer" => Dict{String,Any}("value" => "42","type" => "integer")))

max_stars_repo_name: SmiteWindows/julia

max_issues_repo_name: SmiteWindows/julia

max_forks_repo_name: SmiteWindows/julia


text:
"""
```
simulate(m, horizon, shock_matrix, z₀)
simulate(m, horizon, z₀)
simulate(m, shock_vector, z₀)
simulate(m, horizon, shock_matrix)
simulate(m, horizon)
```
simulates the economy approximated by a risk-adjusted linearization. The first method
incorporates an arbitrary path of shocks across the horizon while the second method
assumes no shocks occur during the horizon. The third method calculates next
period's states and jump variables, given a vector of shocks. The fourth and fifth
methods are the same as the first two but assume the economy begins at the
stochastic steady state.

### Inputs
- `m::RiskAdjustedLinearization`: a solved risk-adjusted linearization of a dynamic economy
- `z₀::AbstractVector`: the initial state from which the economy begins
- `horizon::Int`: number of periods to be simulated
- `shock_matrix::AbstractMatrix`: a `Nε × T` length matrix, whose columns are draws from
    the distributions of exogenous shocks driving the economy approximated by `m`. The number of columns
    must be at least as long as `horizon`. If the number of columns is larger, then we do not use
    draws for columns `horizon + 1:T`.

### Outputs
- `states`: a matrix of the simulated path of states `z`, with type specified by the array type of `z₀`
- `jumps`: a matrix of the simulated path of jump variables `y`, with type specified by the array type of `z₀`
"""
function simulate(m::RiskAdjustedLinearization, horizon::Int, shock_matrix::AbstractMatrix, z₀::AbstractVector)
    @assert horizon <= size(shock_matrix, 2) "There are not enough draws in shock_matrix (horizon <= size(shock_matrix, 2))"

    # Set up
    states = similar(z₀, m.Nz, horizon)
    jumps  = similar(z₀, m.Ny, horizon)
    Γ₁     = m[:Γ₁]
    Γ₂     = m[:Γ₂]
    y₀     = m.y + m.Ψ * (z₀ - m.z)

    # Create "shock function" which creates the matrix mapping shocks to states
    shock_fnct = create_shock_function(m.nonlinear.Σ, m.nonlinear.Λ, m.z, m.y, m.Ψ)

    # Iterate forward!
    states[:, 1] = expected_transition(m.z, m.y, m.Ψ, Γ₁, Γ₂, z₀, y₀) + shock_fnct(z₀, shock_matrix[:, 1])
    jumps[:, 1]  = m.y + m.Ψ * ((@view states[:, 1]) - m.z)
    for t in 2:horizon
        states[:, t] = expected_transition(m.z, m.y, m.Ψ, Γ₁, Γ₂, (@view states[:, t - 1]), (@view jumps[:, t - 1])) +
            shock_fnct((@view states[:, t - 1]), shock_matrix[:, t])
        jumps[:, t]  = m.y + m.Ψ * ((@view states[:, t]) - m.z)
    end

    return states, jumps
end

function simulate(m::RiskAdjustedLinearization, horizon::Int, z₀::AbstractVector)

    # Set up
    states = similar(z₀, m.Nz, horizon)
    jumps  = similar(z₀, m.Ny, horizon)
    Γ₁     = m[:Γ₁]
    Γ₂     = m[:Γ₂]
    y₀     = m.y + m.Ψ * (z₀ - m.z)

    # Iterate forward!
    states[:, 1] = expected_transition(m.z, m.y, m.Ψ, Γ₁, Γ₂, z₀, y₀)
    jumps[:, 1]  = m.y + m.Ψ * ((@view states[:, 1]) - m.z)
    for t in 2:horizon
        states[:, t] = expected_transition(m.z, m.y, m.Ψ, Γ₁, Γ₂, (@view states[:, t - 1]), (@view jumps[:, t - 1]))
        jumps[:, t]  = m.y + m.Ψ * ((@view states[:, t]) - m.z)
    end

    return states, jumps
end

function simulate(m::RiskAdjustedLinearization, shock_vector::AbstractVector, z₀::AbstractVector)

    # Set up
    Γ₁     = m[:Γ₁]
    Γ₂     = m[:Γ₂]
    y₀     = m.y + m.Ψ * (z₀ - m.z)

    # Create "shock function" which creates the matrix mapping shocks to states
    shock_fnct = create_shock_function(m.nonlinear.Σ, m.nonlinear.Λ, m.z, m.y, m.Ψ)

    # Iterate forward!
    states = expected_transition(m.z, m.y, m.Ψ, Γ₁, Γ₂, z₀, y₀) + shock_fnct(z₀, shock_vector)
    jumps  = m.y + m.Ψ * (states - m.z)

    return states, jumps
end

function expected_transition(z::AbstractVector, y::AbstractVector, Ψ::AbstractMatrix,
                             Γ₁::AbstractMatrix, Γ₂::AbstractMatrix, zₜ::AbstractVector, yₜ::AbstractVector)
    return z + Γ₁ * (zₜ - z) + Γ₂ * (yₜ - y)
end

function simulate(m::RiskAdjustedLinearization, horizon::Int, shock_matrix::AbstractMatrix)
    simulate(m, horizon, shock_matrix, m.z)
end

function simulate(m::RiskAdjustedLinearization, horizon::Int)
    simulate(m, horizon, m.z)
end

# Use multiple dispatch to construct the correct shock function
function create_shock_function(Σ::RALF1{S}, Λ::RALF1{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: AbstractMatrix, L <: AbstractMatrix}
    R = all(Λ.cache .≈ 0.) ? Σ.cache : (I - Λ.cache * Ψ) \ Σ.cache
    f = function _both_mat(z::AbstractVector, ε::AbstractVector)
        R * ε
    end

    return f
end

function create_shock_function(Σ::RALF1{S}, Λ::RALF1{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: DiffCache, L <: AbstractMatrix}
    f = if all(Λ.cache .≈ 0.)
        function _only_nonzero_Λ_mat(z::AbstractVector, ε::AbstractVector)
            Σ(z) * ε
        end
    else
        function _only_zero_Λ_mat(z::AbstractVector, ε::AbstractVector)
            (I - Λ.cache * Ψ) \ (Σ(z) * ε)
        end
    end

    return f
end

function create_shock_function(Σ::RALF1{S}, Λ::RALF1{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: AbstractMatrix, L <: DiffCache}
    f = function _only_Σ_mat(z::AbstractVector, ε::AbstractVector)
           (I - Λ(z) * Ψ) \ (Σ.cache * ε)
       end

    return f
end

function create_shock_function(Σ::RALF1{S}, Λ::RALF1{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: DiffCache, L <: DiffCache}
    f = function _both_fnct(z::AbstractVector, ε::AbstractVector)
           (I - Λ(z) * Ψ) \ (Σ(z) * ε)
       end

    return f
end

function create_shock_function(Σ::RALF2{S}, Λ::RALF2{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: AbstractMatrix, L <: AbstractMatrix}
    R = all(Λ.cache .≈ 0.) ? Σ.cache : (I - Λ.cache * Ψ) \ Σ.cache
    f = function _both_mat(z::AbstractVector, ε::AbstractVector)
        R * ε
    end

    return f
end

function create_shock_function(Σ::RALF2{S}, Λ::RALF2{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: TwoDiffCache, L <: AbstractMatrix}
    f = if all(m[:Λ_sss] .≈ 0.)
        function _only_nonzero_Λ_mat(zₜ::AbstractVector, ε::AbstractVector)
            Σ(zₜ, y + Ψ * (zₜ - z)) * ε
        end
    else
        function _only_zero_Λ_mat(zₜ::AbstractVector, ε::AbstractVector)
            (I - Λ.cache * Ψ) \ (Σ(zₜ, y + Ψ * (zₜ - z)) * ε)
        end
    end

    return f
end

function create_shock_function(Σ::RALF2{S}, Λ::RALF2{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: AbstractMatrix, L <: TwoDiffCache}
    f = function _only_Σ_mat(zₜ::AbstractVector, ε::AbstractVector)
           (I - Λ(zₜ, y + Ψ * (zₜ - z)) * Ψ) \ (Σ.cache * ε)
       end

    return f
end

function create_shock_function(Σ::RALF2{S}, Λ::RALF2{L}, z::AbstractVector,
                               y::AbstractVector, Ψ::AbstractMatrix) where {S <: TwoDiffCache, L <: TwoDiffCache}
    f = function _both_fnct(zₜ::AbstractVector, ε::AbstractVector)
        yₜ = y + Ψ * (zₜ - z)
        (I - Λ(zₜ, yₜ) * Ψ) \ (Σ(zₜ, yₜ) * ε)
       end

    return f
end


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

## numeric/object traits
# trait for objects that have an ordering
abstract type TypeOrder end
struct HasOrder <: TypeOrder end
struct Unordered <: TypeOrder end

TypeOrder(instance) = TypeOrder(typeof(instance))
TypeOrder(::Type{<:Real}) = HasOrder()
TypeOrder(::Type{<:Any}) = Unordered()

# trait for objects that support arithmetic
abstract type TypeArithmetic end
struct ArithmeticRounds <: TypeArithmetic end     # least significant bits can be lost
struct ArithmeticOverflows <: TypeArithmetic end  #  most significant bits can be lost
struct ArithmeticUnknown <: TypeArithmetic end

TypeArithmetic(instance) = TypeArithmetic(typeof(instance))
TypeArithmetic(::Type{<:AbstractFloat}) = ArithmeticRounds()
TypeArithmetic(::Type{<:Integer}) = ArithmeticOverflows()
TypeArithmetic(::Type{<:Any}) = ArithmeticUnknown()

max_stars_repo_name: caodi/julia

max_issues_repo_name: caodi/julia

max_forks_repo_name: caodi/julia


text:
"""
    trixi2img(filename::AbstractString...;
            format=:png, variables=[], verbose=false, grid_lines=false,
            output_directory=".", nvisnodes=nothing, max_supported_level=11)

Convert two-dimensional Trixi-generated output files to image files (PNG or PDF).

# Arguments
- `filename`: One or more 2D solution/restart files generated by Trixi to create an image from.
              Filenames support file globbing, e.g., "solution*" to match all files starting
              with `solution`.
- `format`: Output format for solution/restart files. Can be 'vtu' or 'vti'.
- `variables`: Names of the variables to create images for. If empty, each variable found in the
               input file(s) will be plotted.
- `verbose`: Set to `true` to enable verbose output.
- `grid_lines`: Plot outline of elements. (warning: this is an expensive operation!)
- `output_directory`: Output directory where generated files are stored.
- `nvisnodes`: Number of visualization nodes per element (default: twice the number of DG nodes).
               A value of `0` (zero) uses the number of nodes in the DG elements.
- `max_supported_level`: Maximum cell refinement level supported for plotting.
- `slice_axis`: Axis orthogonal to the slice plane. Will be ignored in 2D. May be :x, :y or :z.
- `slice_axis_intercept`: Point on the slice axis where it intersects with the slice plane.

# Examples
```julia
julia> trixi2img("out/solution_000*.h5")
[...]

julia> trixi2img("out/solution_000*.h5", slice_axis=:z, slice_axis_intercept=0.5) # Slice plane will be z=0.5
[...]
```
"""
function trixi2img(filename::AbstractString...;
                   format=:png, variables=[], verbose=false, grid_lines=false,
                   output_directory=".", nvisnodes=nothing, max_supported_level=11,
                   slice_axis=:z, slice_axis_intercept=0)
  # Reset timer
  reset_timer!()

  # Convert filenames to a single list of strings
  if isempty(filename)
    error("no input file was provided")
  end
  filenames = String[]
  for pattern in filename
    append!(filenames, glob(pattern))
  end

  # Ensure valid format
  if !(format in (:png, :pdf))
    error("unsupported output format '$format' (must be 'vtu' or 'vti')")
  end

  # Iterate over input files
  for filename in filenames
    verbose && println("Processing file $filename...")

    # Check if data file exists
    if !isfile(filename)
      error("data file '$filename' does not exist")
    end

    # Get mesh file name
    meshfile = extract_mesh_filename(filename)

    # Check if mesh file exists
    if !isfile(meshfile)
      error("mesh file '$meshfile' does not exist")
    end

    # Read mesh
    verbose && println("| Reading mesh file...")
    @timeit "read mesh" (center_level_0, length_level_0,
                         leaf_cells, coordinates, levels, ndims) = read_meshfile(meshfile)

    # Read data
    verbose && println("| Reading data file...")
    @timeit "read data" labels, unstructured_data, n_nodes, time = read_datafile(filename)

    # Determine resolution for data interpolation
    max_level = maximum(levels)
    if max_level > max_supported_level
      error("Maximum refinement level in data file $max_level is higher than " *
            "maximum supported level $max_supported_level")
    end
    max_available_nodes_per_finest_element = 2^(max_supported_level - max_level)
    if nvisnodes === nothing
      max_nvisnodes = 2 * n_nodes
    elseif nvisnodes == 0
      max_nvisnodes = n_nodes
    else
      max_nvisnodes = nvisnodes
    end
    nvisnodes_at_max_level = min(max_available_nodes_per_finest_element, max_nvisnodes)
    resolution = nvisnodes_at_max_level * 2^max_level
    nvisnodes_per_level = [2^(max_level - level)*nvisnodes_at_max_level for level in 0:max_level]
    # nvisnodes_per_level is an array (accessed by "level + 1" to accommodate
    # level-0-cell) that contains the number of visualization nodes for any
    # refinement level to visualize on an equidistant grid

    if ndims == 3
      verbose && println("| Extracting 2D slice...")
      # convert 3d unstructured data to 2d slice
      @timeit "extract 2D slice" (unstructured_data, coordinates, levels,
          center_level_0) = unstructured_2d_to_3d(unstructured_data,
          coordinates, levels, length_level_0, center_level_0, slice_axis,
          slice_axis_intercept)
    end

    # Normalize element coordinates: move center to (0, 0) and domain size to [-1, 1]²
    n_elements = length(levels)
    normalized_coordinates = similar(coordinates)
    for element_id in 1:n_elements
      @views normalized_coordinates[:, element_id] .= (
           (coordinates[:, element_id] .- center_level_0) ./ (length_level_0 / 2 ))
    end

    # Interpolate unstructured DG data to structured data
    verbose && println("| Interpolating data...")
    @timeit "interpolate data" (structured_data =
        unstructured2structured(unstructured_data, normalized_coordinates,
                                levels, resolution, nvisnodes_per_level))

    # Interpolate cell-centered values to node-centered values
    node_centered_data = cell2node(structured_data)

    # Determine axis coordinates for contour plot
    xs = collect(range(-1, 1, length=resolution+1)) .* length_level_0/2 .+ center_level_0[1]
    ys = collect(range(-1, 1, length=resolution+1)) .* length_level_0/2 .+ center_level_0[2]

    # Determine element vertices to plot grid lines
    if grid_lines
      vertices_x, vertices_y = calc_vertices(coordinates, levels, length_level_0)
    end

    # Set up plotting
    gr()
    if format == :pdf
      GR.inline("pdf")
    elseif format == :png
      GR.inline("png")
    end

    # Check that all variables exist in data file
    if isempty(variables)
      append!(variables, labels)
    else
      for var in variables
        if !(var in labels)
          error("variable '$var' does not exist in the data file $filename")
        end
      end
    end

    # Create output directory if it does not exist
    mkpath(output_directory)

    # Calculate x and y limits
    xlims = (-1, 1) .* (length_level_0/2 + center_level_0[1])
    ylims = (-1, 1) .* (length_level_0/2 + center_level_0[2])

    verbose && println("| Creating plots...")
    @timeit "plot generation" for (variable_id, label) in enumerate(variables)
      verbose && println("| | Variable $label...")

      if ndims == 3
        # Extract plot labels
        if slice_axis === :x
          xlabel = "y"
          ylabel = "z"
        elseif slice_axis === :y
          xlabel = "x"
          ylabel = "z"
        elseif slice_axis === :z
          xlabel = "x"
          ylabel = "y"
        else
          error("illegal dimension '$slice_axis', supported dimensions are :x, :y, and :z")
        end
      elseif ndims == 2
        xlabel = "x"
        ylabel = "y"
      end

      # Create plot
      verbose && println("| | | Creating figure...")
      @timeit "create figure" plot(size=(2000,2000), thickness_scaling=1,
                                   aspectratio=:equal, legend=:none, title="$label (t = $time)",
                                   colorbar=true, xlims=xlims, ylims=ylims,
                                   xlabel=xlabel, ylabel=ylabel,
                                   labelfontsize=18, tickfontsize=18,
                                   titlefontsize=28)

      # Plot contours
      verbose && println("| | | Plotting contours...")
      @timeit "plot contours" contourf!(xs, ys, node_centered_data[:, :, variable_id],
                                        c=:bluesreds, levels=128, linewidth=0,
                                        match_dimensions=true)

      # Plot grid lines
      if grid_lines
        verbose && println("| | | Plotting grid lines...")
        @timeit "plot grid lines" plot!(vertices_x, vertices_y, linecolor=:black,
                                        linewidth=1, grid=false)
      end

      # Determine output file name
      base, _ = splitext(splitdir(filename)[2])
      output_filename = joinpath(output_directory, "$(base)_$(label)." * string(format))

      # Save file
      @timeit "save plot" savefig(output_filename)
    end
  end

  verbose && println("| done.\n")
  print_timer()
  println()
end


text:
#
# Function that returns an ATOM line in PDB format
#
# requires Printf

function write_atom(atom::Atom)

  #ATOM      2  CA  GLY A   1      -1.774   6.778  32.054  1.00  0.08           C
  #COLUMNS        DATA  TYPE    FIELD        DEFINITION
  #-------------------------------------------------------------------------------------
  # 1 -  6        Record name   "ATOM  "
  # 7 - 11        Integer       serial       Atom  serial number.
  #13 - 16        Atom          name         Atom name.
  #17             Character     altLoc       Alternate location indicator.
  #18 - 20        Residue name  resName      Residue name.
  #22             Character     chainID      Chain identifier.
  #23 - 26        Integer       resSeq       Residue sequence number.
  #27             AChar         iCode        Code for insertion of residues.
  #31 - 38        Real(8.3)     x            Orthogonal coordinates for X in Angstroms.
  #39 - 46        Real(8.3)     y            Orthogonal coordinates for Y in Angstroms.
  #47 - 54        Real(8.3)     z            Orthogonal coordinates for Z in Angstroms.
  #55 - 60        Real(6.2)     occupancy    Occupancy.
  #61 - 66        Real(6.2)     tempFactor   Temperature  factor.
  #77 - 78        LString(2)    element      Element symbol, right-justified.
  #79 - 80        LString(2)    charge       Charge  on the atom.

  name = strip(atom.name)
  l = length(name)
  if l == 1
    name = "  $(atom.name) "
  elseif l == 2
    name = " $(atom.name) "
  elseif l == 3
    name = " $(atom.name)"
  else
    name = atom.name
  end
  if isprotein(atom)
    resname = strip(atom.resname)
    l = length(resname)
    if l == 3
      resname = " $(atom.resname) "
    elseif l == 4
      resname = "$(atom.resname) "
    end
  else
    resname = strip(atom.resname)
    l = length(resname)
    if l == 1
      resname = " $(atom.resname)   "
    elseif l == 2
      resname = " $(atom.resname)  "
    elseif l == 3
      resname = " $(atom.resname) "
    elseif l == 4
      resname = " $(atom.resname)"
    else
      resname = atom.resname
    end
  end

  if abs(atom.x) > 999.999 ||
     abs(atom.y) > 999.999 ||
     abs(atom.y) > 999.999
    println("Warning: coordinates of atom $(atom.index) "*
            "($(atom.name) $(atom.resname)$(atom.resnum) $(atom.chain)) "*
            "do not fit in PDB fixed format.")
  end

  if atom.index <= 99999 && atom.resnum <= 9999
    line = @sprintf("%-6s%5i%1s%4s%4s%1s%4i%4s%8.3f%8.3f%8.3f%6.2f%6.2f",
                     "ATOM",
                     atom.index," ",name,resname,atom.chain,atom.resnum,"    ",
                     atom.x,atom.y,atom.z,atom.occup,atom.beta)
  elseif atom.index > 99999 && atom.resnum <= 9999 # Prints index in hexadecimal code for atom index
    line = @sprintf("%-6s%5x%1s%4s%4s%1s%4i%4s%8.3f%8.3f%8.3f%6.2f%6.2f",
                     "ATOM",
                     atom.index," ",name,resname,atom.chain,atom.resnum,"    ",
                     atom.x,atom.y,atom.z,atom.occup,atom.beta)
  elseif atom.index <= 99999 && atom.resnum > 9999 # Prints resnum in hexadecimal code for atom index
    line = @sprintf("%-6s%5i%1s%4s%4s%1s%4x%4s%8.3f%8.3f%8.3f%6.2f%6.2f",
                     "ATOM",
                     atom.index," ",name,resname,atom.chain,atom.resnum,"    ",
                     atom.x,atom.y,atom.z,atom.occup,atom.beta)
  elseif atom.index > 99999 && atom.resnum > 9999 # Prints both in hexadecimal code for atom index
    line = @sprintf("%-6s%5x%1s%4s%4s%1s%4x%4s%8.3f%8.3f%8.3f%6.2f%6.2f",
                     "ATOM",
                     atom.index," ",name,resname,atom.chain,atom.resnum,"    ",
                     atom.x,atom.y,atom.z,atom.occup,atom.beta)
  end

  return line
end