From 4610b2c3943db6b6323aaed01a05af2b3400452e Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 15 May 2021 11:17:30 -0600 Subject: [PATCH 1/3] Add Notes column to Resident table --- app/Models/Resident.php | 2 ++ sql/ResidentNotes.sql | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 sql/ResidentNotes.sql diff --git a/app/Models/Resident.php b/app/Models/Resident.php index 9834192..9aaf827 100644 --- a/app/Models/Resident.php +++ b/app/Models/Resident.php @@ -13,6 +13,7 @@ * @property integer $DOB_YEAR * @property integer $DOB_MONTH * @property integer $DOB_DAY + * @property string $Notes * @property DateTime $Created * @property DateTime $Updated * @property DateTime $deleted_at @@ -29,6 +30,7 @@ class Resident extends ModelBase 'DOB_YEAR' => 'integer', 'DOB_MONTH' => 'tinyint', 'DOB_DAY' => 'tinyint', + 'Notes' => 'string', 'Created' => 'datetime', 'Updated' => 'datetime', 'deleted_at' => 'datetime' diff --git a/sql/ResidentNotes.sql b/sql/ResidentNotes.sql new file mode 100644 index 0000000..9046fcb --- /dev/null +++ b/sql/ResidentNotes.sql @@ -0,0 +1,2 @@ +ALTER TABLE `RxChart`.`Resident` + ADD COLUMN `Notes` VARCHAR(500) NULL DEFAULT NULL AFTER `DOB_DAY`; From 36d247f64357e87c5b537c5a3f1588d76b72a2f6 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 19 May 2021 19:24:57 -0600 Subject: [PATCH 2/3] Add Notes attribute to Resident model - Mutations for nullable fields added to MedHistory, Medicine, and Resident models - composer.json updated to use latest versions: - doctrine/dbal - illuminate/database - php-di/php-di - respect/validatiion - vlucas/phpdotenv - "php": "^8.0" (was ^7.4 || 8.0) --- app/Models/MedHistory.php | 13 +++++++++++++ app/Models/Medicine.php | 39 +++++++++++++++++++++++++++++++++++++++ app/Models/Resident.php | 13 +++++++++++++ composer.json | 12 ++++++------ 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/app/Models/MedHistory.php b/app/Models/MedHistory.php index 2bd34d7..950df54 100644 --- a/app/Models/MedHistory.php +++ b/app/Models/MedHistory.php @@ -35,4 +35,17 @@ class MedHistory extends ModelBase ]; protected $table = 'MedHistory'; + + /** + * Override Notes to null if empty string + * @param string|null $value + */ + public function setNotesAttribute(?string $value) + { + if (empty($value)) { + $this->attributes['Notes'] = null; + } else { + $this->attributes['Notes'] = $value; + } + } } diff --git a/app/Models/Medicine.php b/app/Models/Medicine.php index 1cf2346..73b3598 100644 --- a/app/Models/Medicine.php +++ b/app/Models/Medicine.php @@ -45,4 +45,43 @@ class Medicine extends ModelBase ]; protected $table = 'Medicine'; + + /** + * Override Strength field to null if empty string + * @param string|null $value + */ + public function setStrengthAttribute(?string $value) + { + if (empty($value)) { + $this->attributes['Strength'] = null; + } else { + $this->attributes['Strength'] = $value; + } + } + + /** + * Override Barcode field to null if empty string + * @param string|null $value + */ + public function setBarcodeAttribute(?string $value) + { + if (empty($value)) { + $this->attributes['Barcode'] = null; + } else { + $this->attributes['Barcode'] = $value; + } + } + + /** + * Override Directions field to null if empty string + * @param string|null $value + */ + public function setDirectionsAttribute(?string $value) + { + if (empty($value)) { + $this->attributes['Directions'] = null; + } else { + $this->attributes['Directions'] = $value; + } + } } diff --git a/app/Models/Resident.php b/app/Models/Resident.php index 9aaf827..6c352e3 100644 --- a/app/Models/Resident.php +++ b/app/Models/Resident.php @@ -39,4 +39,17 @@ class Resident extends ModelBase protected $table = 'Resident'; public bool $allowAll = true; + + /** + * Override Notes to null if empty string + * @param string|null $value + */ + public function setNotesAttribute(?string $value) + { + if (empty($value)) { + $this->attributes['Notes'] = null; + } else { + $this->attributes['Notes'] = $value; + } + } } diff --git a/composer.json b/composer.json index 5c3057c..b89dc25 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,17 @@ "sort-packages": true }, "require": { - "php": "^7.4 || 8.0", + "php": "^8.0", "ext-json": "*", "ext-pdo": "*", - "doctrine/dbal": "^3.0.0", - "illuminate/database": "^v8.18.1", + "doctrine/dbal": "^3.1.0", + "illuminate/database": "^v8.40.0", "league/climate": "^3.7.0", - "php-di/php-di": "^6.3.0", - "respect/validation": "^2.1.0", + "php-di/php-di": "^6.3.3", + "respect/validation": "^2.2.3", "slim/psr7": "^1.3.0", "slim/slim": "^4.7.1", - "vlucas/phpdotenv": "^v3.6.7" + "vlucas/phpdotenv": "^v3.6.8" }, "require-dev": { "consolidation/robo": "2.2.2", From ef635a2ee48fe48a1146de1912612b807281f307 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 20 May 2021 02:18:54 -0600 Subject: [PATCH 3/3] Add Notes attribute to Resident model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Mutations 👽 nullable fields added to MedHistory, Medicine, and Resident models - composer.json updated to use latest versions: - doctrine/dbal - illuminate/database - php-di/php-di - respect/validatiion - vlucas/phpdotenv - "php": "^8.0" (was ^7.4 || 8.0) - RxChart.sql updated for new Notes column in the Resident table --- sql/ResidentNotes.sql | 2 - sql/RxChart.sql | 137 +++++++++++++++++++++--------------------- 2 files changed, 70 insertions(+), 69 deletions(-) delete mode 100644 sql/ResidentNotes.sql diff --git a/sql/ResidentNotes.sql b/sql/ResidentNotes.sql deleted file mode 100644 index 9046fcb..0000000 --- a/sql/ResidentNotes.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `RxChart`.`Resident` - ADD COLUMN `Notes` VARCHAR(500) NULL DEFAULT NULL AFTER `DOB_DAY`; diff --git a/sql/RxChart.sql b/sql/RxChart.sql index b08a63b..8110a59 100644 --- a/sql/RxChart.sql +++ b/sql/RxChart.sql @@ -1,8 +1,10 @@ --- MySQL dump 10.13 Distrib 8.0.22, for Linux (x86_64) +CREATE DATABASE IF NOT EXISTS `RxChart` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; +USE `RxChart`; +-- MySQL dump 10.13 Distrib 8.0.25, for Linux (x86_64) -- -- Host: localhost Database: RxChart -- ------------------------------------------------------ --- Server version 8.0.22 +-- Server version 8.0.25 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -23,24 +25,24 @@ DROP TABLE IF EXISTS `MedHistory`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `MedHistory` ( - `Id` int NOT NULL AUTO_INCREMENT, - `ResidentId` int NOT NULL, - `MedicineId` int NOT NULL, - `UserId` int NOT NULL, - `Notes` varchar(500) DEFAULT NULL, - `In` tinyint DEFAULT NULL, - `Out` tinyint DEFAULT NULL, - `Created` timestamp NULL DEFAULT NULL, - `Updated` timestamp NULL DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`Id`), - KEY `fk_MedHistory_Resident_idx` (`ResidentId`), - KEY `fk_MedHistory_Medicine_idx` (`MedicineId`), - KEY `fk_MedHistory_User` (`UserId`), - CONSTRAINT `fk_MedHistory_Medicine` FOREIGN KEY (`MedicineId`) REFERENCES `Medicine` (`Id`), - CONSTRAINT `fk_MedHistory_Resident` FOREIGN KEY (`ResidentId`) REFERENCES `Resident` (`Id`), - CONSTRAINT `fk_MedHistory_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) -) ENGINE=InnoDB AUTO_INCREMENT=41792 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + `Id` int NOT NULL AUTO_INCREMENT, + `ResidentId` int NOT NULL, + `MedicineId` int NOT NULL, + `UserId` int NOT NULL, + `Notes` varchar(500) DEFAULT NULL, + `In` tinyint DEFAULT NULL, + `Out` tinyint DEFAULT NULL, + `Created` timestamp NULL DEFAULT NULL, + `Updated` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`Id`), + KEY `fk_MedHistory_Resident_idx` (`ResidentId`), + KEY `fk_MedHistory_Medicine_idx` (`MedicineId`), + KEY `fk_MedHistory_User` (`UserId`), + CONSTRAINT `fk_MedHistory_Medicine` FOREIGN KEY (`MedicineId`) REFERENCES `Medicine` (`Id`), + CONSTRAINT `fk_MedHistory_Resident` FOREIGN KEY (`ResidentId`) REFERENCES `Resident` (`Id`), + CONSTRAINT `fk_MedHistory_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=61964 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51,28 +53,28 @@ DROP TABLE IF EXISTS `Medicine`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `Medicine` ( - `Id` int NOT NULL AUTO_INCREMENT, - `ResidentId` int DEFAULT NULL, - `UserId` int NOT NULL, - `Drug` varchar(100) NOT NULL, - `Strength` varchar(20) DEFAULT NULL, - `Barcode` varchar(150) DEFAULT NULL, - `Directions` varchar(300) DEFAULT NULL, - `FillDateMonth` tinyint DEFAULT NULL, - `FillDateDay` tinyint DEFAULT NULL, - `FillDateYear` int DEFAULT NULL, - `Notes` varchar(500) DEFAULT NULL, - `OTC` tinyint DEFAULT '0', - `Created` timestamp NULL DEFAULT NULL, - `Updated` timestamp NULL DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`Id`), - KEY `Medicine_Barcode` (`Barcode`), - KEY `fk_Medicine_Resident_idx` (`ResidentId`), - KEY `fk_Medicine_User` (`UserId`), - CONSTRAINT `fk_Medicine_Resident` FOREIGN KEY (`ResidentId`) REFERENCES `Resident` (`Id`), - CONSTRAINT `fk_Medicine_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) -) ENGINE=InnoDB AUTO_INCREMENT=3114 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + `Id` int NOT NULL AUTO_INCREMENT, + `ResidentId` int DEFAULT NULL, + `UserId` int NOT NULL, + `Drug` varchar(100) NOT NULL, + `Strength` varchar(20) DEFAULT NULL, + `Barcode` varchar(150) DEFAULT NULL, + `Directions` varchar(300) DEFAULT NULL, + `FillDateMonth` tinyint DEFAULT NULL, + `FillDateDay` tinyint DEFAULT NULL, + `FillDateYear` int DEFAULT NULL, + `Notes` varchar(500) DEFAULT NULL, + `OTC` tinyint DEFAULT '0', + `Created` timestamp NULL DEFAULT NULL, + `Updated` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`Id`), + KEY `Medicine_Barcode` (`Barcode`), + KEY `fk_Medicine_Resident_idx` (`ResidentId`), + KEY `fk_Medicine_User` (`UserId`), + CONSTRAINT `fk_Medicine_Resident` FOREIGN KEY (`ResidentId`) REFERENCES `Resident` (`Id`), + CONSTRAINT `fk_Medicine_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=3885 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -83,21 +85,22 @@ DROP TABLE IF EXISTS `Resident`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `Resident` ( - `Id` int NOT NULL AUTO_INCREMENT, - `UserId` int NOT NULL, - `LastName` varchar(50) NOT NULL, - `FirstName` varchar(50) NOT NULL, - `DOB_YEAR` int DEFAULT NULL, - `DOB_MONTH` tinyint DEFAULT NULL, - `DOB_DAY` tinyint DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - `Created` timestamp NULL DEFAULT NULL, - `Updated` timestamp NULL DEFAULT NULL, - UNIQUE KEY `Resident_Id_IDX` (`Id`) USING BTREE, - UNIQUE KEY `unique_Resident` (`UserId`,`LastName`,`FirstName`,`DOB_YEAR`,`DOB_MONTH`,`DOB_DAY`), - KEY `fk_Resident_User` (`UserId`), - CONSTRAINT `fk_Resident_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) -) ENGINE=InnoDB AUTO_INCREMENT=704 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + `Id` int NOT NULL AUTO_INCREMENT, + `UserId` int NOT NULL, + `LastName` varchar(50) NOT NULL, + `FirstName` varchar(50) NOT NULL, + `DOB_YEAR` int DEFAULT NULL, + `DOB_MONTH` tinyint DEFAULT NULL, + `DOB_DAY` tinyint DEFAULT NULL, + `Notes` varchar(500) DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `Created` timestamp NULL DEFAULT NULL, + `Updated` timestamp NULL DEFAULT NULL, + UNIQUE KEY `Resident_Id_IDX` (`Id`) USING BTREE, + UNIQUE KEY `unique_Resident` (`UserId`,`LastName`,`FirstName`,`DOB_YEAR`,`DOB_MONTH`,`DOB_DAY`), + KEY `fk_Resident_User` (`UserId`), + CONSTRAINT `fk_Resident_User` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) +) ENGINE=InnoDB AUTO_INCREMENT=865 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -108,15 +111,15 @@ DROP TABLE IF EXISTS `User`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `User` ( - `Id` int NOT NULL AUTO_INCREMENT, - `Organization` varchar(100) DEFAULT NULL, - `PasswordHash` varchar(300) NOT NULL, - `API_KEY` varchar(100) NOT NULL, - `Created` timestamp NULL DEFAULT NULL, - `Updated` timestamp NULL DEFAULT NULL, - `deleted_at` timestamp NULL DEFAULT NULL, - `UserName` varchar(30) DEFAULT NULL, - UNIQUE KEY `User_Id_IDX` (`Id`) USING BTREE + `Id` int NOT NULL AUTO_INCREMENT, + `Organization` varchar(100) DEFAULT NULL, + `PasswordHash` varchar(300) NOT NULL, + `API_KEY` varchar(100) NOT NULL, + `Created` timestamp NULL DEFAULT NULL, + `Updated` timestamp NULL DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `UserName` varchar(30) DEFAULT NULL, + UNIQUE KEY `User_Id_IDX` (`Id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -129,4 +132,4 @@ CREATE TABLE `User` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2021-01-21 6:14:12 \ No newline at end of file +-- Dump completed on 2021-05-20 2:11:42