Package: hospital-logfile-analyzer
IntroductionTool to convert plain-text hospital integration engines' log files to
structured data. Currently supported logfile formats:Cloverleaf plain-text log files (NB: This tool is not affiliated with Infor Cloverleaf.)How to installInstall from Pypipipinstallhospital_logfile_analyzerInstall from GithubDownload the latest release as atar.gzarchive from theGithub repository page:wgethttps://github.com/doctolib/hospital_logfile_analyzer/archive/v.0.1.tar.gz
tar-xvfv.0.1.tar.gzcdhospital_logfile_analyzer
rmv.0.1.tar.gz
pythonsetup.pyinstallInstall from source codeUsing git, clone the repository to your working directory, and install the package:gitclonegit@github.com:doctolib/hospital_logfile_analyzer.gitcdhospital_logfile_analyzer
pythonsetup.pyinstallPrerequisitesThis package supports Python 3 and has not been tested with Python 2.To view and run the attached Jupyter Notebooks, best install anAnaconda environment.Command-line interfaceYou can execute the logfile parser in the command-line of your choice (e.g. bash).main.pyimplements the command-line argument parser.
Display all options:python-mhospital_logfile_analyzer--helpThe easiest call to run the application:python-mhospital_logfile_analyzermylogfile.logoutput_structured_log.jsonA more sophisticated application call would involve mapping and/or field filtering:python-mhospital_logfile_analyzermylogfile.logoutput_structured_log.json--mappingfilemy_mapping.json--filterfilemy_filter.jsonFor instructions on how to create field maps and filters,
see the respective sections in text below.Jupyter NotebookYou will find examples on how to execute this package in a Jupyter Notebook
insidejupyter_notebooksdirectory.PackageYou can use the logfile parser directly in your Python code:fromhospital_logfile_analyzer.parsersimportparseparser=parse('hospital_logfile_analyzer/test/test.log')print(len(parser.events))How to create custom mappings and field filtersField MappingFields can be mapped across different levels of hierarchy.
E.g. you can maproot.child1.child2.key1toroot.key1.
The mapping allows you to propagate fields from lower levels of hierarchy
to the top. Together with filters,
this allows for very efficient analysis of structured data.Mapping is given by a JSON dictionary with the source field names being the
keys, and the target field names the values.
The field names inside subtrees are separated by dots.The following example snippet will copy (or move, depending on the function
parameters) the value of fieldTree.Error CodeintoError Code:{"Tree.Error Code":"Error Code","Tree.Result.Code":"Result Code"}The field map has to be stored as a UTF-8 encoded JSON file. For instructions
on how to pass this file to the application, see the CLI or the package usage
documentation in text above.Field FiltersField filters allow to remove fields and subtrees from the structured data.The following example will remove fieldsTree.Error Codeand will keepTree.Result.Code:{"Tree.Error Code":false,"Tree.Result.Code":true}The field map has to be stored as a UTF-8 encoded JSON file. For instructions
on how to pass this file to the application, see the CLI or the Python package
usage documentation in text above.How to testExecute in the root folder of the repository:python-munittestThis will discover and execute all tests contained
insidehospital_logfile_analyzer/test.How to contributeYou can add your own logfile parsers:InheritYourOwnParserfrom the abstract parent interfaceLogfileParser.Add unit tests by addingtest_yourownparser.pyunderhospital_logfile_analyzer/test.Commit changes to your own branch and create a pull request.
The tests on the branch must run green before the
branch can be merged.LicenseSeeLICENSE.