Skip to content

Commit

Permalink
Docs: quickstart and readme badges
Browse files Browse the repository at this point in the history
  • Loading branch information
zensoup committed Dec 21, 2018
1 parent 722c1d9 commit 03b2394
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FHIRBUG
--------
.. image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=plastic
:target: https://fhirbug.readthedocs.io
:alt: Documentation
.. image:: https://img.shields.io/badge/python-3.6%20%7C%203.7-blue.svg

Fhirbug intends to be a full-featured `FHIR`_ server for python >= **3.6**. It has been
designed to be easy to set up and configure and be flexible when it comes to
Expand Down
86 changes: 85 additions & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,93 @@ Let's start by asking for all Patient entries:

>>> from fhirbug.server.requestparser import parse_url
>>> query = parse_url('Patient')
>>> Patient.get(query)
>>> Patient.get(query, strict=False)
{
"entry": [
{
"resource": {
"birthDate": "1990-10-10T00:00:00",
"name": [{"family": "Guy", "given": ["Some"]}],
"resourceType": "Patient",
}
},
{
"resource": {
"birthDate": "1993-12-18T00:00:00",
"name": [{"family": "Else", "given": ["Someone"]}],
"resourceType": "Patient",
}
},
{
"resource": {
"birthDate": "1985-06-06T00:00:00",
"name": [{"family": "Me", "given": ["Not"]}],
"resourceType": "Patient",
}
},
],
"resourceType": "Bundle",
"total": 3,
"type": "searchset",
}

We get a proper Bundle_ Resource containing all of our Patient records!

Advanced Queries
----------------
This quick guide is almost over, but before that let us see some more things Fhirbug can do. We start by asking only one result per page.

>>> query = parse_url('Patient?_count=1')
>>> Patient.get(query, strict=False)
{
"entry": [
{
"resource": {
"birthDate": "1990-10-10T00:00:00",
"name": [{"family": "Guy", "given": ["Some"]}],
"resourceType": "Patient",
}
}
],
"link": [
{"relation": "next", "url": "Patient/?_count=1&search-offset=2"},
{"relation": "previous", "url": "Patient/?_count=1&search-offset=1"},
],
"resourceType": "Bundle",
"total": 4,
"type": "searchset",
}

Notice how when defining our mappings we declared ``birthDate`` as a
:class:`DateAttribute` and name as a :class:`NameAttribute`? This allows us to
use several automations that Fhirbug provides like advanced searches:

>>> query = parse_url('Patient?birthDate=gt1990&given:contains=one')
>>> Patient.get(query, strict=False)
{
"entry": [
{
"resource": {
"birthDate": "1993-12-18T00:00:00",
"name": [{"family": "Else", "given": ["Someone"]}],
"resourceType": "Patient",
}
}
],
"resourceType": "Bundle",
"total": 1,
"type": "searchset",
}

Here, we ask for all ``Patients`` that were born after 1990-01-01 and whose given
name contains ``one``.

Further Reading
---------------
You can dive into the actual documentation starting at the :ref:`Overview` or
read the docs for the :ref:`Api`.

.. _sqlite3: https://docs.python.org/3/library/sqlite3.html
.. _Patient: https://www.hl7.org/fhir/patient.html
.. _Encounter: https://www.hl7.org/fhir/encounter.html
.. _Bundle: https://www.hl7.org/fhir/bundle.html

0 comments on commit 03b2394

Please sign in to comment.