Skip to content

Commit

Permalink
[ExposuresProvider#21] add reasoner overlay api
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-hao committed Jun 15, 2020
1 parent 48cedb3 commit f8da62f
Show file tree
Hide file tree
Showing 8 changed files with 3,559 additions and 41 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
venv/
__pycache__/
.vscode/
.DS_Store
.DS_Store
**/*~
.idea
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.5

RUN pip install flask flask-restful flask-limiter sqlalchemy psycopg2-binary scipy gunicorn==19.10.0 jsonschema pyyaml tabulate structlog pandas==0.25.3 argparse inflection flasgger simplejson
RUN pip install flask flask-restful flask-limiter sqlalchemy psycopg2-binary scipy gunicorn==19.10.0 jsonschema pyyaml tabulate structlog pandas==0.25.3 argparse inflection flasgger simplejson tx-functional
RUN mkdir icees-api
COPY ./app.py /icees-api/app.py
COPY ./db.py /icees-api/db.py
Expand Down
35 changes: 35 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,40 @@ def get(self):
return wrapped(return_value)


class SERVKnowledgeGraphOverlay(Resource):
def post(self):
"""
Query the ICEES clinical reasoner for knowledge graph co-occurrence overlay.
---
definitions:
import: "TranslatorReasonersAPI.yaml"
parameters:
- in: body
name: body
description: Input message
required: true
schema:
$ref: '#/definitions/Query'
responses:
200:
description: Success
schema:
$ref: '#/definitions/Message'
"""
try:
obj = request.get_json()
# validate(obj, schema.add_name_by_id_schema())
with db.DBConnection() as conn:
return_value = knowledgegraph.co_occurrence_overlay(conn, obj)
except ValidationError as e:
traceback.print_exc()
return_value = e.message
except Exception as e:
traceback.print_exc()
return_value = str(e)
return wrapped(return_value)


api.add_resource(SERVCohort, '/<string:table>/<int:year>/cohort')
api.add_resource(SERVCohortId, '/<string:table>/<int:year>/cohort/<string:cohort_id>')
api.add_resource(SERVFeatures, '/<string:table>/<int:year>/cohort/<string:cohort_id>/features')
Expand All @@ -778,6 +812,7 @@ def get(self):
api.add_resource(SERVName, "/<string:table>/name/<string:name>")
api.add_resource(SERVKnowledgeGraph, "/knowledge_graph")
api.add_resource(SERVKnowledgeGraphSchema, "/knowledge_graph/schema")
api.add_resource(SERVKnowledgeGraphOverlay, "/knowledge_graph_overlay")

if __name__ == '__main__':
app.run()
Loading

0 comments on commit f8da62f

Please sign in to comment.