nlpsandboxclient
NLP data node client that interacts with the NLP SDK client
-
nlpsandboxclient.client.
annotate_note
(host: str, note: Union[dict, nlpsandbox.model.note.Note], tool_type: str) → dict[source] Annotate notes
- Parameters
host – Data node host IP
note – Clinical note
tool_type – Type of annotator
- Yields
Annotated notes
Examples
>>> example_note = { >>> "identifier": "note-1", >>> "noteType": "loinc:LP29684-5", >>> "patientId": "507f1f77bcf86cd799439011", >>> "text": "On 12/26/2020, Ms. Chloe Price met with Dr. Prescott." >>> } >>> annotations = annotate_note(host="0.0.0.0/api/v1", >>> note=example_note, >>> tool_type="date")
-
nlpsandboxclient.client.
get_annotation
(host: str, dataset_id: str, annotation_store_id: str, annotation_id: str) → nlpsandbox.model.annotation.Annotation[source] Gets an annotation
- Parameters
host – Data node host IP
dataset_id – Dataset Id
annotation_store_id – Annotation store Id
annotation_id – Annotation Id
- Returns
Data node Annotation object
Examples
>>> annotation = get_annotation( >>> host="0.0.0.0/api/v1", dataset_id="awesome-dataset", >>> annotation_store_id="awesome-annotation-store", >>> annotation_id="awesome-annotation" >>> )
-
nlpsandboxclient.client.
get_annotation_store
(host: str, dataset_id: str, annotation_store_id: str, create_if_missing: bool = False) → nlpsandbox.model.annotation_store.AnnotationStore[source] Creates an annotation store
- Parameters
host – Data node host IP
dataset_id – Dataset Id
annotation_store_id – Annotation store Id
create_if_missing – Creates annotation store if the resource doesn’t exist
- Returns
Data node Annotation Store object
Examples
>>> annotation = create_annotation_store( >>> host="0.0.0.0/api/v1", dataset_id="awesome-dataset", >>> annotation_store_id="awesome-annotation-store" >>> )
-
nlpsandboxclient.client.
get_tool
(host: str) → nlpsandbox.model.tool.Tool[source] Get annotater service
- Parameters
host – Annotation Service host IP
- Returns
Service object
- Raises
ValueError – If tool base URL isn’t redirected to tool service endpoint
Examples
>>> tool = get_tool(host="0.0.0.0/api/v1")
-
nlpsandboxclient.client.
list_annotations
(host: str, dataset_id: str, annotation_store_id: str) → Iterator[dict][source] List annotations
- Parameters
host – Data node host IP
dataset_id – Dataset Id
annotation_store_id – Annotation store Id
- Yields
Data node annotation objects
Examples
>>> annotations = list_annotations(host="0.0.0.0/api/v1", >>> dataset_id="awesome-dataset", >>> annotation_store_id="awesome-annotation-store")
-
nlpsandboxclient.client.
list_datasets
(host: str) → List[dict][source] Get all datasets
- Parameters
host – Data node host IP
- Yields
list of datasets.
Examples
>>> datasets = list_datasets(host="0.0.0.0/api/v1") >>> list(datasets)[0] >>> { >>> "name": "datasets/testing" >>> }
-
nlpsandboxclient.client.
list_notes
(host: str, dataset_id: str, fhir_store_id: str) → List[dict][source] Get all clinical notes for a dataset
- Parameters
host – Data node host IP
dataset_id – Dataset Id
fhir_store_id – FHIR store Id
- Yields
list of clinical notes.
Examples
>>> notes = get_notes(host="0.0.0.0/api/v1", >>> dataset_id="awesome-dataset", >>> fhir_store_id="awesome-fhir-store") >>> list(notes)[0] { "id": "noteid", "noteType": "", "patientId": "patient_id", "text": "Example text", "note_name": "dataset/awesome-dataset/fhirStores/awesome-fhirstore/fhir/Note/noteid" }
-
nlpsandboxclient.client.
store_annotations
(host: str, dataset_id: str, annotation_store_id: str, annotations: List[dict], delete_existing_annotations: bool = True)[source] Store submission annotated notes. Delete an annotation store if the annotation store exists, then create a new annotation store, then store the annotation.
- Parameters
host – Data node host IP
dataset_id – Dataset Id
annotation_store_id – Annotation store Id
annotations – List of data node Annotations
delete_existing_annotations – To delete existing annotation store. Default is True.
-
nlpsandboxclient.client.
store_dataset
(host: str, dataset_id: str) → nlpsandbox.model.dataset.Dataset[source] Creates a dataset
Utility functions
-
nlpsandboxclient.utils.
change_keys
(obj, convert)[source] Recursivly goes through the dictionnary obj and replaces keys with the convert function.
-
nlpsandboxclient.utils.
check_url
(url: str)[source] Check if url is implemented
- Parameters
url – The url to check
- Raises
ValueError – If url is not implemented
Examples
>>> check_url(url="https://www.google.com")
-
nlpsandboxclient.utils.
get_api_configuration
(host: str)[source] Get API configuration
- Parameters
host – Tool IP
- Returns
API configuration
Examples
>>> get_api_configuration(host="http://0.0.0.0:8080/api/v1")