Giter Club home page Giter Club logo

plone.app.fhirfield's Introduction

Egg Status

Travis Build Status

Test Coverage

Python Versions

Latest Version

License

image

Background (plone.app.fhirfield)

FHIR (Fast Healthcare Interoperability Resources) is the industry standard for Healthcare system. Our intend to implement FHIR based system using Plone! plone.app.fhirfield will make life easier to create, manage content for FHIR resources as well search facilities for any FHIR Resources.

How It Works

This field is working as like other zope.schema field, just add and use it. You will feed the field value as either json string or python dict of FHIR resources through web form or any restapi client. This field has built-in FHIR resource validator and parser.

Example:

from plone.app.fhirfield import FhirResource
from plone.supermodel import model

class IMyContent(model.Schema):

    <resource_type>_resource = FhirResource(
        title=u'your title',
        desciption=u'your desciption',
        fhir_release='any of FHIR release name'
        resource_type='any fhir resource type[optional]'
    )

The field's value is the instance of a specilized class FhirResourceValue inside the context, which is kind of proxy class of fhir model with additional methods and attributes.

Features

  • Plone restapi support
  • Widget: z3cform support
  • plone.supermodel support
  • plone.rfc822 marshaler field support

Available Field's Options

This field has got all standard options (i.e title, required, desciption and so on) with additionally options for the purpose of either validation or constraint those are related to FHIR.

fhir_release

Required: Yes

Default: None

Type: String

The release version of FHIR

Example: R4, STU3

resource_type

Required: No

Default: None

Type: String

The name of FHIR resource can be used as constraint, meaning that we can restricted only accept certain resource. If FHIR json is provided that contains other resource type, would raise validation error. Example: FhirResource(....,resource_type='Patient')

model

Required: No

Default: None

Type: String + full python path (dotted) of the model class.

Like resource_type option, it can be used as constraint, however additionally this option enable us to use custom model class other than fhirclient's model. Example: FhirResource(....,model='fhirclient.models.patient.Patient')

index_mapping

Required: No

Default: None

Type: JSON

The custom index mapping, best case is elasticsearch mapping. Default mapping would be replaced by custom.

Field's Value API

Field's value is a specilized class plone.app.fhirfield.value.FhirResourceValue which has reponsibilty to act as proxy of fhirclient model's class. This class provides some powerful methods.

FhirResourceValue::json

Originally this method is derived from fhir base model, you will always have to use this method during negotiation (although our serializer doing that for you automatically). This method not takes any argument, it returns FHIR json representation of resource.

FhirResourceValue::patch

If you are familar with FHIRPath Patch, this method one of the strongest weapon of this class. Patch applying on any FHIR resources is noting but so easy. This method takes one mandatory argument patch_data and that value should be list of patch items (jsonpatch).

Example:

from plone.app.fhirfield import FhirResource
from plone.supermodel import model

class ITask(model.Schema):

    resource = FhirResource(
        title=u'your title',
        desciption=u'your desciption',
        resource_type='Task'
    )

patch_data = [
  {'op': 'replace', 'path': '/source/display', 'value': 'Patched display'},
  {'op': 'replace', 'path': '/status', 'value': 'Reopen'}
]
task_content.resource.patch(patch_data)

FhirResourceValue::stringify

This method returns string representation of fhir resource json value. Normally as_json returns python's dict type data. This method takes optional prettify argument, by setting this argument True, method will return human/print friendly representation.

FhirResourceValue::foreground_origin

There may some situation come, where you will need just pure instance of fhir model, this method serves that purpose. This method returns current fhir resource model's instance.

Example:

from fhirclient.models.task import Task
from plone.app.fhirfield import FhirResource
from plone.supermodel import model

class ITask(model.Schema):

    resource = FhirResource(
        title=u'your title',
        desciption=u'your desciption',
        resource_type='Task'
    )

task = task_content.resource.foreground_origin()
assert isinstance(task, Task)

