<gh_stars>0
# AUTOGENERATED! DO NOT EDIT! File to edit: 50_web_app.ipynb (unless otherwise specified).

__all__ = ['get_single_patient_medication_bundle', 'create_app']

# Cell
from ..core import *
from ..per_patient import *
from ..status_filter import *
from flask import Flask, g, request
from werkzeug.exceptions import abort
from pathlib import Path
import os

# Cell
def get_single_patient_medication_bundle(api_base, subject):
    bundle = create_single_patient_medication_bundle(api_base, subject)
    bundle = handle_entry_search(bundle)
#     bundle = filter_bundle(bundle, medication_status_filter)
#     bundle = filter_bundle(bundle, do_not_perform_filter)
    return bundle

# Cell
def create_app(test_config=None):
    "Create and configure an instance of the Flask application."
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        # a default secret that should be overridden by instance config
        SECRET_KEY="dev",
        DATA_DIR=app.instance_path # used by filesystem and DB service
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile("config.py", silent=True)
    else:
        # load the test config if passed in
        app.config.update(test_config)

    # ensure the instance folder exists
    os.makedirs(app.config['DATA_DIR'], exist_ok=True)

    @app.route("/hello")
    def hello(): return "Hello, World!"

    @app.route("/single_patient_medication_bundle")
    def _get_single_patient_medication_bundle():
        args = [request.args.get(p) for p in ['api_base', 'subject'] if request.args.get(p) is not None]
        if len(args) != 2:
            abort(400, 'Missing URL parameter: api_base and subject are required')
        return get_single_patient_medication_bundle(*args)

    @app.route("/status_filter", methods=['POST'])
    def _status_filter():
        return get_negated_list(request.json)

    from . import demo
    # apply the blueprints to the app
    app.register_blueprint(demo.bp)

    app.add_url_rule("/", endpoint="index")

    return app
# AUTOGENERATED! DO NOT EDIT! File to edit: 50_web_app.ipynb (unless otherwise specified).

__all__ = ['get_single_patient_medication_bundle', 'create_app']

# Cell
from ..core import *
from ..per_patient import *
from ..status_filter import *
from flask import Flask, g, request
from werkzeug.exceptions import abort
from pathlib import Path
import os

# Cell
def get_single_patient_medication_bundle(api_base, subject):
    bundle = create_single_patient_medication_bundle(api_base, subject)
    bundle = handle_entry_search(bundle)
#     bundle = filter_bundle(bundle, medication_status_filter)
#     bundle = filter_bundle(bundle, do_not_perform_filter)
    return bundle

# Cell
def create_app(test_config=None):
    "Create and configure an instance of the Flask application."
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        # a default secret that should be overridden by instance config
        SECRET_KEY="dev",
        DATA_DIR=app.instance_path # used by filesystem and DB service
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile("config.py", silent=True)
    else:
        # load the test config if passed in
        app.config.update(test_config)

    # ensure the instance folder exists
    os.makedirs(app.config['DATA_DIR'], exist_ok=True)

    @app.route("/hello")
    def hello(): return "Hello, World!"

    @app.route("/single_patient_medication_bundle")
    def _get_single_patient_medication_bundle():
        args = [request.args.get(p) for p in ['api_base', 'subject'] if request.args.get(p) is not None]
        if len(args) != 2:
            abort(400, 'Missing URL parameter: api_base and subject are required')
        return get_single_patient_medication_bundle(*args)

    @app.route("/status_filter", methods=['POST'])
    def _status_filter():
        return get_negated_list(request.json)

    from . import demo
    # apply the blueprints to the app
    app.register_blueprint(demo.bp)

    app.add_url_rule("/", endpoint="index")

    return app
# AUTOGENERATED! DO NOT EDIT! File to edit: 50_web_app.ipynb (unless otherwise specified). # Cell # Cell #     bundle = filter_bundle(bundle, medication_status_filter) #     bundle = filter_bundle(bundle, do_not_perform_filter) # Cell # a default secret that should be overridden by instance config # used by filesystem and DB service # load the instance config, if it exists, when not testing # load the test config if passed in # ensure the instance folder exists # apply the blueprints to the app