Php parser for German healthcare data interchange formats GDT, LDT and BDT.
Via Composer
$ composer require druc/xdt-parser
<?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'];
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email druc@pinsmile.com instead of using the issue tracker.
- Constantin Druc
- js parser - albertzak/xdt
- ruby parser - levinlex/xdt
- All Contributors
The MIT License (MIT). Please see License File for more information.