Module phc.easy.ocr.document

Expand source code
from phc.base_client import BaseClient
from phc.easy.auth import Auth
from phc.easy.document_reference import DocumentReference
from phc.easy.query import Query


class Document(DocumentReference):
    @classmethod
    def get(cls, id: str, auth_args: Auth = Auth.shared(), **kw_args):
        results = (
            super()
            .get_data_frame(
                id=id,
                term={"meta.tag.code.keyword": "PrecisionOCR Service"},
                auth_args=auth_args,
                **kw_args,
            )
            .to_dict("records")
        )

        return results[0] if len(results) else None

    @staticmethod
    def delete(id: str, auth_args: Auth = Auth.shared()):
        auth = Auth(auth_args)
        client = BaseClient(auth.session())

        return client._api_call(
            f"ocr/fhir/projects/{auth.project_id}/documentReferences/{id}",
            http_verb="DELETE",
        )

    @classmethod
    def get_data_frame(
        cls, all_results=False, auth_args: Auth = Auth.shared(), **kw_args
    ):
        return super().get_data_frame(
            term={"meta.tag.code.keyword": "PrecisionOCR Service"},
            all_results=all_results,
            auth_args=auth_args,
            **{"ignore_cache": True, **kw_args},
        )

Classes

class Document

Provides an abstract class and/or static methods for retrieving items from a FSS table that relates to a patient

Expand source code
class Document(DocumentReference):
    @classmethod
    def get(cls, id: str, auth_args: Auth = Auth.shared(), **kw_args):
        results = (
            super()
            .get_data_frame(
                id=id,
                term={"meta.tag.code.keyword": "PrecisionOCR Service"},
                auth_args=auth_args,
                **kw_args,
            )
            .to_dict("records")
        )

        return results[0] if len(results) else None

    @staticmethod
    def delete(id: str, auth_args: Auth = Auth.shared()):
        auth = Auth(auth_args)
        client = BaseClient(auth.session())

        return client._api_call(
            f"ocr/fhir/projects/{auth.project_id}/documentReferences/{id}",
            http_verb="DELETE",
        )

    @classmethod
    def get_data_frame(
        cls, all_results=False, auth_args: Auth = Auth.shared(), **kw_args
    ):
        return super().get_data_frame(
            term={"meta.tag.code.keyword": "PrecisionOCR Service"},
            all_results=all_results,
            auth_args=auth_args,
            **{"ignore_cache": True, **kw_args},
        )

Ancestors

Static methods

def code_fields()

Inherited from: DocumentReference.code_fields

Returns the code keys (e.g. when searching for codes)

def delete(id: str, auth_args: Auth = <phc.easy.auth.Auth object>)
Expand source code
@staticmethod
def delete(id: str, auth_args: Auth = Auth.shared()):
    auth = Auth(auth_args)
    client = BaseClient(auth.session())

    return client._api_call(
        f"ocr/fhir/projects/{auth.project_id}/documentReferences/{id}",
        http_verb="DELETE",
    )
def get(id: str, auth_args: Auth = <phc.easy.auth.Auth object>, **kw_args)
Expand source code
@classmethod
def get(cls, id: str, auth_args: Auth = Auth.shared(), **kw_args):
    results = (
        super()
        .get_data_frame(
            id=id,
            term={"meta.tag.code.keyword": "PrecisionOCR Service"},
            auth_args=auth_args,
            **kw_args,
        )
        .to_dict("records")
    )

    return results[0] if len(results) else None
def get_codes(display_query: Optional[str] = None, sample_size: Optional[int] = None, exclude_meta_tag=True, **kwargs)

Inherited from: DocumentReference.get_codes

Find all codes …

def get_count(query_overrides: dict = {}, auth_args=<phc.easy.auth.Auth object>)

Inherited from: DocumentReference.get_count

Get the count for a given FSS query

def get_count_by_field(field: str, **kwargs)

Inherited from: DocumentReference.get_count_by_field

Count records by a given field …

def get_count_by_patient(**kwargs)

Inherited from: DocumentReference.get_count_by_patient

Count records by a given field …

def get_data_frame(all_results=False, auth_args: Auth = <phc.easy.auth.Auth object>, **kw_args)

Inherited from: DocumentReference.get_data_frame

Retrieve records …

Expand source code
@classmethod
def get_data_frame(
    cls, all_results=False, auth_args: Auth = Auth.shared(), **kw_args
):
    return super().get_data_frame(
        term={"meta.tag.code.keyword": "PrecisionOCR Service"},
        all_results=all_results,
        auth_args=auth_args,
        **{"ignore_cache": True, **kw_args},
    )
def table_name()

Inherited from: DocumentReference.table_name

Returns the FSS table name for retrieval

def transform_results(df: pandas.core.frame.DataFrame, **expand_args)

Inherited from: DocumentReference.transform_results

Transform data frame batch