{
"info": {
"author": "Lucas Weyne",
"author_email": "weynelucas@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Healthcare Industry",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing",
"Topic :: Text Processing :: Markup :: XML"
],
"description": "[](https://pypi.python.org/pypi/python-xml-hl7) [](https://travis-ci.org/weynelucas/python-xml-hl7) [](https://codecov.io/gh/weynelucas/python-xml-hl7)\n\n# python-xml-hl7\nA library for parsing HL7 (version 2.x) messages in XML format into Python objects\n\n\n## Instalation\n\nYou can install this library using pip:\n```\npip install python-xml-hl7\n```\n\nor from the git repository:\n```\ngit clone https://github.com/weynelucas/python-xml-hl7.git\ncd python-xml-hl7\npython setup.py install\n```\n\n## Quickstart\n\nAs an example, let\u2019s create a HL7 message:\n\n```python\nmessage = \"\"\"\n\n|^~\\\\&hospital20180703111743ORUR012.3.1\nshenzhen1libang20091010M\nUadult20180726181346\n20180703111743\nNMSPO296%90-100\nNMPR68bpm50-120\nNMSYS131mmHg90-16020180703111713\nNMDIA85mmHg50-9020180703111713\nNMMAP100mmHg60-11020180703111713\nNMNIBP_PR73bpm50-12020180703111713\n\n\"\"\"\n```\n\nCall `hl7.xml.parse()` command to convert the string message\n\n```python\nfrom hl7.xml import parse\n\nh = parse(message)\n```\n\nThis command returns a `Message` instance, wrapping a series of `Segment` objects. Is possible iterate over segments or match for specific ones:\n\n```python\n>>> list(h) # List all message segments\n[,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ]\n\n>>> h[0] # Get 1st message segment\n\n\n>>> h['OBX'] # Find all OBX segments\n[,\n ,\n ,\n ,\n ,\n ]\n```\n\nA `Segment` instance wraps a serie of `Field` objects, you can iterate over them:\n\n```python\n>>> list(h[2]) # List all fields for 3rd message segment (PV1)\n[,\n ,\n ]\n\n>>> list(h[5]) # List all fields for 6th message segment (OBX)\n[,\n ,\n ,\n ,\n ]\n\n>>> h[5][0].value\n'NM'\n\n>>> h[5][2].value\n'62'\n```\n\nThere are different types of `Segment`, they are: `MSH`, `PID`, `PV1`, `OBR` and `OBX`. Each of them has helper methods to retrieve data from its respective HL7 segment without iterate over his `Field` objects\n\n#### MSH\n\n```python\n>>> msh = h['MSH'][0]\n>>> (msh.field_separator,\n msh.encoding_chars,\n msh.sending_application,\n msh.datetime,\n msh.version,\n msh.message_type)\n('|', '^~\\\\&', 'hospital', datetime.datetime(2018, 7, 3, 11, 17, 43), '2.3.1', ('ORU', 'R01'))\n```\n\n#### PID\n``` python\n>>> pid = h['PID'][0]\n>>> (pid.id,\n pid.id_list,\n pid.name,\n pid.birthdate,\n pid.gender)\n('shenzhen', '1', 'libang', datetime.datetime(2009, 10, 10, 0, 0), 'M')\n```\n\n#### PV1\n```python\n>>> pv1 = h['PV1'][0]\n>>> (pv1.patient_class,\n pv1.patient_class_display,\n pv1.patient_type,\n pv1.patient_type_display,\n pv1.assigned_patient_location,\n pv1.admit_datetime)\n('U', 'Unknown', 'adult', 'Adult', None, datetime.datetime(2018, 7, 26, 18, 13, 46))\n```\n\n#### OBR\n```python\n>>> obr = h['OBR'][0]\n>>> obr.datetime\ndatetime.datetime(2018, 7, 3, 11, 17, 43)\n```\n\n#### OBX\n```python\n>>> obx = h['OBX'][3] # 4th OBX instance\n>>> (obx.identifier,\n obx.value_type,\n obx.value,\n obx.units,\n obx.reference_range,\n obx.datetime)\n('DIA', 'NM', 85, 'mmHg', (50, 90), datetime.datetime(2018, 7, 3, 11, 17, 13))\n```\n\nTo find a `OBX` segment or value inside a `Message` by its identifier, use `get_obx` and `get_obx_value` methods:\n\n```python\n>>> h.get_obx('DIA')\n\n\n>>> h.get_obx('DIA').value\n85\n\n>>> h.get_obx_value('SPO2')\n96\n```\n\n## Network client\n`python-xml-hl7` provides a simple network (TCP/IP) client, wich reads HL7 messages from [Alfamed](http://www.alfamed.com/) patient monitors like [VITA 200e](http://www.alfamed.com/monitor-multiparametro-vita-200.html)\n\n```python\nfrom hl7.xml.client import AlfamedClient\n\nclient = AlfamedClient('169.254.215.35') # Default communication port is 9100\nclient.read_message() # By default, HL7 messages are converted into Message objects\nclient.read_message(parse_message=False) # Returns the original HL7 message as string\n```\n\n`AlfamedClient` objects instantiated with invalid host addresses will raises `AttributeError`\n\n## Testing\nYou can run tests locally using `unittest` module\n\n```\ncd python-xml-hl7\npython -m unittest tests\n```\n\nIf all the tests pass you will see a success message like this:\n```\n.................\n----------------------------------------------------------------------\nRan 17 tests in 0.007s\n\nOK\n```\n\n## Notes\n\n* Specification for XML encoding rules of HL7 v2 messages can be found [here](http://www.hl7.org/implement/standards/product_brief.cfm?product_id=83)\n* For any suggestion, feature or bug fix, you can report an issue [here](https://github.com/weynelucas/python-xml-hl7/issues). Or submit a pull request\n* For handle HL7 messages in original stream format, use solutions like [python-hl7](http://python-hl7.readthedocs.io/en/latest/) or [HL7apy](http://hl7apy.org/)\n\n## Release Notes\n\n* 1.0.0 - First release\n* 1.1.0 - Find `OBX` segments with `get_obx` and `get_obx_value`\n* 1.2.0 - String representation for client and container objects\n* 1.3.0 - Add Travis and Codecov support",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "https://github.com/weynelucas/python-xml-hl7/archive/1.3.0.tar.gz",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/weynelucas/python-xml-hl7",
"keywords": "hl7 health level xml python-hl7 python-xml-hl7",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "python-xml-hl7",
"package_url": "https://pypi.org/project/python-xml-hl7/",
"platform": "",
"project_url": "https://pypi.org/project/python-xml-hl7/",
"project_urls": {
"Download": "https://github.com/weynelucas/python-xml-hl7/archive/1.3.0.tar.gz",
"Homepage": "https://github.com/weynelucas/python-xml-hl7"
},
"release_url": "https://pypi.org/project/python-xml-hl7/1.3.0/",
"requires_dist": null,
"requires_python": "",
"summary": "A library for parsing HL7 (version 2.x) messages in XML format into Python objects",
"version": "1.3.0"
},
"last_serial": 5457856,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "52b94c8caaf787fe0aff0923357a2a1c",
"sha256": "ead4e4f4a06e5c654962ced1053ae8521ceee0451f1c9d999f5a276d8ffeecde"
},
"downloads": -1,
"filename": "python-xml-hl7-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "52b94c8caaf787fe0aff0923357a2a1c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9861,
"upload_time": "2018-08-08T20:55:31",
"url": "https://files.pythonhosted.org/packages/c1/84/3ad3c9705bb3df1fe3110e2e703202c480a5a3a99832175761af390c74e1/python-xml-hl7-1.0.0.tar.gz"
}
],
"1.1.0": [
{
"comment_text": "",
"digests": {
"md5": "535863db9b4c4d6c7b1d70bce99bb832",
"sha256": "8fdcb9148d376a6320ad3647ae799c1501e053fac0671970343f8e596821b3bd"
},
"downloads": -1,
"filename": "python-xml-hl7-1.1.0.zip",
"has_sig": false,
"md5_digest": "535863db9b4c4d6c7b1d70bce99bb832",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 19100,
"upload_time": "2018-08-13T13:30:19",
"url": "https://files.pythonhosted.org/packages/32/2a/4bd8489d2055f88e447cad60c45f10636b4d477e31c3d74935080b8fa394/python-xml-hl7-1.1.0.zip"
}
],
"1.2.0": [
{
"comment_text": "",
"digests": {
"md5": "19405142b94953815df86ddd9b11531d",
"sha256": "0b4cf4b167e1befa3a8e1d9f105dd8dd82de4545fd1cfc14fa0f9a0ac2bb11d4"
},
"downloads": -1,
"filename": "python-xml-hl7-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "19405142b94953815df86ddd9b11531d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10617,
"upload_time": "2018-08-14T20:22:26",
"url": "https://files.pythonhosted.org/packages/93/31/d80b84ca48375ae7b9a9210275f8f31fcedc8c710b64232de303b923ede5/python-xml-hl7-1.2.0.tar.gz"
}
],
"1.3.0": [
{
"comment_text": "",
"digests": {
"md5": "3bfd9b863675d2f809efaa27a2db84c2",
"sha256": "25acc48c70bea60eb766b3d09a928c26dd076c8c99f9be8a00d9ecdc75832f10"
},
"downloads": -1,
"filename": "python-xml-hl7-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3bfd9b863675d2f809efaa27a2db84c2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11813,
"upload_time": "2019-06-27T16:46:41",
"url": "https://files.pythonhosted.org/packages/88/c6/ce3386d2fbc493c748b3e683493e9aca7545736e741dbfb943428cc71a05/python-xml-hl7-1.3.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "3bfd9b863675d2f809efaa27a2db84c2",
"sha256": "25acc48c70bea60eb766b3d09a928c26dd076c8c99f9be8a00d9ecdc75832f10"
},
"downloads": -1,
"filename": "python-xml-hl7-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3bfd9b863675d2f809efaa27a2db84c2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11813,
"upload_time": "2019-06-27T16:46:41",
"url": "https://files.pythonhosted.org/packages/88/c6/ce3386d2fbc493c748b3e683493e9aca7545736e741dbfb943428cc71a05/python-xml-hl7-1.3.0.tar.gz"
}
]
}