druc / xdt-parser
解析德国医疗数据交换格式 GDT、LDT 和 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
用于解析德国医疗数据交换格式 GDT、LDT 和 BDT 的 PHP 解析器。
安装
通过 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'];
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
测试
$ composer test
贡献
请参阅 CONTRIBUTING 和 CODE_OF_CONDUCT 以获取详细信息。
安全
如果您发现任何安全问题,请通过电子邮件 druc@pinsmile.com 而不是使用问题跟踪器来报告。
鸣谢
- Constantin Druc
- JavaScript 解析器 - albertzak/xdt
- Ruby 解析器 - levinlex/xdt
- 所有贡献者
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。