Coder Social home page Coder Social logo

fhirpath_guillotina's Introduction

Introduction

image

image

Documentation Status

Test Coverage

A guillotina framework powered fhirpath provider. Full battery included to use fhirpath more efficiently.

If you don't know about FHIR® and HL7®, Please have a look here.

Quickstart

  1. Make sure fhirpath_guillotina is added as addon in your guillotina configure file.
  2. Make sure elasticsearch server configured properly.
  3. Make sure you have FHIR resource contenttypes registered (see example bellow).
  4. Make sure you have FHIR resources mapping (correct version) for elasticsearch.

Example: Add Contents:

>>> from fhirpath_guillotina.field import FhirField

class IOrganization(IFhirContent, IContentIndex):
    index_field(
        "organization_resource",
        type="object",
        field_mapping=fhir_resource_mapping("Organization"),
        fhirpath_enabled=True,
        resource_type="Organization",
        fhir_release=FHIR_VERSION.R4,
    )
    index_field("org_type", type="keyword")
    org_type = TextLine(title="Organization Type", required=False)
    organization_resource = FhirField(
        title="Organization Resource", resource_type="Organization", fhir_release="R4"
    )


@configure.contenttype(type_name="Organization", schema=IOrganization)
class Organization(Folder):
    """ """

    index(schemas=[IOrganization], settings={})
    resource_type = "Organization"

Example Search:

>>> from guillotina.component import query_utility
>>> from fhirpath.interfaces import ISearchContextFactory
>>> from fhirpath.interfaces import IFhirSearch
>>> search_context = query_utility(ISearchContextFactory).get(
...    resource_type="Organization"
... )
>>> search_tool = query_utility(IFhirSearch)
>>> params = (
...     ("active", "true"),
...     ("_lastUpdated", "2010-05-28T05:35:56+00:00"),
...     ("_profile", "http://hl7.org/fhir/Organization"),
...     ("identifier", "urn:oid:2.16.528.1|91654"),
...     ("type", "http://hl7.org/fhir/organization-type|prov"),
...     ("address-postalcode", "9100 AA")
... )
>>> fhir_bundle = await search_tool(params, context=search_context)
>>> fhir_bundle.total == len(fhir_bundle.entry)

Example FhirPath Query:

>>> from fhirpath.interfaces import IElasticsearchEngineFactory
>>> from guillotina.component import query_utility
>>> from fhirpath.enums import SortOrderType
>>> from fhirpath.fql import Q_
>>> from fhirpath.fql import T_
>>> from fhirpath.fql import V_
>>> from fhirpath.fql import sort_
>>> engine = query_utility(IElasticsearchEngineFactory).get()
>>> query_builder = Q_(resource="Organization", engine=engine)
>>> query_builder = (
...        query_builder.where(T_("Organization.active") == V_("true"))
...        .where(T_("Organization.meta.lastUpdated", "2010-05-28T05:35:56+00:00"))
...        .sort(sort_("Organization.meta.lastUpdated", SortOrderType.DESC))
...        .limit(20)
...    )
>>> query_result = query_builder(async_result=True)
>>> result = query_result.fetchall()
>>> result.header.total == 100
True
>>> len(result.body) == 20
True
>>> async for resource in query_result:
...     assert resource.resource_type == "Organization"

Credits

This package skeleton was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

fhirpath_guillotina's People

Contributors

nazrulworld avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.