drop support for php 7.4 (#5740)
[openemr.git] / src / Common / Command / CcdaNewpatientImport.php
blob2c270fd8691427a0c4a795397b602a27488b6e82
1 <?php
3 /**
4 * CcdaNewpatientImport 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 CcdaNewpatientImport extends Command
24 protected function configure(): void
26 $this
27 ->setName('openemr:ccda-newpatient-import')
28 ->setDescription('Import a new patient ccda directly from ccda')
29 ->addUsage('--site=default --document=/file/path/file.xml')
30 ->setDefinition(
31 new InputDefinition([
32 new InputOption('document', null, InputOption::VALUE_REQUIRED, 'File (path) that will be imported to create the new patient'),
33 new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
39 protected function execute(InputInterface $input, OutputInterface $output): int
41 if (empty($input->getOption('document'))) {
42 $output->writeln('document parameter is missing (required), so exiting');
43 return 2;
45 if (!is_file($input->getOption('document'))) {
46 $output->writeln('document does not exist, so exiting');
47 return 1;
50 // get around a large ccda data array
51 ini_set("memory_limit", -1);
53 $GLOBALS['modules_application']->getServiceManager()->build(CarecoordinationTable::class)->importNewPatient($input->getOption('document'));
54 return 0;