drop support for php 7.4 (#5740)
[openemr.git] / src / Common / Command / CcdaNewpatient.php
blob75bf8c9885b700872e2a6a193e40ac9428f3235f
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;
22 class CcdaNewpatient extends Command
24 protected function configure(): void
26 $this
27 ->setName('openemr:ccda-newpatient')
28 ->setDescription('Import new patient from audit table id and ccda document id')
29 ->addUsage('--site=default --am_id=5 --document_id=7')
30 ->setDefinition(
31 new InputDefinition([
32 new InputOption('am_id', null, InputOption::VALUE_REQUIRED, 'The master audit table id of patient that will be imported as a new patient'),
33 new InputOption('document_id', null, InputOption::VALUE_REQUIRED, 'The ccda document id that was imported into the audit table'),
34 new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
40 protected function execute(InputInterface $input, OutputInterface $output): int
42 if (empty($input->getOption('document_id'))) {
43 $output->writeln('document_id parameter is missing (required), so exiting');
44 return 2;
46 if (empty($input->getOption('am_id'))) {
47 $output->writeln('am_id parameter is missing (required), so exiting');
48 return 2;
51 $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->insert_patient($input->getOption('am_id'), $input->getOption('document_id'));
52 return 0;