FHIR field for Plone
Project description
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.
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 = FhirResource( title=u'your title', desciption=u'your desciption', 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 fhirclient model with additional methods and attributes.
Features
Plone restapi support
Widget: z3cform support
plone.supermodel support
plone.rfc822 marshaler field support
elasticsearch based catalog search
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.
- 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’)
- model_interface
Required: No
Default: None
Type: String + full python path (dotted) of the model class.
Unlike model option, this option has more versatile goal although you can use it for single resource restriction. The advanced usecase like, the field could accept muiltiple resources types those model class implements the provided interface. For example you made a interface called IMedicalService and (Organization, Patient, Practitioner) models those are implementing IMedicalService. So when you provides this option value, actually three types of fhir json can now be accepted by this field. Example: FhirResource(….,model=’plone.app.interfaces.IFhirResourceModel’)
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::as_json
Originally this method is derived from fhirclient 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)
Helper API
This package provides some useful functions those could be usable in your codebase.
resource_type_str_to_fhir_model
This function return appropriate fhirclient model class based on provided resource type. On wrong resource type zope.interface.Invalid exception is raisen.
Example:
>>> from plone.app.fhirfield.helpers import resource_type_str_to_fhir_model >>> task_model_class = resource_type_str_to_fhir_model('Task')
Available Catalog PluginIndexes
Bellows are fhirfield based catalog indexes are available.
- FhirActivityDefinitionIndex
Resource Type: ActivityDefinition
Has Mapping: yes
- FhirAppointmentIndex
Resource Type: Appointment
Has Mapping: yes
- FhirCarePlanIndex
Resource Type: CarePlan
Has Mapping: yes
- FhirDeviceIndex
Resource Type: Device
Has Mapping: yes
- FhirDeviceRequestIndex
Resource Type: DeviceRequest
Has Mapping: yes
- FhirHealthcareServiceIndex
Resource Type: HealthcareService
Has Mapping: yes
- FhirMedicationAdministrationIndex
Resource Type: MedicationAdministration
Has Mapping: yes
- FhirMedicationDispenseIndex
Resource Type: MedicationDispense
Has Mapping: yes
- FhirMedicationRequestIndex
Resource Type: MedicationRequest
Has Mapping: yes
- FhirMedicationStatementIndex
Resource Type: MedicationStatement
Has Mapping: yes
- FhirObservationIndex
Resource Type: Observation
Has Mapping: yes
- FhirOrganizationIndex
Resource Type: Organization
Has Mapping: yes
- FhirPatientIndex
Resource Type: Patient
Has Mapping: yes
- FhirPlanDefinitionIndex
Resource Type: PlanDefinition
Has Mapping: yes
- FhirPractitionerIndex
Resource Type: Practitioner
Has Mapping: yes
- FhirProcedureRequestIndex
Resource Type: ProcedureRequest
Has Mapping: yes
- FhirQuestionnaireIndex
Resource Type: Questionnaire
Has Mapping: yes
- FhirQuestionnaireResponseIndex
Resource Type: QuestionnaireResponse
Has Mapping: yes
- FhirRelatedPersonIndex
Resource Type: RelatedPerson
Has Mapping: yes
- FhirTaskIndex
Resource Type: Task
Has Mapping: yes
- FhirValueSetIndex
Resource Type: ValueSet
Has Mapping: yes
- FhirFieldIndex:
Resource Type: any valid fhir resource
Has Mapping: minimal (id, identifier, meta)
Example usages:
<?xml version="1.0"?> <object name="portal_catalog" meta_type="Plone Catalog Tool"> <index name="organization_resource" meta_type="FhirOrganizationIndex"> <indexed_attr value="organization_resource"/> </index> </object>
elasticsearch setup
If your intent to use elasticsearch based indexing and query, this section for you! you can find more details here
server setup
server version is restricted to 2.4.x, means we cannot use latest version of elasticsearch. i.e 5.6.x
Download from here and install according to documentation.
For development you could use docker container. The Makefile is available, ~$ make run-es
collective.elasticsearch setup
Full configuration guide could be found here. Simple steps are described bellow.
create catalog/indexes: First you will need add indexes for each fhirfield used in your project. each resource type has it’s own Meta Index. example is here
Install collective.elasticsearch addon from plone control panel.
Convert your Indexes to elasticsearch. Go To {portal url}/@@elastic-controlpanel
In the settings form’s Indexes for which all searches are done through ElasticSearch section add your all indexes those you mentioned into catalog.xml file, also add portal_type
Now save and again Convert Catalog.
Installation
Install plone.app.fhirfield by adding it to your buildout:
[buildout] ... eggs = plone.app.fhirfield [elasticsearch]
and then running bin/buildout
Links
Code repository:
Continuous Integration:
Issue Tracker:
License
The project is licensed under the GPLv2.
Contributors
Md Nazrul Islam (Author), email2nazrul@gmail.com
Changelog
1.0.0b4 (2018-08-01)
Must Update (fix): Important updates made on mapping, reference field mapping was not working if value contains with /, now made it tokenize by indecating index is not_analyzed
_profile search parameter is now available. [nazrulworld]
1.0.0b3 (2018-07-30)
Mapping improvment for FhirQuestionnaireResponseIndex, FhirObservationIndex, FhirProcedureRequestIndex, FhirTaskIndex, FhirDeviceRequestIndex
1.0.0b2 (2018-07-29)
New Features:
supports for elasticsearch has been added. Now many basic fhir search are possible to be queried.
upto 22 FHIR fields indexes (FhirActivityDefinitionIndex, FhirAppointmentIndex, FhirCarePlanIndex, FhirDeviceIndex, FhirDeviceRequestIndex, FhirHealthcareServiceIndex, FhirMedicationAdministrationIndex, FhirMedicationDispenseIndex, FhirMedicationRequestIndex, FhirMedicationStatementIndex, FhirObservationIndex, FhirOrganizationIndex, FhirPatientIndex, FhirPlanDefinitionIndex, FhirPractitionerIndex, FhirProcedureRequestIndex, FhirQuestionnaireIndex, FhirQuestionnaireResponseIndex, FhirRelatedPersonIndex, FhirTaskIndex, FhirValueSetIndex)
Mappings for all available fhir indexes are created.
elasticsearch option is now available for setup.py
1.0.0b1 (2018-03-17)
first beta version has been released.
1.0.0a10 (2018-03-12)
fix(bug) Issue-3: resource_type constraint don’t raise exception from validator.
1.0.0a9 (2018-03-08)
There is no restriction/limit over fhir resources, all available models are supported.
1.0.0a8 (2018-01-22)
fix(bug) Issue-: Empty string value raise json validation error #2:https://github.com/nazrulworld/plone.app.fhirfield/issues/2
1.0.0a7 (2018-01-21)
fix(bug) Issue-1: _RuntimeError: maximum recursion depth exceeded while calling a Python object at form view. #1:https://github.com/nazrulworld/plone.app.fhirfield/issues/1
1.0.0a6 (2018-01-14)
missing HealthcareService fhir model is added as supported model.
1.0.0a5 (2018-01-14)
Person fhir model added in whitelist.
1.0.0a4 (2018-01-14)
IFhirResource.model_interface field type changed to DottedName from InterfaceField.
1.0.0a3 (2017-12-22)
FHIR Patch support added. Now patching fhir resource is more easy to manage.
plone.supermodel support is confirmed.[nazrulworld]
plone.rfc822 marshaler field support.[nazrulworld]
1.0.0a2 (2017-12-10)
FhirResourceWidget is made working state. From now it is possible to adapt FhirResourceWidget` with z3c.form [nazrulworld]
1.0.0a1 (2017-12-05)
Initial release. [nazrulworld]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for plone.app.fhirfield-1.0.0b4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2957cf16a2b491efb26d5416e311121871e2e643601e2f4c5444bd0e1078767f |
|
MD5 | 22a8e9d434359fd3c70ef339d4159650 |
|
BLAKE2b-256 | f5d968ea2c766b323c10f679cefaa28ce1e53b24d1254d0fdfc4a36184097bc4 |