druc / xdt-parser
Parse German healthcare data interchange formats GDT, LDT and BDT
v0.2.1
2018-10-03 10:30 UTC
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: 6.*
- squizlabs/php_codesniffer: ^2.3
README
Php parser for German healthcare data interchange formats GDT, LDT and BDT.
Install
Via Composer
$ composer require druc/xdt-parser
Usage
<?php use Druc\XdtParser\XdtParser; // Create instance $this->parser = XdtParser::make( file_get_contents(__DIR__ . '/data/sample.ldt'), // file contents ['id' => '8316', 'observation' => '6220'] // field mapping ); // Get first value matching the id field $this->parser->first('id'); // --> '123' // Get all values matching the observation field $this->parser->find('observation'); // --> ['observation 1', 'observation 2']; // Also works with the xdt code $this->parser->first('8316'); // --> '123' $this->parser->find('6220'); // --> ['observation 1', 'observation 2']; // Get mapped values $this->parser->getMapped(); // -> ['id' => 123, 'observation' => ['observation 1', 'observation 2']]; // Add extra field mapping $this->parser->addFieldsMap(['my_value' => '3213']); // Remove fields $this->parser->removeFields(['id']); // Get all values (mapped and unkown/unmapped values) $this->parser->all(); // -> ['3213' => 'unkown code value', 'id' => 123, 'observation' => ['observation 1', 'observation 2']]; // Get field key $this->parser->getKey('observation'); // -> 6220 if the mapping contains 'observation' => '6220' // Get field name $this->parser->getFieldName('6220'); // -> `observation` if the mapping contains 'observation' => '6220' // Get xdtRows $this->parser->getXdtRows(); // will return an array with the unparsed rows of your content: ['0346220Dies ist ein zweizeiliger', '0143102Frank'] // Parse single string $this->parser->parseSingle('0346220Dies ist ein zweizeiliger'); // -> ['length' => 32, field = '6220', 'value' => 'Dies ist ein zweizeiliger'];
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email druc@pinsmile.com instead of using the issue tracker.
Credits
- Constantin Druc
- js parser - albertzak/xdt
- ruby parser - levinlex/xdt
- All Contributors
License
The MIT License (MIT). Please see License File for more information.