Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing url note ids #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clarkproc/clarkproc/blueprint_fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
from functools import wraps
import logging
from urllib.parse import unquote

from flask import Blueprint, jsonify, request

Expand Down Expand Up @@ -372,7 +373,7 @@ def get_patient_details(state, patient_id, detail_type, *args, **kwargs):
return jsonify(d)


@bp_fhir.route('/patient/<string:patient_id>/note/<string:note_id>', methods=['GET'])
@bp_fhir.route('/patient/<string:patient_id>/note/<path:note_id>', methods=['GET'])
@require_fhir
def get_patient_note(state, patient_id, note_id, *args, **kwargs):
"""
Expand Down Expand Up @@ -424,7 +425,8 @@ def get_patient_note(state, patient_id, note_id, *args, **kwargs):
{'Content-Type': 'text/plain'}
)

n = p.notes.get(note_id)
decoded_note_id = unquote(note_id)
n = p.notes.get(decoded_note_id)

if n is None:
return (
Expand Down
12 changes: 0 additions & 12 deletions clarkproc/clarkproc/server_app.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
"""Entry file for python server."""
import logging
import os
import sys

from appdirs import user_data_dir
from flask import request
import werkzeug

from clarkproc import state
from clarkproc.server_setup import app


APPDIR = user_data_dir('clark', appauthor=False, roaming=True)
if not os.path.exists(APPDIR):
os.makedirs(APPDIR)
logging.basicConfig(
filename=os.path.join(APPDIR, 'clark-server.log'),
format="[%(asctime)s: %(levelname)s/%(name)s(%(processName)s)]: %(message)s",
level=logging.DEBUG,
)

LOGGER = logging.getLogger(__name__)


Expand Down
13 changes: 13 additions & 0 deletions clarkproc/clarkproc/server_setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
"""Clark server setup."""
from flask import Flask
from flasgger import Swagger
from appdirs import user_data_dir
import os
import logging
# from flask_cors import CORS

from clarkproc.blueprint_fhir import TEST_DATA_INDICATOR, bp_fhir
from clarkproc.blueprint_ml import bp_ml

APPDIR = user_data_dir('clark', appauthor=False, roaming=True)
if not os.path.exists(APPDIR):
os.makedirs(APPDIR)
logging.basicConfig(
filename=os.path.join(APPDIR, 'clark-server.log'),
format="[%(asctime)s: %(levelname)s/%(name)s(%(processName)s)]: %(message)s",
level=logging.DEBUG,
)

app = Flask("clark_server")
app.register_blueprint(bp_fhir, url_prefix='/fhir')
app.register_blueprint(bp_fhir, url_prefix='/test',
Expand Down
3 changes: 2 additions & 1 deletion ui/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const API = {
});
}),
getPatientNote: (patientId, noteId, type) => new Promise((resolve, reject) => {
axios.get(url(`${type}/patient/${patientId}/note/${noteId}`))
const encodedNoteId = encodeURIComponent(noteId);
axios.get(url(`${type}/patient/${patientId}/note/${encodedNoteId}`))
.then((res) => {
resolve(res.data);
})
Expand Down