Installation

Install plone.app.fhirfield by adding it to your buildout:

[buildout]

...

eggs =
    plone.app.fhirfield

and then running bin/buildout. Go to plone control and install plone.app.fhirfield or If you are creating an addon that depends on this product, you may add <dependency>profile-plone.app.fhirfield:default</dependency> in metadata.xml at profiles.

Links

Code repository:

https://github.com/nazrulworld/plone.app.fhirfield

Continuous Integration:

https://travis-ci.org/nazrulworld/plone.app.fhirfield

Issue Tracker:

https://github.com/nazrulworld/plone.app.fhirfield/issues

License

The project is licensed under the GPLv2.

plone.app.fhirfield's People

Contributors

nazrulworld avatar

Stargazers

 avatar

Watchers

 avatar  avatar

plone.app.fhirfield's Issues

RuntimeError: maximum recursion depth exceeded while calling a Python object at form view.

During pickling by zope this error is appeared.

Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
Module plone.app.fhirfield.value, line 124, in getattr
RuntimeError: maximum recursion depth exceeded while calling a Python object

Can not add a default value for fhirfield

Hi,
I have tried this in updateWidgets
self.widgets["fhir_json"].mode = HIDDEN_MODE
self.widgets["fhir_json"].value = FhirResourceValue(None)

but when the form is loading it gives error here:
buildout-cache/eggs/zope.traversing-4.4.1-py3.7.egg/zope/traversing/adapters.py(61)traverse()
-> raise LocationError(subject, name)
whereas subject is : <plone.app.fhirfield.value.FhirResourceValue object represents object of NoneType at 0x7f7be4b73790>
and name is: stringfy

Maybe I am setting default value in wrong way, can you please let me know the currect way for seting None for a fhirfield?
BTW if I just do like this

self.widgets["fhir_json"].mode = HIDDEN_MODE
without setting the value it also gives same error so problem is when it is hidden mode.. maybe need a widget template for hidden mode.

FhirIndexes file generator

Background

We have FhirIndexes as PluginIndex python modules FHIRIndex.py and Elasticsearch FhirIndex. If you close look at those files, most of all classes are same just name of the class and some other attributes has different. Beside there so many FHIR resources are available and handling all could be so tough!

Propose

  1. we have script folder, dedicated to making tools. There could be the right place to make a generator that will make fhir.py and FHIRIndex.py input from manages json file.

Add support for `code` DataType search

"code":[
            "token",
            [
                "CompartmentDefinition.code",
                "DeviceRequest.code.as(CodeableConcept)",
                "Questionnaire.item.code",
                "FamilyMemberHistory.condition.code",
                "Substance.code",
                "MedicationAdministration.medication.as(CodeableConcept)",
                "Substance.ingredient.substance.as(CodeableConcept)",
                "Group.code",
                "DataElement.element.code",
                "OperationDefinition.code",
                "Condition.code",
                "Observation.code",
                "Medication.code",
                "AllergyIntolerance.code",
                "MedicationDispense.medication.as(CodeableConcept)",
                "Procedure.code",
                "AllergyIntolerance.reaction.substance",
                "BodySite.code",
                "MessageHeader.response.code",
                "SearchParameter.code",
                "Basic.code",
                "Task.code",
                "ProcedureRequest.code",
                "ChargeItem.code",
                "List.code",
                "CodeSystem.concept.code",
                "MedicationStatement.medication.as(CodeableConcept)",
                "DiagnosticReport.code",
                "MedicationRequest.medication.as(CodeableConcept)"
            ]
        ]

FhirFieldIndex stores whole FHIR resources json as indexed value

Background

Since FHIR resources indexing, mapping are handled by Elasticsearh through collective.elasticsearch but a copy of zope version of indexed value also stored by zope it-self , in that case there is no mapping applied here, instead whole string. This could cause make indexes size this is unnecessary. For example Media and Attachment resource contains binary data that could be more that 5MB.

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.