Skip to content

Commit

Permalink
Fixes openemr#7319 ccda extra drug_unit list options (openemr#7321)
Browse files Browse the repository at this point in the history
* Fixes openemr#7319 ccda extra drug_unit list options

This fixes the error in the ccda that was creating tons of entries in
the drug_entry list options list.  The CCDA was not checking against
empty values and would continue to create new list_options for each
immunization / prescription drug_unit when the unit was an empty string

I also added some debugging instruments on the prescription and
immunization process which makes it easy to compare for a ccda what is
being parsed and what is being stored in the database.

Added a debug flag to all of the ccda commands so that these options are
available for people needing to do any debugging of the process.

* Exclude 0 values from amount administered checks.

We decided that we wanted to exclude recording 0 values so updated the
conditions on the immunization and prescription to account for that.
  • Loading branch information
adunsulag authored Apr 7, 2024
1 parent 51b92a5 commit 0b1be28
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
use Laminas\Config\Reader\ReaderInterface;
use Laminas\Config\Reader\Xml;
use Laminas\Db\TableGateway\AbstractTableGateway;
use OpenEMR\Common\Command\Trait\CommandLineDebugStylerTrait;
use OpenEMR\Services\Cda\CdaTemplateImportDispose;
use OpenEMR\Services\Cda\CdaTemplateParse;
use OpenEMR\Services\Cda\CdaValidateDocuments;
use OpenEMR\Services\Cda\XmlExtended;
use OpenEMR\Services\CodeTypesService;
use Symfony\Component\Console\Style\SymfonyStyle;

class CarecoordinationTable extends AbstractTableGateway
{
use CommandLineDebugStylerTrait;

public const NPI_SAMPLE = "987654321";
public const ORGANIZATION_SAMPLE = "External Physicians Practice";
public const ORGANIZATION2_SAMPLE = "External Health and Hospitals";
Expand All @@ -51,6 +55,11 @@ public function __construct()
$this->validationIsDisabled = $GLOBALS['ccda_validation_disable'] ?? false;
}

public function getImportService(): CdaTemplateImportDispose
{
return $this->importService;
}

/*
* Fetch the category ID using category name
*
Expand Down
12 changes: 12 additions & 0 deletions src/Common/Command/CcdaImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class CcdaImport extends Command
{
Expand All @@ -30,6 +31,7 @@ protected function configure(): void
->setDefinition(
new InputDefinition([
new InputOption('document_id', null, InputOption::VALUE_REQUIRED, 'Document id that will be imported into the ccda table'),
new InputOption('debug', null, InputOption::VALUE_NONE, 'Turns on debug mode.'),
new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
])
)
Expand All @@ -44,6 +46,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->import($input->getOption('document_id'));
$symfonyStyler = new SymfonyStyle($input, $output);

$careCoordinationTable = $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class);
if ($careCoordinationTable instanceof CarecoordinationTable) {
if ($input->getOption('debug') !== false) {
$careCoordinationTable->setCommandLineStyler($symfonyStyler);
$careCoordinationTable->getImportService()->setCommandLineStyler($symfonyStyler);
}
$careCoordinationTable->import($input->getOption('document_id'));
}
return 0;
}
}
12 changes: 12 additions & 0 deletions src/Common/Command/CcdaNewpatient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class CcdaNewpatient extends Command
{
Expand All @@ -31,6 +32,7 @@ protected function configure(): void
new InputDefinition([
new InputOption('am_id', null, InputOption::VALUE_REQUIRED, 'The master audit table id of patient that will be imported as a new patient'),
new InputOption('document_id', null, InputOption::VALUE_REQUIRED, 'The ccda document id that was imported into the audit table'),
new InputOption('debug', null, InputOption::VALUE_NONE, 'Turns on debug mode.'),
new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
])
)
Expand All @@ -49,6 +51,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->insert_patient($input->getOption('am_id'), $input->getOption('document_id'));
$symfonyStyler = new SymfonyStyle($input, $output);

$careCoordinationTable = $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class);
if ($careCoordinationTable instanceof CarecoordinationTable) {
if ($input->getOption('debug') !== false) {
$careCoordinationTable->setCommandLineStyler($symfonyStyler);
$careCoordinationTable->getImportService()->setCommandLineStyler($symfonyStyler);
}
$careCoordinationTable->insert_patient($input->getOption('am_id'), $input->getOption('document_id'));
}
return 0;
}
}
15 changes: 14 additions & 1 deletion src/Common/Command/CcdaNewpatientImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class CcdaNewpatientImport extends Command
{
Expand All @@ -30,6 +31,7 @@ protected function configure(): void
->setDefinition(
new InputDefinition([
new InputOption('document', null, InputOption::VALUE_REQUIRED, 'File (path) that will be imported to create the new patient'),
new InputOption('debug', null, InputOption::VALUE_NONE, 'Turns on debug mode.'),
new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
])
)
Expand All @@ -50,7 +52,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// get around a large ccda data array
ini_set("memory_limit", -1);

$GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->importNewPatient($input->getOption('document'));


$symfonyStyler = new SymfonyStyle($input, $output);

$careCoordinationTable = $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class);
if ($careCoordinationTable instanceof CarecoordinationTable) {
if ($input->getOption('debug') !== false) {
$careCoordinationTable->setCommandLineStyler($symfonyStyler);
$careCoordinationTable->getImportService()->setCommandLineStyler($symfonyStyler);
}
$careCoordinationTable->importNewPatient($input->getOption('document'));
}
return 0;
}
}
44 changes: 44 additions & 0 deletions src/Common/Command/Trait/CommandLineDebugStylerTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Facilitates adding a debug flag and a cli input/output styler useful for debugging commands.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Stephen Nielson <[email protected]>
* @copyright Copyright (c) 2024 Discover and Change, Inc. <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

namespace OpenEMR\Common\Command\Trait;

use Symfony\Component\Console\Style\SymfonyStyle;

trait CommandLineDebugStylerTrait
{
/**
* @var SymfonyStyle CLI styler used for debug mode to help in identifying issues during the import process.
*/
protected SymfonyStyle $styler;

/**
* @var bool Whether to add additional logging / debug output to the system
*/
protected bool $cliDebug = false;

public function setCommandLineStyler(SymfonyStyle $symfonyStyler)
{
$this->cliDebug = true;
$this->styler = $symfonyStyler;
}

public function isCliDebug()
{
return $this->cliDebug;
}

public function getCommandLineStyler(): SymfonyStyle
{
return $this->styler;
}
}
Loading

0 comments on commit 0b1be28

Please sign in to comment.