Showing posts with label drugs. Show all posts
Showing posts with label drugs. Show all posts

Wednesday, November 3, 2010

Controller: Drugs

Create /app/controllers/drugs_controller.php
<?php
class DrugsController extends AppController {
    var $name = 'Drugs';
    var $scaffold;
}
?>
Upload the file and browse to http://drug-ed.com/drugs to verify it works. Again the defined relationship to reminders should cause action links to show. Add a drug.
NameBrand NameIndicationsAdverse ReactionsCounseling PointsNotes
Diclofenac NaCataflamDiclofenac is used to relieve pain, tenderness, swelling, and stiffness caused by osteoarthritis, rheumatoid arthritis, ankylosing spondylitis, painful menstrual periods and pain from other causes.diarrhea, constipation, gas or bloating, headache, dizziness, ringing in the earsNSAIDs such as diclofenac may cause ulcers, bleeding, or holes in the stomach or intestine. People who take nonsteroidal anti-inflammatory drugs (NSAIDs) (other than aspirin) such as diclofenac may have a higher risk of having a heart attack or a stroke than people who do not take these medications.Diclofenac is in the class of Non-Steroidal Anti-Inflammatory Drugs (NSAIDs)

Update Model: Drug

As mentioned previously, to coordinate with the reminder model, add the relationship to the drug model. Edit /app/models/drug.php and add
    var $hasMany = array('Reminder');
Save and upload the file.

Model: Drug

Create /app/models/drug.php
<?php
class User extends AppModel {
    var $name = 'Drug';
}
?>
Save and upload the file.

Database: Setup Drugs Table

Create drugs table
CREATE TABLE IF NOT EXISTS `drugs` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `brand_name` varchar(50) NULL,
  `indications` varchar(255) NULL,
  `adverse_reactions` varchar(255) NULL,
  `counseling_points` varchar(500) NULL,
  `notes` varchar(255) NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;