hl7lib


Namehl7lib JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/norlowski/HL7py
SummaryHL7 message parser
upload_time2024-09-27 04:41:20
maintainerNone
docs_urlNone
authorfatryst
requires_pythonNone
licenseMIT
keywords hl7 parsing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. code:: hl7lib

   -----
   The MIT License

   Copyright (c) 2016 Ankhos Clinical Oncology Software

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.

   =====



   A parser for the HL7 Health data interchange format written in python. Provides
   attribute-like access to correct datatypes and provides the ability to construct HL7
   messages from dictionaries.

   The HL7 transport protocol is a confusing mess of pipes and carriage returns. This package
   provides easy Pythonic access to attributes within a message. There is much domain
   knowledge of segments names and field names, but what follows are some basic examples of
   syntax and usage.



   Here is a sample message from http://www.coast2coastinformatics.com/user/ADTA08_examples-110106.pdf
    
       MSH|^~\&|AccMgr|1|||20050110045504||ADT^A01|599102|P|2.3|||
       EVN|A01|20050110045502|||||
       PID|1||10006579^^^1^MRN^1||DUCK^DONALD^D||19241010|M||1|111 DUCK ST^^FOWL^CA^999990000^^M|1|8885551212|8885551212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO NK1|1|DUCK^HUEY|SO|3583 DUCK RD^^FOWL^CA^999990000|8885552222||Y||||||||||||||
       PV1|1|I|PREOP^101^1^1^^^S|3|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|||01||||1|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|2|40007716^^^AccMgr^VN|4|||||||||||||||||||1||G|||20050110045253||||||
       GT1|1|8291|DUCK^DONALD^D||111^DUCK ST^^FOWL^CA^999990000|8885551212||19241010|M||1|123121234||||#Cartoon Ducks Inc|111^DUCK ST^^FOWL^CA^999990000|8885551212||PT| DG1|1|I9|71596^OSTEOARTHROS NOS-L/LEG ^I9|OSTEOARTHROS NOS-L/LEG ||A|
       IN1|1|MEDICARE|3|MEDICARE|||||||Cartoon Ducks Inc|19891001|||4|DUCK^DONALD^D|1|19241010|111^DUCK ST^^FOWL^CA^999990000|||||||||||||||||123121234A||||||PT|M|111 DUCK ST^^FOWL^CA^999990000|||||8291
       IN2|1||123121234|Cartoon Ducks Inc|||123121234A|||||||||||||||||||||||||||||||||||||||||||||||||||||||||8885551212 IN1|2|NON-PRIMARY|9|MEDICAL MUTUAL CALIF.|PO BOX 94776^^HOLLYWOOD^CA^441414776||8003621279|PUBSUMB|||Cartoon Ducks Inc||||7|DUCK^DONALD^D|1|19241010|111 DUCK ST^^FOWL^CA^999990000|||||||||||||||||056269770||||||PT|M|111^DUCK ST^^FOWL^CA^999990000|||||8291 IN2|2||123121234|Cartoon Ducks Inc||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||8885551212
       IN1|3|SELF PAY|1|SELF PAY|||||||||||5||1


   =================DATA ACCESS EXAMPLES============

   You will be able to use syntax like

   1. 'SEG.some_attribute.data' to access either a dictionary (if that field has subfields)
      or a value parsed to the correct datatype, e.g. datetime or numeric.
   2. 'SEG.some_attribute.hl7' to have the message construct the HL7 equivalent of that
      attribute and all of its following segments and subsegments.

   3. 'SEG.some_attribute.some_timestamp.data = datetime.datetime.now()' allows you to set
      the value of a specific note/segment. See examples in the tests.


   Examples:

       from HL7py import parser
       my_message = parser.parse(incoming_str)
       my_message.PID.pat_name.data
       {'family_name':'DUCK','give_name':'DONALD','middle_name':'D'}
       my_message.PID.pat_name.family_name.hl7
       'DUCK'
       my_message.IN1[0].ins_company_name.hl7
       'MEDICARE'
       my_message.IN1[0].ins_company_name.data
       'MEDICARE'
       my_message.IN1[1].ins_company_name.hl7
       'SELF PAY'
       my_message.IN1_list
       [IN1,IN1]
       for ins in IN1_list:
           print ins.ins_company_name.hl7
       'MEDICARE'
       'SELFPAY




   The NTE section is a special case. NTE sections can come after any other section and
   are assembled into the .note attribute for a segment.



       PID|1|123456789|112233|1234567|Test^Patient||19820620|F|||123 Fake St.^^SumCity^ST^12345-||(123)456-7890||||||
       ORC|RE|29117637990^LAB|291176379902012^LAB||||||201210170000|||1366445686^Doctor^M^^^^^N
       OBR|1|29117637990^LAB|291176379902012^LAB|001321^Iron and TIBC^L|||201210171632|||||||201210171934||||M542856833||29117637990||201210180743|||F
       OBX|1|NM|001347^Iron Bind.Cap.(TIBC)^L||476|ug/dL|250-450|H||N|F|19840622||201210180726|BN
       OBX|2|NM|001348^UIBC^L||462|ug/dL|150-375|H||N|F|19940518||201210180726|BN
       NTE|1|L|Results confirmed on
       NTE|2|L|dilution.
       
   The following would occur:

       print my_message.ORC.OBR.OBX_list[1].note
       'Results confirmed on dilution'

   =================MESSAGE CREATION EXAMPLES============
   Messages are created by assembling Segments and adding them to a Message.
    Here is an example of how our EMR, Ankhos, constructs an ADT/A08 message.  The chart.to_dict()
    method constructs a dictionary of the relevant fields from chart demographics, etc.

       msg = Message()
       msh_data= dict(
               recv_app={'app_name': 'Their App'},
               send_app={'app_name': 'ANKHOS'},
               msg_type=dict(message_code='ADT',
                             event_code='A08'),
               accept_ack_type='AL',
               application_ack_type='AL',
               proc_id='P',
               version='2.3',
               msg_ctl_id=control_id,
               encoding_chars='^~\&',
               timestamp=datetime.datetime.now())
       MSH = Segment(code='MSH',data=msh_data)
       evn_data = dict(event_code=event_code,timestamp=dict(time=datetime.datetime.now(),
                                                             resolution='S'))
       EVN = Segment(code='EVN',data=evn_data)
       PID = Segment(code='PID',data=chart.to_dict())
       pv1_data = {...}
       PV1 = Segment(code='PV1',data=pv1_data)
       msg.add_segments([MSH,EVN,PID,PV1])

       #Voila!
       print msg.hl7


   As long as the data dictionaries follow the signatures in the HL7fields.py specification,
   the Segments should be constructed correctly.  There are a LOT of HL7 specified segments
   but only a few in the include HL7fields.py file. We simply haven't had a use for most of them
   yet but if we do, I will be sure to update the HL7fields specification dictionary.


   Current limitations:
    1. The ADD operation is not supported. (very low priority)
    2. Intra-field repetition is not yet supported
    3. The tests included are only smoke tests to make sure fundamental things haven't broken!
      HL7 is used in life-critical systems. Again. Please Please Please test your own software!
      More real tests will be added when time allows.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/norlowski/HL7py",
    "name": "hl7lib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "hl7 parsing",
    "author": "fatryst",
    "author_email": "fatryst@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/d2/fe41bb68bb4d1c2d3c04dcd5639cd3726301073606ac0884f3e8a177f160/hl7lib-1.0.0.tar.gz",
    "platform": null,
    "description": ".. code:: hl7lib\r\n\r\n   -----\r\n   The MIT License\r\n\r\n   Copyright (c) 2016 Ankhos Clinical Oncology Software\r\n\r\n   Permission is hereby granted, free of charge, to any person obtaining a copy\r\n   of this software and associated documentation files (the \"Software\"), to deal\r\n   in the Software without restriction, including without limitation the rights\r\n   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n   copies of the Software, and to permit persons to whom the Software is\r\n   furnished to do so, subject to the following conditions:\r\n\r\n   The above copyright notice and this permission notice shall be included in\r\n   all copies or substantial portions of the Software.\r\n\r\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n   THE SOFTWARE.\r\n\r\n   =====\r\n\r\n\r\n\r\n   A parser for the HL7 Health data interchange format written in python. Provides\r\n   attribute-like access to correct datatypes and provides the ability to construct HL7\r\n   messages from dictionaries.\r\n\r\n   The HL7 transport protocol is a confusing mess of pipes and carriage returns. This package\r\n   provides easy Pythonic access to attributes within a message. There is much domain\r\n   knowledge of segments names and field names, but what follows are some basic examples of\r\n   syntax and usage.\r\n\r\n\r\n\r\n   Here is a sample message from http://www.coast2coastinformatics.com/user/ADTA08_examples-110106.pdf\r\n    \r\n       MSH|^~\\&|AccMgr|1|||20050110045504||ADT^A01|599102|P|2.3|||\r\n       EVN|A01|20050110045502|||||\r\n       PID|1||10006579^^^1^MRN^1||DUCK^DONALD^D||19241010|M||1|111 DUCK ST^^FOWL^CA^999990000^^M|1|8885551212|8885551212|1|2||40007716^^^AccMgr^VN^1|123121234|||||||||||NO NK1|1|DUCK^HUEY|SO|3583 DUCK RD^^FOWL^CA^999990000|8885552222||Y||||||||||||||\r\n       PV1|1|I|PREOP^101^1^1^^^S|3|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|||01||||1|||37^DISNEY^WALT^^^^^^AccMgr^^^^CI|2|40007716^^^AccMgr^VN|4|||||||||||||||||||1||G|||20050110045253||||||\r\n       GT1|1|8291|DUCK^DONALD^D||111^DUCK ST^^FOWL^CA^999990000|8885551212||19241010|M||1|123121234||||#Cartoon Ducks Inc|111^DUCK ST^^FOWL^CA^999990000|8885551212||PT| DG1|1|I9|71596^OSTEOARTHROS NOS-L/LEG ^I9|OSTEOARTHROS NOS-L/LEG ||A|\r\n       IN1|1|MEDICARE|3|MEDICARE|||||||Cartoon Ducks Inc|19891001|||4|DUCK^DONALD^D|1|19241010|111^DUCK ST^^FOWL^CA^999990000|||||||||||||||||123121234A||||||PT|M|111 DUCK ST^^FOWL^CA^999990000|||||8291\r\n       IN2|1||123121234|Cartoon Ducks Inc|||123121234A|||||||||||||||||||||||||||||||||||||||||||||||||||||||||8885551212 IN1|2|NON-PRIMARY|9|MEDICAL MUTUAL CALIF.|PO BOX 94776^^HOLLYWOOD^CA^441414776||8003621279|PUBSUMB|||Cartoon Ducks Inc||||7|DUCK^DONALD^D|1|19241010|111 DUCK ST^^FOWL^CA^999990000|||||||||||||||||056269770||||||PT|M|111^DUCK ST^^FOWL^CA^999990000|||||8291 IN2|2||123121234|Cartoon Ducks Inc||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||8885551212\r\n       IN1|3|SELF PAY|1|SELF PAY|||||||||||5||1\r\n\r\n\r\n   =================DATA ACCESS EXAMPLES============\r\n\r\n   You will be able to use syntax like\r\n\r\n   1. 'SEG.some_attribute.data' to access either a dictionary (if that field has subfields)\r\n      or a value parsed to the correct datatype, e.g. datetime or numeric.\r\n   2. 'SEG.some_attribute.hl7' to have the message construct the HL7 equivalent of that\r\n      attribute and all of its following segments and subsegments.\r\n\r\n   3. 'SEG.some_attribute.some_timestamp.data = datetime.datetime.now()' allows you to set\r\n      the value of a specific note/segment. See examples in the tests.\r\n\r\n\r\n   Examples:\r\n\r\n       from HL7py import parser\r\n       my_message = parser.parse(incoming_str)\r\n       my_message.PID.pat_name.data\r\n       {'family_name':'DUCK','give_name':'DONALD','middle_name':'D'}\r\n       my_message.PID.pat_name.family_name.hl7\r\n       'DUCK'\r\n       my_message.IN1[0].ins_company_name.hl7\r\n       'MEDICARE'\r\n       my_message.IN1[0].ins_company_name.data\r\n       'MEDICARE'\r\n       my_message.IN1[1].ins_company_name.hl7\r\n       'SELF PAY'\r\n       my_message.IN1_list\r\n       [IN1,IN1]\r\n       for ins in IN1_list:\r\n           print ins.ins_company_name.hl7\r\n       'MEDICARE'\r\n       'SELFPAY\r\n\r\n\r\n\r\n\r\n   The NTE section is a special case. NTE sections can come after any other section and\r\n   are assembled into the .note attribute for a segment.\r\n\r\n\r\n\r\n       PID|1|123456789|112233|1234567|Test^Patient||19820620|F|||123 Fake St.^^SumCity^ST^12345-||(123)456-7890||||||\r\n       ORC|RE|29117637990^LAB|291176379902012^LAB||||||201210170000|||1366445686^Doctor^M^^^^^N\r\n       OBR|1|29117637990^LAB|291176379902012^LAB|001321^Iron and TIBC^L|||201210171632|||||||201210171934||||M542856833||29117637990||201210180743|||F\r\n       OBX|1|NM|001347^Iron Bind.Cap.(TIBC)^L||476|ug/dL|250-450|H||N|F|19840622||201210180726|BN\r\n       OBX|2|NM|001348^UIBC^L||462|ug/dL|150-375|H||N|F|19940518||201210180726|BN\r\n       NTE|1|L|Results confirmed on\r\n       NTE|2|L|dilution.\r\n       \r\n   The following would occur:\r\n\r\n       print my_message.ORC.OBR.OBX_list[1].note\r\n       'Results confirmed on dilution'\r\n\r\n   =================MESSAGE CREATION EXAMPLES============\r\n   Messages are created by assembling Segments and adding them to a Message.\r\n    Here is an example of how our EMR, Ankhos, constructs an ADT/A08 message.  The chart.to_dict()\r\n    method constructs a dictionary of the relevant fields from chart demographics, etc.\r\n\r\n       msg = Message()\r\n       msh_data= dict(\r\n               recv_app={'app_name': 'Their App'},\r\n               send_app={'app_name': 'ANKHOS'},\r\n               msg_type=dict(message_code='ADT',\r\n                             event_code='A08'),\r\n               accept_ack_type='AL',\r\n               application_ack_type='AL',\r\n               proc_id='P',\r\n               version='2.3',\r\n               msg_ctl_id=control_id,\r\n               encoding_chars='^~\\&',\r\n               timestamp=datetime.datetime.now())\r\n       MSH = Segment(code='MSH',data=msh_data)\r\n       evn_data = dict(event_code=event_code,timestamp=dict(time=datetime.datetime.now(),\r\n                                                             resolution='S'))\r\n       EVN = Segment(code='EVN',data=evn_data)\r\n       PID = Segment(code='PID',data=chart.to_dict())\r\n       pv1_data = {...}\r\n       PV1 = Segment(code='PV1',data=pv1_data)\r\n       msg.add_segments([MSH,EVN,PID,PV1])\r\n\r\n       #Voila!\r\n       print msg.hl7\r\n\r\n\r\n   As long as the data dictionaries follow the signatures in the HL7fields.py specification,\r\n   the Segments should be constructed correctly.  There are a LOT of HL7 specified segments\r\n   but only a few in the include HL7fields.py file. We simply haven't had a use for most of them\r\n   yet but if we do, I will be sure to update the HL7fields specification dictionary.\r\n\r\n\r\n   Current limitations:\r\n    1. The ADD operation is not supported. (very low priority)\r\n    2. Intra-field repetition is not yet supported\r\n    3. The tests included are only smoke tests to make sure fundamental things haven't broken!\r\n      HL7 is used in life-critical systems. Again. Please Please Please test your own software!\r\n      More real tests will be added when time allows.\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "HL7 message parser",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/norlowski/HL7py"
    },
    "split_keywords": [
        "hl7",
        "parsing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8cd2fe41bb68bb4d1c2d3c04dcd5639cd3726301073606ac0884f3e8a177f160",
                "md5": "a62a5afd87d47d2332404a7d2ac67d18",
                "sha256": "fc9e04abe594372459eaede7294b93daa15954d82d6afbb44f1cbd40bc001ff1"
            },
            "downloads": -1,
            "filename": "hl7lib-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a62a5afd87d47d2332404a7d2ac67d18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21867,
            "upload_time": "2024-09-27T04:41:20",
            "upload_time_iso_8601": "2024-09-27T04:41:20.966129Z",
            "url": "https://files.pythonhosted.org/packages/8c/d2/fe41bb68bb4d1c2d3c04dcd5639cd3726301073606ac0884f3e8a177f160/hl7lib-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 04:41:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "norlowski",
    "github_project": "HL7py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hl7lib"
}
        
Elapsed time: 1.94480s