Réparer l’ouverture des fiches animales
This commit is contained in:
parent
e3d8bf45fa
commit
72438556cd
4 changed files with 70 additions and 1 deletions
|
|
@ -601,7 +601,7 @@ trait AnimalBrowseActions
|
||||||
$ref_med_administration = $db
|
$ref_med_administration = $db
|
||||||
->query('SELECT id, name, accro FROM ref_med_administration ORDER BY id')
|
->query('SELECT id, name, accro FROM ref_med_administration ORDER BY id')
|
||||||
->fetchAll();
|
->fetchAll();
|
||||||
$vaccines = $db->query('SELECT id, name, code FROM ref_vaccines ORDER BY id')->fetchAll();
|
$vaccines = $db->query('SELECT id, name FROM ref_vaccines ORDER BY id')->fetchAll();
|
||||||
$inventoryBatches = $db
|
$inventoryBatches = $db
|
||||||
->query(
|
->query(
|
||||||
'SELECT b.id,b.batch_number,b.expires_on,b.quantity,p.name,p.unit,p.category,p.reference_id FROM inventory_batches b JOIN inventory_products p ON p.id=b.product_id WHERE b.quantity>0 AND p.active=1 ORDER BY p.category,p.name COLLATE NOCASE,date(b.expires_on)',
|
'SELECT b.id,b.batch_number,b.expires_on,b.quantity,p.name,p.unit,p.category,p.reference_id FROM inventory_batches b JOIN inventory_products p ON p.id=b.product_id WHERE b.quantity>0 AND p.active=1 ORDER BY p.category,p.name COLLATE NOCASE,date(b.expires_on)',
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,24 @@ final class Migrations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Les anciennes bases possédaient déjà le nouvel historique alors
|
||||||
|
// que les installations neuves recevaient encore son premier schéma.
|
||||||
|
if ($name === '090_medication_administration_routes.sql') {
|
||||||
|
$columns = array_column(
|
||||||
|
$db->query('PRAGMA table_info(animal_history)')->fetchAll(PDO::FETCH_ASSOC),
|
||||||
|
'name',
|
||||||
|
);
|
||||||
|
if (!in_array('type', $columns, true)) {
|
||||||
|
$db->exec("ALTER TABLE animal_history ADD COLUMN type TEXT NOT NULL DEFAULT 'history'");
|
||||||
|
}
|
||||||
|
if (!in_array('label', $columns, true)) {
|
||||||
|
$db->exec("ALTER TABLE animal_history ADD COLUMN label TEXT NOT NULL DEFAULT ''");
|
||||||
|
}
|
||||||
|
if (!in_array('details', $columns, true)) {
|
||||||
|
$db->exec('ALTER TABLE animal_history ADD COLUMN details TEXT');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
try {
|
try {
|
||||||
$db->exec($sql);
|
$db->exec($sql);
|
||||||
|
|
|
||||||
33
migrations/090_medication_administration_routes.sql
Normal file
33
migrations/090_medication_administration_routes.sql
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS ref_med_administration (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
name TEXT NOT NULL UNIQUE,
|
||||||
|
accro TEXT,
|
||||||
|
notes TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT OR IGNORE INTO ref_med_administration (name, accro) VALUES
|
||||||
|
('Prise orale', 'PO'),
|
||||||
|
('Sous-cutané', 'SC'),
|
||||||
|
('Intramusculaire', 'IM'),
|
||||||
|
('Intraveineux', 'IV'),
|
||||||
|
('Intra-péritonéal', 'IP'),
|
||||||
|
('Intradermique', 'ID'),
|
||||||
|
('Topique', 'TOP'),
|
||||||
|
('Oculaire', 'OC'),
|
||||||
|
('Auriculaire', 'AUR'),
|
||||||
|
('Intra-nasal', 'IN'),
|
||||||
|
('Rectale', 'PR'),
|
||||||
|
('Sublinguale', 'SL'),
|
||||||
|
('Transdermique', 'TD'),
|
||||||
|
('Inhalation', 'INH');
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS icad_cache (
|
||||||
|
animal_id INTEGER PRIMARY KEY,
|
||||||
|
chip_id TEXT,
|
||||||
|
data_json TEXT,
|
||||||
|
fetched_at TEXT,
|
||||||
|
status TEXT,
|
||||||
|
error_msg TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_icad_cache_chip ON icad_cache(chip_id);
|
||||||
|
|
@ -63,6 +63,24 @@ try {
|
||||||
$actual = (int) $db->query('SELECT COUNT(*) FROM _migrations')->fetchColumn();
|
$actual = (int) $db->query('SELECT COUNT(*) FROM _migrations')->fetchColumn();
|
||||||
$assert($actual === $expected, "$actual/$expected migrations");
|
$assert($actual === $expected, "$actual/$expected migrations");
|
||||||
});
|
});
|
||||||
|
$test("Les voies d’administration des médicaments sont initialisées", function () use ($db, $assert): void {
|
||||||
|
$routes = $db
|
||||||
|
->query('SELECT accro FROM ref_med_administration ORDER BY id')
|
||||||
|
->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
$assert(count($routes) === 14, 'Référentiel des voies incomplet');
|
||||||
|
$assert(in_array('PO', $routes, true) && in_array('SC', $routes, true) && in_array('IV', $routes, true));
|
||||||
|
$historyColumns = array_column(
|
||||||
|
$db->query('PRAGMA table_info(animal_history)')->fetchAll(PDO::FETCH_ASSOC),
|
||||||
|
'name',
|
||||||
|
);
|
||||||
|
foreach (['type', 'label', 'details'] as $column) {
|
||||||
|
$assert(in_array($column, $historyColumns, true), 'Colonne historique absente : ' . $column);
|
||||||
|
}
|
||||||
|
$assert(
|
||||||
|
(int) $db->query("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='icad_cache'")->fetchColumn() === 1,
|
||||||
|
'Cache i-CAD absent',
|
||||||
|
);
|
||||||
|
});
|
||||||
$test('Une installation vierge initialise les médias privés', function () use ($db, $assert): void {
|
$test('Une installation vierge initialise les médias privés', function () use ($db, $assert): void {
|
||||||
$columns = array_column($db->query('PRAGMA table_info(animal_photos)')->fetchAll(PDO::FETCH_ASSOC), 'name');
|
$columns = array_column($db->query('PRAGMA table_info(animal_photos)')->fetchAll(PDO::FETCH_ASSOC), 'name');
|
||||||
$assert(in_array('is_public', $columns, true), 'Colonne is_public absente');
|
$assert(in_array('is_public', $columns, true), 'Colonne is_public absente');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue