From c1744d7fcaf8762129fa18e5666b266595a503ff Mon Sep 17 00:00:00 2001 From: Robert Down RN Date: Thu, 10 Aug 2023 11:20:10 -0400 Subject: [PATCH] Revert "feat: Hook into the CDA Parsing functions (#6716)" (#6730) This reverts commit e2f1e03a2389ed8c15f870503197d5a542f59387. --- src/Events/CDA/CDAPostParseEvent.php | 125 ---------------------------------- src/Events/CDA/CDAPreParseEvent.php | 57 ---------------- src/Services/Cda/CdaTemplateParse.php | 18 +---- 3 files changed, 1 insertion(+), 199 deletions(-) delete mode 100644 src/Events/CDA/CDAPostParseEvent.php delete mode 100644 src/Events/CDA/CDAPreParseEvent.php diff --git a/src/Events/CDA/CDAPostParseEvent.php b/src/Events/CDA/CDAPostParseEvent.php deleted file mode 100644 index 508d7f253..000000000 --- a/src/Events/CDA/CDAPostParseEvent.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright 2023 Robert Down - * @copyright 2023 Providence Healthtech - * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 - */ - -namespace OpenEMR\Events\CDA; - -use Symfony\Contracts\EventDispatcher\Event; - -/** - * - * This event is dispatched when the CDA document is parsed. It is dispatched - * once for each component in the list of components and occurs after the core - * processing has occurred. It can return the manipulated templateData. - */ -final class CDAPostParseEvent extends Event -{ - public const EVENT_HANDLE = 'cda.component.post.parse'; - - /** - * @var array The component of the CDA document, see parseCDAEntryComponents() in CdaTemplateParse - */ - private $templateData; - - /** - * @var array Should equal the $templateData property in CdaTemplateParse - */ - private $component; - - /** - * @var string The name of the component. allergies, encounters, etc. - */ - private $componentName; - - /** - * @var string The OID of the template - */ - private $oid; - - /** - * - * @param string $componentName - * @param array $component - * @param array $templateData - */ - public function __construct(string $componentName, string $oid, array $component, array $templateData) - { - $this->componentName = $componentName; - $this->component = $component; - $this->templateData = $templateData; - $this->oid = $oid; - } - - /** - * @return string The name of the component. allergies, encounters, etc. - */ - public function getComponentName(): string - { - return $this->componentName; - } - - /** - * @return array The component of the CDA document, see parseCDAEntryComponents() in CdaTemplateParse - */ - public function getComponent(): array - { - return $this->component; - } - - /** - * @return array Should equal the $templateData property in CdaTemplateParse - */ - public function getTemplateData(): array - { - return $this->templateData; - } - - /** - * @return string The OID of the template - */ - public function getOid(): string - { - return $this->oid; - } - - /** - * @param string $componentName The name of the component. allergies, encounters, etc. - */ - public function setComponentName(string $componentName): void - { - $this->componentName = $componentName; - } - - /** - * @param string $component - */ - public function setComponent(array $component): void - { - $this->component = $component; - } - - /** - * @param array $templateData - */ - public function setTemplateData($templateData): void - { - $this->templateData = $templateData; - } - - /** - * Set the OID - */ - public function setOid(string $oid): void - { - $this->oid = $oid; - } -} diff --git a/src/Events/CDA/CDAPreParseEvent.php b/src/Events/CDA/CDAPreParseEvent.php deleted file mode 100644 index 5fc06ff9c..000000000 --- a/src/Events/CDA/CDAPreParseEvent.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright 2023 Robert Down - * @copyright 2023 Providence Healthtech - * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 - */ - -namespace OpenEMR\Events\CDA; - -use Symfony\Contracts\EventDispatcher\Event; - -/** - * - * This event is dispatched when the CDA document is parsed. It is dispatched - * prior to any processing of the data. It accepts the component data and returns - * data in the same shape as the component data - */ -final class CDAPreParseEvent extends Event -{ - public const EVENT_HANDLE = 'cda.component.pre.parse'; - - /** - * @var array Should equal the $templateData property in CdaTemplateParse - */ - private $components; - - /** - * - * @param array $components - */ - public function __construct(array $components = []) - { - $this->components = $components; - } - - /** - * @return array The components of the CDA document, see parseCDAEntryComponentss() in CdaTemplateParse - */ - public function getComponents(): array - { - return $this->components; - } - - /** - * @param string $components - */ - public function setComponents(array $components): void - { - $this->components = $components; - } -} diff --git a/src/Services/Cda/CdaTemplateParse.php b/src/Services/Cda/CdaTemplateParse.php index 3d80d9ebc..ac040eba4 100644 --- a/src/Services/Cda/CdaTemplateParse.php +++ b/src/Services/Cda/CdaTemplateParse.php @@ -13,8 +13,6 @@ namespace OpenEMR\Services\Cda; use DOMDocument; -use OpenEMR\Events\CDA\CDAPreParseEvent; -use OpenEMR\Events\CDA\CDAPostParseEvent; use OpenEMR\Services\CodeTypesService; class CdaTemplateParse @@ -24,17 +22,11 @@ class CdaTemplateParse private $currentOid; protected $is_qrda_import; - /** - * @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface - */ - private $ed; - public function __construct() { $this->templateData = []; $this->is_qrda_import = false; $this->codeService = new CodeTypesService(); - $this->ed = $GLOBALS['kernel']->getEventDispatcher(); } public function parseCDAEntryComponents($components): array @@ -69,17 +61,12 @@ class CdaTemplateParse '2.16.840.1.113883.10.20.22.2.41' => 'dischargeSummary' ); - $preParseEvent = new CDAPreParseEvent($components); - $this->ed->dispatch($preParseEvent, CDAPreParseEvent::EVENT_HANDLE); - - foreach ($preParseEvent->getComponents() as $component) { + foreach ($components as $component) { if (!empty($component['section']['templateId']['root'])) { if (!empty($components_oids[$component['section']['templateId']['root']])) { $this->currentOid = $component['section']['templateId']['root']; $func_name = $components_oids[$component['section']['templateId']['root']]; $this->$func_name($component); - $postParseEvent = new CDAPostParseEvent($func_name, $this->currentOid, $component, $this->templateData); - $this->ed->dispatch($postParseEvent, CDAPostParseEvent::EVENT_HANDLE); } } elseif (empty($component['section']['templateId'])) { // uncomment for debugging information. @@ -91,13 +78,10 @@ class CdaTemplateParse $this->currentOid = $component['section']['templateId'][$key_1]['root']; $func_name = $components_oids[$component['section']['templateId'][$key_1]['root']]; $this->$func_name($component); - $postParseEvent = new CDAPostParseEvent($func_name, $this->currentOid, $component, $this->templateData); - $this->ed->dispatch($postParseEvent, CDAPostParseEvent::EVENT_HANDLE); break; } } } - $this->templateData = $postParseEvent->getTemplateData(); } return $this->templateData; } -- 2.11.4.GIT