Globinours/scripts/asm3-clinical.php

21 lines
732 B
PHP

#!/usr/bin/env php
<?php
declare(strict_types=1);
$root = dirname(__DIR__);
foreach (['DB', 'Migrations', 'BackupService', 'AppSettings', 'Asm3Analyzer', 'Asm3ClinicalImporter'] as $s) {
require $root . '/app/Services/' . $s . '.php';
}
$path = $argv[1] ?? null;
$apply = in_array('--apply', $argv, true);
if (!$path) {
fwrite(STDERR, "Usage : php scripts/asm3-clinical.php dump.sql [--apply]\n");
exit(2);
}
if ($apply) {
fwrite(STDERR, 'Tapez IMPORTER MEDICAL : ');
if (trim((string) fgets(STDIN)) !== 'IMPORTER MEDICAL') {
exit(3);
}
}
Migrations::run($root . '/migrations');
echo json_encode(Asm3ClinicalImporter::run($path, DB::pdo(), $apply), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), "\n";