diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4a5935..0f887d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: pull_request: env: - docker_repository: docker.synapse.org/syn22277123/physical-address-annotator-example + docker_repository: docker.synapse.org/syn22277123/location-annotator-example jobs: configure: diff --git a/.nlpsandbox-version b/.nlpsandbox-version index 45a1b3f..26aaba0 100644 --- a/.nlpsandbox-version +++ b/.nlpsandbox-version @@ -1 +1 @@ -1.1.2 +1.2.0 diff --git a/README.md b/README.md index f26560a..f0f7b07 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ [![nlpsandbox.io](https://nlpsandbox.github.io/nlpsandbox-themes/banner/Banner@3x.png)](https://nlpsandbox.io) -# NLP Sandbox Physical Address Annotator Example +# NLP Sandbox Location Annotator Example -[![GitHub Release](https://img.shields.io/github/release/nlpsandbox/physical-address-annotator-example.svg?include_prereleases&color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/physical-address-annotator-example/releases) -[![GitHub CI](https://img.shields.io/github/workflow/status/nlpsandbox/physical-address-annotator-example/CI.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/physical-address-annotator-example/actions) -[![GitHub License](https://img.shields.io/github/license/nlpsandbox/physical-address-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/physical-address-annotator-example/blob/develop/LICENSE) +[![GitHub Release](https://img.shields.io/github/release/nlpsandbox/location-annotator-example.svg?include_prereleases&color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/location-annotator-example/releases) +[![GitHub CI](https://img.shields.io/github/workflow/status/nlpsandbox/location-annotator-example/CI.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/location-annotator-example/actions) +[![GitHub License](https://img.shields.io/github/license/nlpsandbox/location-annotator-example.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/nlpsandbox/location-annotator-example/blob/develop/LICENSE) [![Docker](https://img.shields.io/badge/docker-blue.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=nlpsandbox&logo=data:image/svg%2bxml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMy4yIDcuOS0xLjctMXYxMS40bDkuOSA1LjdWMTIuNkw1LjYgOS4zIDMuMiA3Ljl6bTE3LjEtMS4zIDEuNS0uOUwxMiAwIDIuMiA1LjdsMi42IDEuNS4xLjEgMS43IDEgNS41IDMuMiA1LjEtMyAzLjEtMS45ek0xMiA5LjUgOS4zIDcuOSA3LjQgNi44bC0xLjctMS0uMS0uMWgtLjFMMTIgMS45bDYuNSAzLjhMMTYuMyA3IDEyIDkuNXptOC44LTEuNi0yLjQgMS40LS41LjItNS4zIDMuMVYyNGw5LjktNS43VjYuOWwtMS43IDF6IiBmaWxsPSIjZmZmIi8+PC9zdmc+)](https://www.synapse.org/#!Synapse:syn25830546 "Get the Docker image of this tool on NLPSandbox.io") [![Leaderboard](https://img.shields.io/badge/leaderboard-blue.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=nlpsandbox&logo=data:image/svg%2bxml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJtMy4yIDcuOS0xLjctMXYxMS40bDkuOSA1LjdWMTIuNkw1LjYgOS4zIDMuMiA3Ljl6bTE3LjEtMS4zIDEuNS0uOUwxMiAwIDIuMiA1LjdsMi42IDEuNS4xLjEgMS43IDEgNS41IDMuMiA1LjEtMyAzLjEtMS45ek0xMiA5LjUgOS4zIDcuOSA3LjQgNi44bC0xLjctMS0uMS0uMWgtLjFMMTIgMS45bDYuNSAzLjhMMTYuMyA3IDEyIDkuNXptOC44LTEuNi0yLjQgMS40LS41LjItNS4zIDMuMVYyNGw5LjktNS43VjYuOWwtMS43IDF6IiBmaWxsPSIjZmZmIi8+PC9zdmc+)](https://www.synapse.org/#!Synapse:syn22277123/wiki/609143 "View the performance of this tool on NLPSandbox.io") [![Discord](https://img.shields.io/discord/770484164393828373.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Discord&logo=discord)](https://nlpsandbox.io/discord "Realtime support / chat with the community and the team") @@ -16,14 +16,14 @@ processing (NLP) tools on both public and private datasets. Academics, students, and industry professionals are invited to browse the available tasks and participate by developing and submitting an NLP Sandbox tool. -This repository provides an example implementation of the [NLP Sandbox Physical -Address Annotator API] written in Python-Flask. An NLP Sandbox physical address -annotator takes as input a clinical note (text) and outputs a list of predicted -physical address annotations found in the clinical note. Here physicall -addresses are identified using dictionaries. +This repository provides an example implementation of the [NLP Sandbox Location +Annotator API] written in Python-Flask. An NLP Sandbox location annotator takes +as input a clinical note (text) and outputs a list of predicted location +annotations found in the clinical note. Here locations are identified using +dictionaries. This tool is provided to NLP developers who develop in Python as a starting -point to package their own physical address annotator as an NLP Sandbox tool +point to package their own location annotator as an NLP Sandbox tool (see section [Development](#Development)). This section also describes how to generate a tool "stub" using [openapi-generator] for 50+ programming languages-frameworks. This repository includes a GitHub CI/CD workflow that @@ -62,9 +62,9 @@ performance! ## Specification -- NLP Sandbox schemas version: 1.1.2 -- NLP Sandbox tool version: 1.1.2 -- Docker image: [docker.synapse.org/syn22277123/physical-address-annotator-example] +- NLP Sandbox schemas version: 1.2.0 +- NLP Sandbox tool version: 1.2.0 +- Docker image: [docker.synapse.org/syn22277123/location-annotator-example] ## Requirements @@ -76,7 +76,7 @@ performance! ### Running with Docker -The command below starts this NLP Sandbox physical address annotator locally. +The command below starts this NLP Sandbox location annotator locally. ```console docker compose up --build @@ -89,11 +89,11 @@ You can stop the container run with `Ctrl+C`, followed by `docker compose down`. Create a Conda environment. ```console -conda create --name physical-address-annotator python=3.9 -conda activate physical-address-annotator +conda create --name location-annotator python=3.9 +conda activate location-annotator ``` -Install and start this NLP Sandbox physical address annotator. +Install and start this NLP Sandbox location annotator. ```console cd server && pip install -r requirements.txt @@ -114,10 +114,10 @@ the tool using Docker (production) or Python (development). ## Development -This section describes how to develop your own NLP Sandbox physical address +This section describes how to develop your own NLP Sandbox location annotator in Python-Flask and other programming languages-frameworks. This example tool is also available in Java in the GitHub repository -[nlpsandbox/physical-address-annotator-example-java]. +[nlpsandbox/location-annotator-example-java]. ### Development requirements @@ -177,9 +177,9 @@ disabling version updates]. The development of new NLP Sandbox tools is streamlined by using the [openapi-generator] to generate tool "stubs" for more than 50 programming -languages and frameworks. Here a physical address annotator stub refers to an +languages and frameworks. Here a location annotator stub refers to an initial implementation that has been automatically generated by -[openapi-generator] from the [NLP Sandbox Physical Address Annotator API] +[openapi-generator] from the [NLP Sandbox Location Annotator API] specification. Run the command below to get the list of languages-framework supported by the @@ -189,7 +189,7 @@ Run the command below to get the list of languages-framework supported by the npx @openapitools/openapi-generator-cli list ``` -Generate the physical address annotator stub from an empty GitHub repository +Generate the location annotator stub from an empty GitHub repository (here in Python-Flask): ```console @@ -197,15 +197,15 @@ mkdir server npx @openapitools/openapi-generator-cli generate \ -g python-flask \ -o server \ - -i https://nlpsandbox.github.io/nlpsandbox-schemas/physical-address-annotator/latest/openapi.json + -i https://nlpsandbox.github.io/nlpsandbox-schemas/location-annotator/latest/openapi.json ``` where the option `-i` refers to the OpenAPI specification of the [NLP Sandbox -Physical Address Annotator API]. +Location Annotator API]. The URL is composed of different elements: -- `physical-address-annotator` - The type of NLP Sandbox tool to generate. The +- `location-annotator` - The type of NLP Sandbox tool to generate. The list of all the NLP Sandbox tool types available is defined in the [NLP Sandbox schemas]. - `latest` - The latest stable version of the [NLP Sandbox schemas]. This token @@ -332,11 +332,11 @@ Thinking about contributing to this project? Get started by reading our [nlpsandbox.io]: https://www.synapse.org/nlpsandbox -[docker.synapse.org/syn22277123/physical-address-annotator-example]: https://www.synapse.org/#!Synapse:syn25828638 +[docker.synapse.org/syn22277123/location-annotator-example]: https://www.synapse.org/#!Synapse:syn25828638 [Synapse.org]: https://synapse.org [openapi-generator]: https://github.com/OpenAPITools/openapi-generator [contribution guide]: .github/CONTRIBUTING.md -[Apache License 2.0]: https://github.com/nlpsandbox/physical-address-annotator-example/blob/main/LICENSE +[Apache License 2.0]: https://github.com/nlpsandbox/location-annotator-example/blob/main/LICENSE [Docker Engine]: https://docs.docker.com/engine/install/ [Node]: https://nodejs.org/en/ [Java]: https://www.java.com/en/download/help/download_options.html @@ -352,9 +352,9 @@ Thinking about contributing to this project? Get started by reading our [Enabling and disabling version updates]: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/enabling-and-disabling-version-updates [NLP Sandbox schemas]: https://github.com/nlpsandbox/nlpsandbox-schemas [nlpsandbox/nlpsandbox-schemas]: https://github.com/nlpsandbox/nlpsandbox-schemas -[NLP Sandbox Physical Address Annotator API]: https://nlpsandbox.github.io/nlpsandbox-schemas/physical-address-annotator/latest/docs/ -[this GitHub template]: https://github.com/nlpsandbox/physical-address-annotator-example/generate -[nlpsandbox/physical-address-annotator-example-java]: https://github.com/nlpsandbox/physical-address-annotator-example-java +[NLP Sandbox Location Annotator API]: https://nlpsandbox.github.io/nlpsandbox-schemas/location-annotator/latest/docs/ +[this GitHub template]: https://github.com/nlpsandbox/location-annotator-example/generate +[nlpsandbox/location-annotator-example-java]: https://github.com/nlpsandbox/location-annotator-example-java [Patient schema]: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/develop/openapi/commons/components/schemas/Patient.yaml [semantic versioning]: https://semver.org/ [NLP Sandbox schemas CHANGELOG]: .github/CHANGELOG.md diff --git a/docker-compose.yml b/docker-compose.yml index bc32c00..67cd0bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,21 @@ version: "3.8" services: - physical-address-annotator: - image: docker.synapse.org/syn22277123/physical-address-annotator-example:1.1.2 + location-annotator: + image: docker.synapse.org/syn22277123/location-annotator-example:1.2.0 build: context: server dockerfile: Dockerfile - container_name: physical-address-annotator + container_name: location-annotator networks: - nlpsandbox-internal nginx: image: nginx:1.19.6-alpine - container_name: physical-address-annotator-nginx + container_name: location-annotator-nginx restart: always environment: - - TOOL_HOST=physical-address-annotator + - TOOL_HOST=location-annotator - TOOL_PORT=8080 volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro @@ -26,7 +26,7 @@ services: ports: - "80:80" depends_on: - - physical-address-annotator + - location-annotator networks: nlpsandbox: diff --git a/package-lock.json b/package-lock.json index a77b839..0a631c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "physical-address-annotator-example", + "name": "location-annotator-example", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 89c2799..fed1dda 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ }, "scripts": { "generate:server": "openapi-generator-cli generate -g python-flask -o server -i $npm_config_specification", - "generate:server:latest": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/physical-address-annotator/latest/openapi.json", - "generate:server:edge": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/physical-address-annotator/edge/openapi.json", + "generate:server:latest": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/location-annotator/latest/openapi.json", + "generate:server:edge": "openapi-generator-cli generate -g python-flask -o server -i https://nlpsandbox.github.io/nlpsandbox-schemas/location-annotator/edge/openapi.json", "lint": "cd server && flake8", "test": "cd server && tox", "install:dependencies": "npm ci && cd server && pip install -r requirements.txt", diff --git a/server/openapi_server/controllers/text_physical_address_annotation_controller.py b/server/openapi_server/controllers/text_location_annotation_controller.py similarity index 70% rename from server/openapi_server/controllers/text_physical_address_annotation_controller.py rename to server/openapi_server/controllers/text_location_annotation_controller.py index 71cf536..b1fe21b 100644 --- a/server/openapi_server/controllers/text_physical_address_annotation_controller.py +++ b/server/openapi_server/controllers/text_location_annotation_controller.py @@ -3,9 +3,9 @@ import re from openapi_server.models.error import Error # noqa: E501 -from openapi_server.models.text_physical_address_annotation_request import TextPhysicalAddressAnnotationRequest # noqa: E501 -from openapi_server.models.text_physical_address_annotation import TextPhysicalAddressAnnotation # noqa: E501 -from openapi_server.models.text_physical_address_annotation_response import TextPhysicalAddressAnnotationResponse # noqa: E501 +from openapi_server.models.text_location_annotation import TextLocationAnnotation # noqa: E501 +from openapi_server.models.text_location_annotation_request import TextLocationAnnotationRequest # noqa: E501 +from openapi_server.models.text_location_annotation_response import TextLocationAnnotationResponse # noqa: E501 class Data: @@ -29,18 +29,21 @@ def __init__(self): data = Data() -def create_text_physical_address_annotations(): # noqa: E501 - """Annotate physical addresses in a clinical note +def create_text_location_annotations(): # noqa: E501 + """Annotate locations in a clinical note - Return the physical addresse annotations found in a clinical note # noqa: E501 + Return the location annotations found in a clinical note # noqa: E501 - :rtype: TextPhysicalAddressAnnotationResponse + :param text_location_annotation_request: + :type text_location_annotation_request: dict | bytes + + :rtype: TextLocationAnnotationResponse """ res = None status = None if connexion.request.is_json: try: - annotation_request = TextPhysicalAddressAnnotationRequest.from_dict(connexion.request.get_json()) # noqa: E501 + annotation_request = TextLocationAnnotationRequest.from_dict(connexion.request.get_json()) # noqa: E501 note = annotation_request._note annotations = [] @@ -70,7 +73,7 @@ def create_text_physical_address_annotations(): # noqa: E501 r'\b({})\b'.format(other), note._text, re.IGNORECASE) add_annotations(annotations, matches, 'other') - res = TextPhysicalAddressAnnotationResponse(annotations) + res = TextLocationAnnotationResponse(annotations) status = 200 except Exception as error: status = 500 @@ -78,17 +81,17 @@ def create_text_physical_address_annotations(): # noqa: E501 return res, status -def add_annotations(annotations, matches, address_type): +def add_annotations(annotations, matches, location_type): """ - Converts matches to TextPhysicalAddressAnnotation objects and adds them + Converts matches to TextLocationAnnotation objects and adds them to the annotations array specified. """ for match in matches: annotations.append( - TextPhysicalAddressAnnotation( + TextLocationAnnotation( start=match.start(), length=len(match[0]), text=match[0], - address_type=address_type, + location_type=location_type, confidence=95.5 )) diff --git a/server/openapi_server/controllers/tool_controller.py b/server/openapi_server/controllers/tool_controller.py index 7ad501d..059f2a6 100644 --- a/server/openapi_server/controllers/tool_controller.py +++ b/server/openapi_server/controllers/tool_controller.py @@ -1,5 +1,6 @@ from openapi_server.models.tool import Tool # noqa: E501 from openapi_server.models.tool_dependencies import ToolDependencies # noqa: E501 +from openapi_server.models.tool_type import ToolType from openapi_server.models.license import License @@ -12,17 +13,17 @@ def get_tool(): # noqa: E501 :rtype: Tool """ tool = Tool( - name="physical-address-annotator-example", - version="1.1.2", + name="location-annotator-example", + version="1.2.0", license=License.APACHE_2_0, - repository="github:nlpsandbox/physical-address-annotator-example", - description="Example implementation of the NLP Sandbox Physical " + - "Address Annotator", + repository="github:nlpsandbox/location-annotator-example", + description="Example implementation of the NLP Sandbox Location " + + "Annotator API", author="NLP Sandbox Team", author_email="team@nlpsandbox.io", - url="https://github.com/nlpsandbox/physical-address-annotator-example", - type="nlpsandbox:physical-address-annotator", - api_version="1.1.2" + url="https://github.com/nlpsandbox/location-annotator-example", + type=ToolType.LOCATION_ANNOTATOR, + api_version="1.2.0" ) return tool, 200 diff --git a/server/openapi_server/models/__init__.py b/server/openapi_server/models/__init__.py index 8d7f535..b506fde 100644 --- a/server/openapi_server/models/__init__.py +++ b/server/openapi_server/models/__init__.py @@ -8,9 +8,10 @@ from openapi_server.models.license import License from openapi_server.models.note import Note from openapi_server.models.text_annotation import TextAnnotation -from openapi_server.models.text_physical_address_annotation import TextPhysicalAddressAnnotation -from openapi_server.models.text_physical_address_annotation_all_of import TextPhysicalAddressAnnotationAllOf -from openapi_server.models.text_physical_address_annotation_request import TextPhysicalAddressAnnotationRequest -from openapi_server.models.text_physical_address_annotation_response import TextPhysicalAddressAnnotationResponse +from openapi_server.models.text_location_annotation import TextLocationAnnotation +from openapi_server.models.text_location_annotation_all_of import TextLocationAnnotationAllOf +from openapi_server.models.text_location_annotation_request import TextLocationAnnotationRequest +from openapi_server.models.text_location_annotation_response import TextLocationAnnotationResponse from openapi_server.models.tool import Tool from openapi_server.models.tool_dependencies import ToolDependencies +from openapi_server.models.tool_type import ToolType diff --git a/server/openapi_server/models/text_physical_address_annotation.py b/server/openapi_server/models/text_location_annotation.py similarity index 55% rename from server/openapi_server/models/text_physical_address_annotation.py rename to server/openapi_server/models/text_location_annotation.py index ed0c32d..a7dac38 100644 --- a/server/openapi_server/models/text_physical_address_annotation.py +++ b/server/openapi_server/models/text_location_annotation.py @@ -7,38 +7,38 @@ from openapi_server.models.base_model_ import Model from openapi_server.models.text_annotation import TextAnnotation -from openapi_server.models.text_physical_address_annotation_all_of import TextPhysicalAddressAnnotationAllOf +from openapi_server.models.text_location_annotation_all_of import TextLocationAnnotationAllOf from openapi_server import util from openapi_server.models.text_annotation import TextAnnotation # noqa: E501 -from openapi_server.models.text_physical_address_annotation_all_of import TextPhysicalAddressAnnotationAllOf # noqa: E501 +from openapi_server.models.text_location_annotation_all_of import TextLocationAnnotationAllOf # noqa: E501 -class TextPhysicalAddressAnnotation(Model): +class TextLocationAnnotation(Model): """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. """ - def __init__(self, start=None, length=None, text=None, confidence=None, address_type=None): # noqa: E501 - """TextPhysicalAddressAnnotation - a model defined in OpenAPI + def __init__(self, start=None, length=None, text=None, confidence=None, location_type=None): # noqa: E501 + """TextLocationAnnotation - a model defined in OpenAPI - :param start: The start of this TextPhysicalAddressAnnotation. # noqa: E501 + :param start: The start of this TextLocationAnnotation. # noqa: E501 :type start: int - :param length: The length of this TextPhysicalAddressAnnotation. # noqa: E501 + :param length: The length of this TextLocationAnnotation. # noqa: E501 :type length: int - :param text: The text of this TextPhysicalAddressAnnotation. # noqa: E501 + :param text: The text of this TextLocationAnnotation. # noqa: E501 :type text: str - :param confidence: The confidence of this TextPhysicalAddressAnnotation. # noqa: E501 + :param confidence: The confidence of this TextLocationAnnotation. # noqa: E501 :type confidence: float - :param address_type: The address_type of this TextPhysicalAddressAnnotation. # noqa: E501 - :type address_type: str + :param location_type: The location_type of this TextLocationAnnotation. # noqa: E501 + :type location_type: str """ self.openapi_types = { 'start': int, 'length': int, 'text': str, 'confidence': float, - 'address_type': str + 'location_type': str } self.attribute_map = { @@ -46,44 +46,44 @@ def __init__(self, start=None, length=None, text=None, confidence=None, address_ 'length': 'length', 'text': 'text', 'confidence': 'confidence', - 'address_type': 'addressType' + 'location_type': 'locationType' } self._start = start self._length = length self._text = text self._confidence = confidence - self._address_type = address_type + self._location_type = location_type @classmethod - def from_dict(cls, dikt) -> 'TextPhysicalAddressAnnotation': + def from_dict(cls, dikt) -> 'TextLocationAnnotation': """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The TextPhysicalAddressAnnotation of this TextPhysicalAddressAnnotation. # noqa: E501 - :rtype: TextPhysicalAddressAnnotation + :return: The TextLocationAnnotation of this TextLocationAnnotation. # noqa: E501 + :rtype: TextLocationAnnotation """ return util.deserialize_model(dikt, cls) @property def start(self): - """Gets the start of this TextPhysicalAddressAnnotation. + """Gets the start of this TextLocationAnnotation. The position of the first character # noqa: E501 - :return: The start of this TextPhysicalAddressAnnotation. + :return: The start of this TextLocationAnnotation. :rtype: int """ return self._start @start.setter def start(self, start): - """Sets the start of this TextPhysicalAddressAnnotation. + """Sets the start of this TextLocationAnnotation. The position of the first character # noqa: E501 - :param start: The start of this TextPhysicalAddressAnnotation. + :param start: The start of this TextLocationAnnotation. :type start: int """ if start is None: @@ -93,22 +93,22 @@ def start(self, start): @property def length(self): - """Gets the length of this TextPhysicalAddressAnnotation. + """Gets the length of this TextLocationAnnotation. The length of the annotation # noqa: E501 - :return: The length of this TextPhysicalAddressAnnotation. + :return: The length of this TextLocationAnnotation. :rtype: int """ return self._length @length.setter def length(self, length): - """Sets the length of this TextPhysicalAddressAnnotation. + """Sets the length of this TextLocationAnnotation. The length of the annotation # noqa: E501 - :param length: The length of this TextPhysicalAddressAnnotation. + :param length: The length of this TextLocationAnnotation. :type length: int """ if length is None: @@ -118,22 +118,22 @@ def length(self, length): @property def text(self): - """Gets the text of this TextPhysicalAddressAnnotation. + """Gets the text of this TextLocationAnnotation. The string annotated # noqa: E501 - :return: The text of this TextPhysicalAddressAnnotation. + :return: The text of this TextLocationAnnotation. :rtype: str """ return self._text @text.setter def text(self, text): - """Sets the text of this TextPhysicalAddressAnnotation. + """Sets the text of this TextLocationAnnotation. The string annotated # noqa: E501 - :param text: The text of this TextPhysicalAddressAnnotation. + :param text: The text of this TextLocationAnnotation. :type text: str """ if text is None: @@ -143,22 +143,22 @@ def text(self, text): @property def confidence(self): - """Gets the confidence of this TextPhysicalAddressAnnotation. + """Gets the confidence of this TextLocationAnnotation. The confidence in the accuracy of the annotation # noqa: E501 - :return: The confidence of this TextPhysicalAddressAnnotation. + :return: The confidence of this TextLocationAnnotation. :rtype: float """ return self._confidence @confidence.setter def confidence(self, confidence): - """Sets the confidence of this TextPhysicalAddressAnnotation. + """Sets the confidence of this TextLocationAnnotation. The confidence in the accuracy of the annotation # noqa: E501 - :param confidence: The confidence of this TextPhysicalAddressAnnotation. + :param confidence: The confidence of this TextLocationAnnotation. :type confidence: float """ if confidence is None: @@ -171,30 +171,30 @@ def confidence(self, confidence): self._confidence = confidence @property - def address_type(self): - """Gets the address_type of this TextPhysicalAddressAnnotation. + def location_type(self): + """Gets the location_type of this TextLocationAnnotation. - Type of address information # noqa: E501 + Type of location # noqa: E501 - :return: The address_type of this TextPhysicalAddressAnnotation. + :return: The location_type of this TextLocationAnnotation. :rtype: str """ - return self._address_type + return self._location_type - @address_type.setter - def address_type(self, address_type): - """Sets the address_type of this TextPhysicalAddressAnnotation. + @location_type.setter + def location_type(self, location_type): + """Sets the location_type of this TextLocationAnnotation. - Type of address information # noqa: E501 + Type of location # noqa: E501 - :param address_type: The address_type of this TextPhysicalAddressAnnotation. - :type address_type: str + :param location_type: The location_type of this TextLocationAnnotation. + :type location_type: str """ allowed_values = ["city", "country", "department", "hospital", "organization", "other", "room", "state", "street", "zip"] # noqa: E501 - if address_type not in allowed_values: + if location_type not in allowed_values: raise ValueError( - "Invalid value for `address_type` ({0}), must be one of {1}" - .format(address_type, allowed_values) + "Invalid value for `location_type` ({0}), must be one of {1}" + .format(location_type, allowed_values) ) - self._address_type = address_type + self._location_type = location_type diff --git a/server/openapi_server/models/text_location_annotation_all_of.py b/server/openapi_server/models/text_location_annotation_all_of.py new file mode 100644 index 0000000..751f01f --- /dev/null +++ b/server/openapi_server/models/text_location_annotation_all_of.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from openapi_server.models.base_model_ import Model +from openapi_server import util + + +class TextLocationAnnotationAllOf(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, location_type=None): # noqa: E501 + """TextLocationAnnotationAllOf - a model defined in OpenAPI + + :param location_type: The location_type of this TextLocationAnnotationAllOf. # noqa: E501 + :type location_type: str + """ + self.openapi_types = { + 'location_type': str + } + + self.attribute_map = { + 'location_type': 'locationType' + } + + self._location_type = location_type + + @classmethod + def from_dict(cls, dikt) -> 'TextLocationAnnotationAllOf': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The TextLocationAnnotation_allOf of this TextLocationAnnotationAllOf. # noqa: E501 + :rtype: TextLocationAnnotationAllOf + """ + return util.deserialize_model(dikt, cls) + + @property + def location_type(self): + """Gets the location_type of this TextLocationAnnotationAllOf. + + Type of location # noqa: E501 + + :return: The location_type of this TextLocationAnnotationAllOf. + :rtype: str + """ + return self._location_type + + @location_type.setter + def location_type(self, location_type): + """Sets the location_type of this TextLocationAnnotationAllOf. + + Type of location # noqa: E501 + + :param location_type: The location_type of this TextLocationAnnotationAllOf. + :type location_type: str + """ + allowed_values = ["city", "country", "department", "hospital", "organization", "other", "room", "state", "street", "zip"] # noqa: E501 + if location_type not in allowed_values: + raise ValueError( + "Invalid value for `location_type` ({0}), must be one of {1}" + .format(location_type, allowed_values) + ) + + self._location_type = location_type diff --git a/server/openapi_server/models/text_physical_address_annotation_request.py b/server/openapi_server/models/text_location_annotation_request.py similarity index 61% rename from server/openapi_server/models/text_physical_address_annotation_request.py rename to server/openapi_server/models/text_location_annotation_request.py index cb52a41..2a35626 100644 --- a/server/openapi_server/models/text_physical_address_annotation_request.py +++ b/server/openapi_server/models/text_location_annotation_request.py @@ -11,16 +11,16 @@ from openapi_server.models.note import Note # noqa: E501 -class TextPhysicalAddressAnnotationRequest(Model): +class TextLocationAnnotationRequest(Model): """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually. """ def __init__(self, note=None): # noqa: E501 - """TextPhysicalAddressAnnotationRequest - a model defined in OpenAPI + """TextLocationAnnotationRequest - a model defined in OpenAPI - :param note: The note of this TextPhysicalAddressAnnotationRequest. # noqa: E501 + :param note: The note of this TextLocationAnnotationRequest. # noqa: E501 :type note: Note """ self.openapi_types = { @@ -34,32 +34,32 @@ def __init__(self, note=None): # noqa: E501 self._note = note @classmethod - def from_dict(cls, dikt) -> 'TextPhysicalAddressAnnotationRequest': + def from_dict(cls, dikt) -> 'TextLocationAnnotationRequest': """Returns the dict as a model :param dikt: A dict. :type: dict - :return: The TextPhysicalAddressAnnotationRequest of this TextPhysicalAddressAnnotationRequest. # noqa: E501 - :rtype: TextPhysicalAddressAnnotationRequest + :return: The TextLocationAnnotationRequest of this TextLocationAnnotationRequest. # noqa: E501 + :rtype: TextLocationAnnotationRequest """ return util.deserialize_model(dikt, cls) @property def note(self): - """Gets the note of this TextPhysicalAddressAnnotationRequest. + """Gets the note of this TextLocationAnnotationRequest. - :return: The note of this TextPhysicalAddressAnnotationRequest. + :return: The note of this TextLocationAnnotationRequest. :rtype: Note """ return self._note @note.setter def note(self, note): - """Sets the note of this TextPhysicalAddressAnnotationRequest. + """Sets the note of this TextLocationAnnotationRequest. - :param note: The note of this TextPhysicalAddressAnnotationRequest. + :param note: The note of this TextLocationAnnotationRequest. :type note: Note """ if note is None: diff --git a/server/openapi_server/models/text_location_annotation_response.py b/server/openapi_server/models/text_location_annotation_response.py new file mode 100644 index 0000000..9e024d3 --- /dev/null +++ b/server/openapi_server/models/text_location_annotation_response.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from openapi_server.models.base_model_ import Model +from openapi_server.models.text_location_annotation import TextLocationAnnotation +from openapi_server import util + +from openapi_server.models.text_location_annotation import TextLocationAnnotation # noqa: E501 + +class TextLocationAnnotationResponse(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, text_location_annotations=None): # noqa: E501 + """TextLocationAnnotationResponse - a model defined in OpenAPI + + :param text_location_annotations: The text_location_annotations of this TextLocationAnnotationResponse. # noqa: E501 + :type text_location_annotations: List[TextLocationAnnotation] + """ + self.openapi_types = { + 'text_location_annotations': List[TextLocationAnnotation] + } + + self.attribute_map = { + 'text_location_annotations': 'textLocationAnnotations' + } + + self._text_location_annotations = text_location_annotations + + @classmethod + def from_dict(cls, dikt) -> 'TextLocationAnnotationResponse': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The TextLocationAnnotationResponse of this TextLocationAnnotationResponse. # noqa: E501 + :rtype: TextLocationAnnotationResponse + """ + return util.deserialize_model(dikt, cls) + + @property + def text_location_annotations(self): + """Gets the text_location_annotations of this TextLocationAnnotationResponse. + + A list of location annotations # noqa: E501 + + :return: The text_location_annotations of this TextLocationAnnotationResponse. + :rtype: List[TextLocationAnnotation] + """ + return self._text_location_annotations + + @text_location_annotations.setter + def text_location_annotations(self, text_location_annotations): + """Sets the text_location_annotations of this TextLocationAnnotationResponse. + + A list of location annotations # noqa: E501 + + :param text_location_annotations: The text_location_annotations of this TextLocationAnnotationResponse. + :type text_location_annotations: List[TextLocationAnnotation] + """ + if text_location_annotations is None: + raise ValueError("Invalid value for `text_location_annotations`, must not be `None`") # noqa: E501 + + self._text_location_annotations = text_location_annotations diff --git a/server/openapi_server/models/text_physical_address_annotation_all_of.py b/server/openapi_server/models/text_physical_address_annotation_all_of.py deleted file mode 100644 index 924e190..0000000 --- a/server/openapi_server/models/text_physical_address_annotation_all_of.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -from datetime import date, datetime # noqa: F401 - -from typing import List, Dict # noqa: F401 - -from openapi_server.models.base_model_ import Model -from openapi_server import util - - -class TextPhysicalAddressAnnotationAllOf(Model): - """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - - Do not edit the class manually. - """ - - def __init__(self, address_type=None): # noqa: E501 - """TextPhysicalAddressAnnotationAllOf - a model defined in OpenAPI - - :param address_type: The address_type of this TextPhysicalAddressAnnotationAllOf. # noqa: E501 - :type address_type: str - """ - self.openapi_types = { - 'address_type': str - } - - self.attribute_map = { - 'address_type': 'addressType' - } - - self._address_type = address_type - - @classmethod - def from_dict(cls, dikt) -> 'TextPhysicalAddressAnnotationAllOf': - """Returns the dict as a model - - :param dikt: A dict. - :type: dict - :return: The TextPhysicalAddressAnnotation_allOf of this TextPhysicalAddressAnnotationAllOf. # noqa: E501 - :rtype: TextPhysicalAddressAnnotationAllOf - """ - return util.deserialize_model(dikt, cls) - - @property - def address_type(self): - """Gets the address_type of this TextPhysicalAddressAnnotationAllOf. - - Type of address information # noqa: E501 - - :return: The address_type of this TextPhysicalAddressAnnotationAllOf. - :rtype: str - """ - return self._address_type - - @address_type.setter - def address_type(self, address_type): - """Sets the address_type of this TextPhysicalAddressAnnotationAllOf. - - Type of address information # noqa: E501 - - :param address_type: The address_type of this TextPhysicalAddressAnnotationAllOf. - :type address_type: str - """ - allowed_values = ["city", "country", "department", "hospital", "organization", "other", "room", "state", "street", "zip"] # noqa: E501 - if address_type not in allowed_values: - raise ValueError( - "Invalid value for `address_type` ({0}), must be one of {1}" - .format(address_type, allowed_values) - ) - - self._address_type = address_type diff --git a/server/openapi_server/models/text_physical_address_annotation_response.py b/server/openapi_server/models/text_physical_address_annotation_response.py deleted file mode 100644 index b2e13a8..0000000 --- a/server/openapi_server/models/text_physical_address_annotation_response.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -from datetime import date, datetime # noqa: F401 - -from typing import List, Dict # noqa: F401 - -from openapi_server.models.base_model_ import Model -from openapi_server.models.text_physical_address_annotation import TextPhysicalAddressAnnotation -from openapi_server import util - -from openapi_server.models.text_physical_address_annotation import TextPhysicalAddressAnnotation # noqa: E501 - -class TextPhysicalAddressAnnotationResponse(Model): - """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - - Do not edit the class manually. - """ - - def __init__(self, text_physical_address_annotations=None): # noqa: E501 - """TextPhysicalAddressAnnotationResponse - a model defined in OpenAPI - - :param text_physical_address_annotations: The text_physical_address_annotations of this TextPhysicalAddressAnnotationResponse. # noqa: E501 - :type text_physical_address_annotations: List[TextPhysicalAddressAnnotation] - """ - self.openapi_types = { - 'text_physical_address_annotations': List[TextPhysicalAddressAnnotation] - } - - self.attribute_map = { - 'text_physical_address_annotations': 'textPhysicalAddressAnnotations' - } - - self._text_physical_address_annotations = text_physical_address_annotations - - @classmethod - def from_dict(cls, dikt) -> 'TextPhysicalAddressAnnotationResponse': - """Returns the dict as a model - - :param dikt: A dict. - :type: dict - :return: The TextPhysicalAddressAnnotationResponse of this TextPhysicalAddressAnnotationResponse. # noqa: E501 - :rtype: TextPhysicalAddressAnnotationResponse - """ - return util.deserialize_model(dikt, cls) - - @property - def text_physical_address_annotations(self): - """Gets the text_physical_address_annotations of this TextPhysicalAddressAnnotationResponse. - - A list of physical address annotations # noqa: E501 - - :return: The text_physical_address_annotations of this TextPhysicalAddressAnnotationResponse. - :rtype: List[TextPhysicalAddressAnnotation] - """ - return self._text_physical_address_annotations - - @text_physical_address_annotations.setter - def text_physical_address_annotations(self, text_physical_address_annotations): - """Sets the text_physical_address_annotations of this TextPhysicalAddressAnnotationResponse. - - A list of physical address annotations # noqa: E501 - - :param text_physical_address_annotations: The text_physical_address_annotations of this TextPhysicalAddressAnnotationResponse. - :type text_physical_address_annotations: List[TextPhysicalAddressAnnotation] - """ - if text_physical_address_annotations is None: - raise ValueError("Invalid value for `text_physical_address_annotations`, must not be `None`") # noqa: E501 - - self._text_physical_address_annotations = text_physical_address_annotations diff --git a/server/openapi_server/models/tool.py b/server/openapi_server/models/tool.py index 15a4628..ed54381 100644 --- a/server/openapi_server/models/tool.py +++ b/server/openapi_server/models/tool.py @@ -7,10 +7,12 @@ from openapi_server.models.base_model_ import Model from openapi_server.models.license import License +from openapi_server.models.tool_type import ToolType import re from openapi_server import util from openapi_server.models.license import License # noqa: E501 +from openapi_server.models.tool_type import ToolType # noqa: E501 import re # noqa: E501 class Tool(Model): @@ -39,7 +41,7 @@ def __init__(self, name=None, version=None, license=None, repository=None, descr :param url: The url of this Tool. # noqa: E501 :type url: str :param type: The type of this Tool. # noqa: E501 - :type type: str + :type type: ToolType :param api_version: The api_version of this Tool. # noqa: E501 :type api_version: str """ @@ -52,7 +54,7 @@ def __init__(self, name=None, version=None, license=None, repository=None, descr 'author': str, 'author_email': str, 'url': str, - 'type': str, + 'type': ToolType, 'api_version': str } @@ -221,8 +223,8 @@ def description(self, description): """ if description is None: raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 - if description is not None and len(description) > 100: - raise ValueError("Invalid value for `description`, length must be less than or equal to `100`") # noqa: E501 + if description is not None and len(description) > 280: + raise ValueError("Invalid value for `description`, length must be less than or equal to `280`") # noqa: E501 self._description = description @@ -305,10 +307,9 @@ def url(self, url): def type(self): """Gets the type of this Tool. - The type of this tool # noqa: E501 :return: The type of this Tool. - :rtype: str + :rtype: ToolType """ return self._type @@ -316,19 +317,12 @@ def type(self): def type(self, type): """Sets the type of this Tool. - The type of this tool # noqa: E501 :param type: The type of this Tool. - :type type: str + :type type: ToolType """ if type is None: raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501 - if type is not None and len(type) > 60: - raise ValueError("Invalid value for `type`, length must be less than or equal to `60`") # noqa: E501 - if type is not None and len(type) < 3: - raise ValueError("Invalid value for `type`, length must be greater than or equal to `3`") # noqa: E501 - if type is not None and not re.search(r'^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$', type): # noqa: E501 - raise ValueError("Invalid value for `type`, must be a follow pattern or equal to `/^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$/`") # noqa: E501 self._type = type diff --git a/server/openapi_server/models/tool_type.py b/server/openapi_server/models/tool_type.py new file mode 100644 index 0000000..2b00018 --- /dev/null +++ b/server/openapi_server/models/tool_type.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from openapi_server.models.base_model_ import Model +from openapi_server import util + + +class ToolType(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + """ + allowed enum values + """ + CONTACT_ANNOTATOR = "nlpsandbox:contact-annotator" + COVID_SYMPTOM_ANNOTATOR = "nlpsandbox:covid-symptom-annotator" + DATA_NODE = "nlpsandbox:data-node" + DATE_ANNOTATOR = "nlpsandbox:date-annotator" + ID_ANNOTATOR = "nlpsandbox:id-annotator" + PERSON_NAME_ANNOTATOR = "nlpsandbox:person-name-annotator" + PHI_ANNOTATOR = "nlpsandbox:phi-annotator" + PHI_DEIDENTIFIER = "nlpsandbox:phi-deidentifier" + LOCATION_ANNOTATOR = "nlpsandbox:location-annotator" + def __init__(self): # noqa: E501 + """ToolType - a model defined in OpenAPI + + """ + self.openapi_types = { + } + + self.attribute_map = { + } + + @classmethod + def from_dict(cls, dikt) -> 'ToolType': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The ToolType of this ToolType. # noqa: E501 + :rtype: ToolType + """ + return util.deserialize_model(dikt, cls) diff --git a/server/openapi_server/openapi/openapi.yaml b/server/openapi_server/openapi/openapi.yaml index 109797a..fa27b5f 100644 --- a/server/openapi_server/openapi/openapi.yaml +++ b/server/openapi_server/openapi/openapi.yaml @@ -6,13 +6,13 @@ info: url: https://nlpsandbox.io description: | # Introduction - A Physical Address Annotator takes as input a clinical note and outputs a list of predicted physical address annotations found in the clinical note. This OpenAPI document describes the specification of a Physical Address Annotator. This specification includes the schemas of the input and output data, and the conditions that this annotator must meet if you want to benchmark its performance on [nlpsandbox.io](https://nlpsandbox.io). + A location annotator takes as input a clinical note and outputs a list of predicted location annotations found in the clinical note. This OpenAPI document describes the specification of the NLP Sandbox Location Annotator API. This specification includes the schemas of the input and output data, and the requirements that this annotator must meet if you want to benchmark its performance on [nlpsandbox.io](https://nlpsandbox.io). # Getting Started - The GitHub repository [nlpsandbox/physical-address-annotator-example](https://github.com/nlpsandbox/physical-address-annotator-example) provides a simple example implementation of a Python-Flask Physical Address Annotator. By the end of the tutorial available in the README, you will have built a Docker image for a simple Physical Address Annotator. You will then be able to submit this image to [nlpsandbox.io](https://nlpsandbox.io) to benchmark its performance. + The GitHub repository [nlpsandbox/location-annotator-example](https://github.com/nlpsandbox/location-annotator-example) provides an example implementation of the NLP Sandbox Location Annotator API in Python-Flask. By the end of the tutorial available in the README, you will have built a Docker image for this NLP Sandbox tool. You will then be able to submit this image to [nlpsandbox.io](https://nlpsandbox.io) to benchmark its performance. # Benchmarking Requirements - Your NLP Sandbox tool must meet the following conditions before evaluating its performance on [nlpsandbox.io](https://nlpsandbox.io). + Your NLP Sandbox tool must meet the following requirements before evaluating its performance on [nlpsandbox.io](https://nlpsandbox.io). - The endpoint `/` must redirect to `/api/v1/tool`. - - The endpoint `/ui` must redirect to the web interface (UI). + - The endpoint `/ui` must redirect to the Swagger User Interface (UI). - The output of this tool must be reproducible: a given input should always generate the same output. @@ -22,22 +22,22 @@ info: connect to remote servers. # Examples - - [Physical Address Annotator Example (Python)](https://github.com/nlpsandbox/physical-address-annotator-example) + - [NLP Sandbox Location Annotator Example (Python)](https://github.com/nlpsandbox/location-annotator-example) license: name: Apache 2.0 - url: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/develop/LICENSE - title: NLP Sandbox Physical Address Annotator API - version: 1.1.2 + url: https://github.com/nlpsandbox/nlpsandbox-schemas/blob/main/LICENSE + title: NLP Sandbox Location Annotator API + version: 1.2.0 x-logo: - url: https://nlpsandbox.github.io/nlpsandbox-schemas/logo.png + url: https://github.com/nlpsandbox/nlpsandbox-schemas/raw/main/docs/logo.png servers: - url: http://example.com/api/v1 - url: https://example.com/api/v1 tags: - description: Operations about health checks name: HealthCheck -- description: Operations about text physical address annotations - name: TextPhysicalAddressAnnotation +- description: Operations about text location annotations + name: TextLocationAnnotation - description: Operations about this tool name: Tool paths: @@ -69,21 +69,21 @@ paths: tags: - HealthCheck x-openapi-router-controller: openapi_server.controllers.health_check_controller - /textPhysicalAddressAnnotations: + /textLocationAnnotations: post: - description: Return the physical addresse annotations found in a clinical note - operationId: create_text_physical_address_annotations + description: Return the location annotations found in a clinical note + operationId: create_text_location_annotations requestBody: content: application/json: schema: - $ref: '#/components/schemas/TextPhysicalAddressAnnotationRequest' + $ref: '#/components/schemas/TextLocationAnnotationRequest' responses: "200": content: application/json: schema: - $ref: '#/components/schemas/TextPhysicalAddressAnnotationResponse' + $ref: '#/components/schemas/TextLocationAnnotationResponse' description: Success "400": content: @@ -98,10 +98,10 @@ paths: $ref: '#/components/schemas/Error' description: The request cannot be fulfilled due to an unexpected server error - summary: Annotate physical addresses in a clinical note + summary: Annotate locations in a clinical note tags: - - TextPhysicalAddressAnnotation - x-openapi-router-controller: openapi_server.controllers.text_physical_address_annotation_controller + - TextLocationAnnotation + x-openapi-router-controller: openapi_server.controllers.text_location_annotation_controller /tool: get: description: Get information about the tool @@ -270,8 +270,8 @@ components: - type title: Note type: object - TextPhysicalAddressAnnotationRequest: - description: A request to annotate physical addresses in a clinical note + TextLocationAnnotationRequest: + description: A request to annotate locations in a clinical note example: note: identifier: awesome-note @@ -313,43 +313,43 @@ components: - start - text type: object - TextPhysicalAddressAnnotation: + TextLocationAnnotation: allOf: - $ref: '#/components/schemas/TextAnnotation' - - $ref: '#/components/schemas/TextPhysicalAddressAnnotation_allOf' - description: A physical address annotation in a text + - $ref: '#/components/schemas/TextLocationAnnotation_allOf' + description: A location annotation in a text example: start: 42 length: 7 text: Seattle - addressType: city + locationType: city confidence: 95.5 - title: TextPhysicalAddressAnnotation + title: TextLocationAnnotation type: object - TextPhysicalAddressAnnotationResponse: - description: The response to a physical addresses annotation request + TextLocationAnnotationResponse: + description: The response to a locations annotation request example: - textPhysicalAddressAnnotations: + textLocationAnnotations: - start: 42 length: 7 text: Seattle - addressType: city + locationType: city confidence: 95.5 - start: 42 length: 7 text: Seattle - addressType: city + locationType: city confidence: 95.5 properties: - textPhysicalAddressAnnotations: - description: A list of physical address annotations + textLocationAnnotations: + description: A list of location annotations items: - $ref: '#/components/schemas/TextPhysicalAddressAnnotation' - title: textPhysicalAddressAnnotations + $ref: '#/components/schemas/TextLocationAnnotation' + title: textLocationAnnotations type: array required: - - textPhysicalAddressAnnotations - title: TextPhysicalAddressAnnotationResponse + - textLocationAnnotations + title: TextLocationAnnotationResponse type: object License: description: The license (license keyword used by GitHub) @@ -394,10 +394,18 @@ components: type: string ToolType: description: The type of this tool + enum: + - nlpsandbox:contact-annotator + - nlpsandbox:covid-symptom-annotator + - nlpsandbox:data-node + - nlpsandbox:date-annotator + - nlpsandbox:id-annotator + - nlpsandbox:person-name-annotator + - nlpsandbox:phi-annotator + - nlpsandbox:phi-deidentifier + - nlpsandbox:physical-address-annotator example: nlpsandbox:date-annotator - maxLength: 60 - minLength: 3 - pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$ + title: ToolType type: string Tool: description: Information about an NLP tool @@ -411,7 +419,7 @@ components: authorEmail: author@example.com url: https://example.com type: nlpsandbox:date-annotator - apiVersion: 1.1.2 + apiVersion: 1.2.0 properties: name: description: The tool name @@ -431,7 +439,7 @@ components: type: string description: description: A short, one-sentence summary of the tool - maxLength: 100 + maxLength: 280 type: string author: description: The author of the tool @@ -445,12 +453,7 @@ components: format: uri type: string type: - description: The type of this tool - example: nlpsandbox:date-annotator - maxLength: 60 - minLength: 3 - pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*(:)[a-z0-9]+(?:-[a-z0-9]+)*$ - type: string + $ref: '#/components/schemas/ToolType' apiVersion: description: The version of the tool OpenAPI specification minLength: 1 @@ -482,7 +485,7 @@ components: authorEmail: author@example.com url: https://example.com type: nlpsandbox:date-annotator - apiVersion: 1.1.2 + apiVersion: 1.2.0 - name: awesome-nlp-tool version: 1.0.6 license: apache-2.0 @@ -492,7 +495,7 @@ components: authorEmail: author@example.com url: https://example.com type: nlpsandbox:date-annotator - apiVersion: 1.1.2 + apiVersion: 1.2.0 properties: tools: description: A list of tools @@ -504,10 +507,10 @@ components: - tools title: ToolDependencies type: object - TextPhysicalAddressAnnotation_allOf: + TextLocationAnnotation_allOf: properties: - addressType: - description: Type of address information + locationType: + description: Type of location enum: - city - country @@ -521,5 +524,5 @@ components: - zip type: string required: - - addressType + - locationType type: object diff --git a/server/openapi_server/test/integration/__init__.py b/server/openapi_server/test/integration/__init__.py deleted file mode 100644 index 58f698a..0000000 --- a/server/openapi_server/test/integration/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -import logging - -import connexion -from flask_testing import TestCase - -from openapi_server.encoder import JSONEncoder - - -class BaseTestCase(TestCase): - - def create_app(self): - logging.getLogger('connexion.operation').setLevel('ERROR') - app = connexion.App(__name__, specification_dir='../../openapi/') - app.app.json_encoder = JSONEncoder - app.add_api('openapi.yaml', pythonic_params=True) - return app.app diff --git a/server/openapi_server/test/integration/test_health_check_controller.py b/server/openapi_server/test/integration/test_health_check_controller.py deleted file mode 100644 index da298b0..0000000 --- a/server/openapi_server/test/integration/test_health_check_controller.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -import unittest - -from openapi_server.test.integration import BaseTestCase - - -class TestHealthCheckController(BaseTestCase): - """HealthCheckController integration test stubs""" - - def test_get_health_check(self): - """Test case for get_health_check - - Get health check information - """ - headers = { - 'Accept': 'application/json', - } - response = self.client.open( - '/api/v1/healthCheck', - method='GET', - headers=headers) - self.assert200(response, - 'Response body is : ' + response.data.decode('utf-8')) - - -if __name__ == '__main__': - unittest.main() diff --git a/server/openapi_server/test/integration/test_text_physical_address_annotation_controller.py b/server/openapi_server/test/integration/test_text_physical_address_annotation_controller.py deleted file mode 100644 index dee28b3..0000000 --- a/server/openapi_server/test/integration/test_text_physical_address_annotation_controller.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -import unittest - -from flask import json - -from openapi_server.test.integration import BaseTestCase - - -class TestTextPhysicalAddressAnnotationController(BaseTestCase): - """TextPhysicalAddressAnnotationController integration test stubs""" - - def test_create_text_physical_address_annotations(self): - """Test case for create_text_physical_address_annotations - - Annotate physical addresses in a clinical note - """ - text_physical_address_annotation_request = { - "note": { - "identifier": "awesome-note", - "type": "loinc:LP29684-5", - "patientId": "awesome-patient", - "text": "On 12/26/2020, Ms. Chloe Price met with Dr. Prescott in Seattle." # noqa: E501 - } - } - headers = { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - } - response = self.client.open( - '/api/v1/textPhysicalAddressAnnotations', - method='POST', - headers=headers, - data=json.dumps(text_physical_address_annotation_request), - content_type='application/json') - self.assert200(response, - 'Response body is : ' + response.data.decode('utf-8')) - - -if __name__ == '__main__': - unittest.main() diff --git a/server/openapi_server/test/integration/test_tool_controller.py b/server/openapi_server/test/integration/test_tool_controller.py deleted file mode 100644 index 78b7dbe..0000000 --- a/server/openapi_server/test/integration/test_tool_controller.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding: utf-8 - -from __future__ import absolute_import -import unittest - -from openapi_server.test.integration import BaseTestCase - - -class TestToolController(BaseTestCase): - """ToolController integration test stubs""" - - def test_get_tool(self): - """Test case for get_tool - - Get tool information - """ - headers = { - 'Accept': 'application/json', - } - response = self.client.open( - '/api/v1/tool', - method='GET', - headers=headers) - self.assert200(response, - 'Response body is : ' + response.data.decode('utf-8')) - - def test_get_tool_dependencies(self): - """Test case for get_tool_dependencies - - Get tool dependencies - """ - headers = { - 'Accept': 'application/json', - } - response = self.client.open( - '/api/v1/tool/dependencies', - method='GET', - headers=headers) - self.assert200(response, - 'Response body is : ' + response.data.decode('utf-8')) - - -if __name__ == '__main__': - unittest.main() diff --git a/server/openapi_server/test/test_text_physical_address_annotation_controller.py b/server/openapi_server/test/test_text_location_annotation_controller.py similarity index 53% rename from server/openapi_server/test/test_text_physical_address_annotation_controller.py rename to server/openapi_server/test/test_text_location_annotation_controller.py index a111741..b57cdfd 100644 --- a/server/openapi_server/test/test_text_physical_address_annotation_controller.py +++ b/server/openapi_server/test/test_text_location_annotation_controller.py @@ -7,20 +7,20 @@ from six import BytesIO from openapi_server.models.error import Error # noqa: E501 -from openapi_server.models.text_physical_address_annotation_request import TextPhysicalAddressAnnotationRequest # noqa: E501 -from openapi_server.models.text_physical_address_annotation_response import TextPhysicalAddressAnnotationResponse # noqa: E501 +from openapi_server.models.text_location_annotation_request import TextLocationAnnotationRequest # noqa: E501 +from openapi_server.models.text_location_annotation_response import TextLocationAnnotationResponse # noqa: E501 from openapi_server.test import BaseTestCase -class TestTextPhysicalAddressAnnotationController(BaseTestCase): - """TextPhysicalAddressAnnotationController integration test stubs""" +class TestTextLocationAnnotationController(BaseTestCase): + """TextLocationAnnotationController integration test stubs""" - def test_create_text_physical_address_annotations(self): - """Test case for create_text_physical_address_annotations + def test_create_text_location_annotations(self): + """Test case for create_text_location_annotations - Annotate physical addresses in a clinical note + Annotate locations in a clinical note """ - text_physical_address_annotation_request = { + text_location_annotation_request = { "note" : { "identifier" : "awesome-note", "text" : "On 12/26/2020, Ms. Chloe Price met with Dr. Prescott in Seattle.", @@ -33,10 +33,10 @@ def test_create_text_physical_address_annotations(self): 'Content-Type': 'application/json', } response = self.client.open( - '/api/v1/textPhysicalAddressAnnotations', + '/api/v1/textLocationAnnotations', method='POST', headers=headers, - data=json.dumps(text_physical_address_annotation_request), + data=json.dumps(text_location_annotation_request), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))