Skip to content

Commit

Permalink
Merge pull request #34 from RyanNerd/active-switch
Browse files Browse the repository at this point in the history
Medicine model update
  • Loading branch information
RyanNerd committed Aug 6, 2021
2 parents 60709d2 + 934a67f commit 54eebb5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/Models/Medicine.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#[ApplyModelColumnAttribute('FillDateDay', 'int')] // Day value for when the drug was filled mm/DD/yyyy
#[ApplyModelColumnAttribute('FillDateMonth', 'int')] // Month value when the drug was filled MM/dd/yyyy
#[ApplyModelColumnAttribute('FillDateYear', 'int')] // Year value when the drug was filled mm/dd/YYYY
#[ApplyModelColumnAttribute('Active', 'bool', null, ['NN'], '1')] // Indicates if drug is active, appears in dropdown
#[ApplyModelColumnAttribute('OTC', 'bool', null, null, '0')] // Is set to true (1) if drug is OTC
#[ApplyModelColumnAttribute('Pillbox', 'bool', null, null, '0')] // Is set to true (1) if parent Pillbox record
#[ApplyModelColumnAttribute('Quantity', 'int', 254)] // For Pillbox items (child Medicine records)
Expand All @@ -31,13 +32,15 @@
* @property integer $UserId // User FK
* @property integer $MedicineId // Pillbox self referening FK
* @property string $Drug // Medicine name
* @property string $OtherNames // Other names for the medicine
* @property string $Strength // Medicine strength e.g. 10mg
* @property string $Barcode // Barcode
* @property string $Directions // Directions e.g. Take one tablet at bedtime
* @property string $Notes // Additional information about the drug
* @property integer $FillDateDay // Day value for when the drug was filled mm/DD/yyyy
* @property integer $FillDateMonth // Month value when the drug was filled MM/dd/yyyy
* @property integer $FillDateYear // Year value when the drug was filled mm/dd/YYYY
* @property boolean $Active // Is set to true (1) if the drug should show in the medicine dropdown
* @property boolean $OTC // Is set to true (1) if drug is OTC
* @property boolean $Pillbox // Is set to true (1) if parent Pillbox record
* @property integer $Quantity // For Pillbox items (child Medicine records)
Expand All @@ -61,6 +64,18 @@ final public function setStrengthAttribute(?string $value): void {
}
}

/**
* Override OtherNames field to null if empty string
* @param string|null $value
*/
final public function setOtherNamesAttribute(?string $value): void {
if (empty($value)) {
$this->attributes['OtherNames'] = null;
} else {
$this->attributes['OtherNames'] = $value;
}
}

/**
* Override Barcode field to null if empty string
* @param string|null $value
Expand Down
3 changes: 2 additions & 1 deletion sql/RxChart.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ CREATE TABLE `Medicine` (
`FillDateDay` tinyint DEFAULT NULL,
`FillDateYear` int DEFAULT NULL,
`Notes` varchar(500) DEFAULT NULL,
`Active` tinyint NOT NULL DEFAULT '1',
`OTC` tinyint DEFAULT '0',
`Pillbox` tinyint DEFAULT '0' COMMENT 'When true it indicates that this record is a parent pillbox and If a pillbox the MedicineId MUST be NULL',
`Quantity` tinyint DEFAULT NULL COMMENT 'When a child of pillbox (MedicineId !== null) this indicates how many of the medicine is in the pillbox - typically 1 if populated.',
Expand Down Expand Up @@ -139,4 +140,4 @@ CREATE TABLE `User` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-07-29 4:47:54
-- Dump completed on 2021-08-06 1:03:51

0 comments on commit 54eebb5

Please sign in to comment.