Skip to main content

SHC.Ai Cli

Project description

SHCAi Client

build License python

Instalação

Para instalar o SHCAi client: pip install -U shcaicli

Uso

from shcaicli.api import SHCAi
import os

api_key = os.getenv('API_KEY')
shc = SHCAi(api_key=api_key, tokens_mode=True)

cn = 'Paciente diagnosticado com has, nega dm. Em 20/09 iniciou QT para tratamento CA de mama'
cn_inferred = shc.infer(cn=cn)

Estrutura de retorno

O exemplo acima retorna a seguinte estrutura:

Clique para ver
[
    {
        "text_tokens": [
            "Paciente",
            "diagnosticado",
            "com",
            "has",
            ",",
            "nega",
            "dm",
            ".",
            "Em",
            "20/09",
            "iniciou",
            "QT",
            "para",
            "tratamento",
            "CA",
            "de",
            "mama"
        ],
        "clinical_entities": [
            {
                "entity": "has",
                "entity_tokens": [
                    "has"
                ],
                "label": "DISEASE",
                "start": 3,
                "end": 4,
                "assertion": "PRESENTE",
                "adverse_event": "",
                "el": {
                    "term_text": "I10 - hipertensão essencial (primária)",
                    "terminology": "ICD10",
                    "term_code": "I10",
                    "term_desc": "hipertensão essencial (primária)"
                },
                "relations": []
            },
            {
                "entity": "dm",
                "entity_tokens": [
                    "dm"
                ],
                "label": "DISEASE",
                "start": 6,
                "end": 7,
                "assertion": "AUSENTE",
                "adverse_event": "",
                "el": {
                    "term_text": "E14 - diabetes mellitus não especificado",
                    "terminology": "ICD10",
                    "term_code": "E14",
                    "term_desc": "diabetes mellitus não especificado"
                },
                "relations": []
            },
            {
                "entity": "20/09",
                "entity_tokens": [
                    "20/09"
                ],
                "label": "TEMPORAL_CONCEPT",
                "start": 9,
                "end": 10,
                "assertion": "",
                "adverse_event": "",
                "el": {
                    "term_text": "",
                    "terminology": "",
                    "term_code": "",
                    "term_desc": ""
                },
                "relations": [
                    {
                        "entity": "QT",
                        "entity_tokens": [
                            "QT"
                        ],
                        "position": "tail",
                        "start": 11,
                        "end": 12,
                        "type": "is_date_of"
                    }
                ]
            },
            {
                "entity": "QT",
                "entity_tokens": [
                    "QT"
                ],
                "label": "PROCEDURE",
                "start": 11,
                "end": 12,
                "assertion": "PRESENTE",
                "adverse_event": "",
                "el": {
                    "term_text": "",
                    "terminology": "",
                    "term_code": "",
                    "term_desc": ""
                },
                "relations": [
                    {
                        "entity": "20/09",
                        "entity_tokens": [
                            "20/09"
                        ],
                        "position": "head",
                        "start": 9,
                        "end": 10,
                        "type": "is_date_of"
                    }
                ]
            },
            {
                "entity": "CA",
                "entity_tokens": [
                    "CA"
                ],
                "label": "DISEASE",
                "start": 14,
                "end": 15,
                "assertion": "PRESENTE",
                "adverse_event": "",
                "el": {
                    "term_text": "",
                    "terminology": "",
                    "term_code": "",
                    "term_desc": ""
                },
                "relations": [
                    {
                        "entity": "mama",
                        "entity_tokens": [
                            "mama"
                        ],
                        "position": "tail",
                        "start": 16,
                        "end": 17,
                        "type": "disease_has_primary_anatomic_site"
                    }
                ]
            },
            {
                "entity": "mama",
                "entity_tokens": [
                    "mama"
                ],
                "label": "BODY_PART",
                "start": 16,
                "end": 17,
                "assertion": "",
                "adverse_event": "",
                "el": {
                    "term_text": "",
                    "terminology": "",
                    "term_code": "",
                    "term_desc": ""
                },
                "relations": [
                    {
                        "entity": "CA",
                        "entity_tokens": [
                            "CA"
                        ],
                        "position": "head",
                        "start": 14,
                        "end": 15,
                        "type": "disease_has_primary_anatomic_site"
                    }
                ]
            }
        ],
        "biomarkers": [],
        "lab_tests": [],
        "vital_signs": [],
        "entities_relations": [
            {
                "relation_type": "is_date_of",
                "head_entity": "20/09",
                "tail_entity": "QT",
                "head_entity_tokens": [
                    "20/09"
                ],
                "tail_entity_tokens": [
                    "QT"
                ],
                "head_start": 9,
                "head_end": 10,
                "tail_start": 11,
                "tail_end": 12
            },
            {
                "relation_type": "disease_has_primary_anatomic_site",
                "head_entity": "CA",
                "tail_entity": "mama",
                "head_entity_tokens": [
                    "CA"
                ],
                "tail_entity_tokens": [
                    "mama"
                ],
                "head_start": 14,
                "head_end": 15,
                "tail_start": 16,
                "tail_end": 17
            }
        ]
    }
]

Atenção especial para a estrutura de cada clinical_entities:

{
    "entity": "20/09",
    "entity_tokens": [
        "20/09"
    ],
    "label": "TEMPORAL_CONCEPT",
    "start": 9,
    "end": 10,
    "assertion": "",
    "adverse_event": "",
    "el": {
        "term_text": "",
        "terminology": "",
        "term_code": "",
        "term_desc": ""
    },
    "relations": [
        {
            "entity": "QT",
            "entity_tokens": [
                "QT"
            ],
            "position": "tail",
            "start": 11,
            "end": 12,
            "type": "is_date_of"
        }
    ]
}

O campo relations está presente e mostra a quais outras entidades ela está relacionada. No exemplo acima, a entidade categorizada como TEMPORAL_CONCEPT 20/09 possui uma relação com a entidade QT. Ao analisar a relação vemos o campo especial position ele mostra que QT está no tail da relação que deve ser lida assim:

20/09 is_date_of QT

Tokens do texto da nota

O texto clínico foi quebrado em tokens para facilitar a identificação de cada item entre as relações. Os campos start e end fazem referência a posição do token na lista de tokens.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shcaicli-0.0.8.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

shcaicli-0.0.8-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file shcaicli-0.0.8.tar.gz.

File metadata

  • Download URL: shcaicli-0.0.8.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for shcaicli-0.0.8.tar.gz
Algorithm Hash digest
SHA256 eeebd162ba372bb04021c64d11ef217658ee9aea11e6c88e654deaae143f3876
MD5 eaa4c386260e91b96aa4eeb8ab91100d
BLAKE2b-256 3d9a4ec851c0ae3b4e253f7b5099c9294650345da1219d5c89189bec03dcf8a6

See more details on using hashes here.

File details

Details for the file shcaicli-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: shcaicli-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for shcaicli-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9bb89943936dc114b8d4d84fdc4945028f528bac7e4d6e89f02e8f494c4edd24
MD5 a0bfc84e9675f4132dcbda174f7ed51b
BLAKE2b-256 c3c086267db146eb6fd53738a594121bbdb248291f7a59b7726c1c0ac12fc8fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page