Skip to content

Commit

Permalink
Merge pull request #13 from RyanNerd/add-client-notes
Browse files Browse the repository at this point in the history
Add Notes 📓 to Resident model
  • Loading branch information
RyanNerd committed May 20, 2021
2 parents 023db6a + ef635a2 commit 2dbe5d5
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 73 deletions.
13 changes: 13 additions & 0 deletions app/Models/MedHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
39 changes: 39 additions & 0 deletions app/Models/Medicine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
15 changes: 15 additions & 0 deletions app/Models/Resident.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -37,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;
}
}
}
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
137 changes: 70 additions & 67 deletions sql/RxChart.sql
Original file line number Diff line number Diff line change
@@ -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 */;
Expand All @@ -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 */;

--
Expand All @@ -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 */;

--
Expand All @@ -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 */;

--
Expand All @@ -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 */;
Expand All @@ -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
-- Dump completed on 2021-05-20 2:11:42

0 comments on commit 2dbe5d5

Please sign in to comment.