fix: x12837 billing 5 or 9 digit zip check (#7760)
[openemr.git] / src / Common / Command / CcdaNewpatient.php
blob7acc99527b7b3b42e1743ba7ebf2a2b5cec484c1
1 <?php
3 /**
4 * CcdaNewpatient class.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2022 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Common\Command;
15 use Carecoordination\Model\CarecoordinationTable;
16 use Symfony\Component\Console\Command\Command;
17 use Symfony\Component\Console\Input\InputDefinition;
18 use Symfony\Component\Console\Input\InputInterface;
19 use Symfony\Component\Console\Input\InputOption;
20 use Symfony\Component\Console\Output\OutputInterface;
21 use Symfony\Component\Console\Style\SymfonyStyle;
23 class CcdaNewpatient extends Command
25 protected function configure(): void
27 $this
28 ->setName('openemr:ccda-newpatient')
29 ->setDescription('Import new patient from audit table id and ccda document id')
30 ->addUsage('--site=default --am_id=5 --document_id=7')
31 ->setDefinition(
32 new InputDefinition([
33 new InputOption('am_id', null, InputOption::VALUE_REQUIRED, 'The master audit table id of patient that will be imported as a new patient'),
34 new InputOption('document_id', null, InputOption::VALUE_REQUIRED, 'The ccda document id that was imported into the audit table'),
35 new InputOption('debug', null, InputOption::VALUE_NONE, 'Turns on debug mode.'),
36 new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
42 protected function execute(InputInterface $input, OutputInterface $output): int
44 if (empty($input->getOption('document_id'))) {
45 $output->writeln('document_id parameter is missing (required), so exiting');
46 return 2;
48 if (empty($input->getOption('am_id'))) {
49 $output->writeln('am_id parameter is missing (required), so exiting');
50 return 2;
53 $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->insert_patient($input->getOption('am_id'), $input->getOption('document_id'));
54 $symfonyStyler = new SymfonyStyle($input, $output);
56 $careCoordinationTable = $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class);
57 if ($careCoordinationTable instanceof CarecoordinationTable) {
58 if ($input->getOption('debug') !== false) {
59 $careCoordinationTable->setCommandLineStyler($symfonyStyler);
60 $careCoordinationTable->getImportService()->setCommandLineStyler($symfonyStyler);
62 $careCoordinationTable->insert_patient($input->getOption('am_id'), $input->getOption('document_id'));
64 return 0;