diff --git a/src/Controller/Api/SubCountiesController.php b/src/Controller/Api/SubCountiesController.php new file mode 100644 index 000000000..b112e6a3a --- /dev/null +++ b/src/Controller/Api/SubCountiesController.php @@ -0,0 +1,148 @@ +Auth->allow('autocomplete'); + } + + public function autocomplete() + { + + $term = $this->request->getQuery('county'); + $subCounties = $this->SubCounties->find() + ->where(['SubCounties.county_id' => $term]) + ->all(); + + if ($subCounties->isEmpty()) { + throw new NotFoundException(__('No sub-counties found for the selected county.')); + } + + // Prepare data for JSON response + $subCountiesList = []; + foreach ($subCounties as $subCounty) { + $subCountiesList[] = [ + 'id' => $subCounty->id, + 'name' => $subCounty->sub_county_name + ]; + } + + $this->set([ + 'codes' => $subCountiesList, + '_serialize' => ['codes'] + ]); + } + /** + * Index method + * + * @return \Cake\Http\Response|null|void Renders view + */ + public function index() + { + $this->paginate = [ + 'contain' => ['Counties'], + ]; + $subCounties = $this->paginate($this->SubCounties); + + $this->set(compact('subCounties')); + } + + /** + * View method + * + * @param string|null $id Sub County id. + * @return \Cake\Http\Response|null|void Renders view + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function view($id = null) + { + $subCounty = $this->SubCounties->get($id, [ + 'contain' => ['Counties', 'Aefis', 'Aggregates', 'Ce2bs', 'Padrs', 'Pqmps', 'Sadrs'], + ]); + + $this->set(compact('subCounty')); + } + + /** + * Add method + * + * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. + */ + public function add() + { + $subCounty = $this->SubCounties->newEmptyEntity(); + if ($this->request->is('post')) { + $subCounty = $this->SubCounties->patchEntity($subCounty, $this->request->getData()); + if ($this->SubCounties->save($subCounty)) { + $this->Flash->success(__('The sub county has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The sub county could not be saved. Please, try again.')); + } + $counties = $this->SubCounties->Counties->find('list', ['limit' => 200])->all(); + $this->set(compact('subCounty', 'counties')); + } + + /** + * Edit method + * + * @param string|null $id Sub County id. + * @return \Cake\Http\Response|null|void Redirects on successful edit, renders view otherwise. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function edit($id = null) + { + $subCounty = $this->SubCounties->get($id, [ + 'contain' => [], + ]); + if ($this->request->is(['patch', 'post', 'put'])) { + $subCounty = $this->SubCounties->patchEntity($subCounty, $this->request->getData()); + if ($this->SubCounties->save($subCounty)) { + $this->Flash->success(__('The sub county has been saved.')); + + return $this->redirect(['action' => 'index']); + } + $this->Flash->error(__('The sub county could not be saved. Please, try again.')); + } + $counties = $this->SubCounties->Counties->find('list', ['limit' => 200])->all(); + $this->set(compact('subCounty', 'counties')); + } + + /** + * Delete method + * + * @param string|null $id Sub County id. + * @return \Cake\Http\Response|null|void Redirects to index. + * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. + */ + public function delete($id = null) + { + $this->request->allowMethod(['post', 'delete']); + $subCounty = $this->SubCounties->get($id); + if ($this->SubCounties->delete($subCounty)) { + $this->Flash->success(__('The sub county has been deleted.')); + } else { + $this->Flash->error(__('The sub county could not be deleted. Please, try again.')); + } + + return $this->redirect(['action' => 'index']); + } +} diff --git a/src/Controller/FacilityCodesController.php b/src/Controller/FacilityCodesController.php index 83fba35bf..105b452c4 100755 --- a/src/Controller/FacilityCodesController.php +++ b/src/Controller/FacilityCodesController.php @@ -44,22 +44,7 @@ public function wards() 'codes' => $codes, '_serialize' => ['codes'] ]); - - // $this->RequestHandler->setContent('json', 'application/json'); - // if (is_numeric($this->request->query['term'])) { - // $coders = $this->FacilityCode->finder($this->request->query['term'], 'N'); - // } else { - // $coders = $this->FacilityCode->finder($this->request->query['term'], 'A'); - // } - // $codes = array(); - // foreach ($coders as $key => $value) { - // $codes[] = array( - // 'value' => $value['FacilityCode']['facility_code'], 'label' => $value['FacilityCode']['facility_name'], 'sub_county' => $value['FacilityCode']['district'], - // 'desc' => $value['FacilityCode']['county'], 'addr' => $value['FacilityCode']['official_address'], 'phone' => $value['FacilityCode']['official_mobile'] - // ); - // } - // $this->set('codes', $codes); - // $this->set('_serialize', 'codes'); + } public function autocomplete() { diff --git a/src/Controller/Reporter/SadrsController.php b/src/Controller/Reporter/SadrsController.php index c76e55bf9..800530ef7 100755 --- a/src/Controller/Reporter/SadrsController.php +++ b/src/Controller/Reporter/SadrsController.php @@ -56,7 +56,7 @@ public function view($id = null) * @return \Cake\Http\Response|null|void Redirects on successful add, renders view otherwise. */ public function add($id = null) - { + { $sadr = $this->Sadrs->newEmptyEntity(); $data = array( 'user_id' => $this->Auth->User('id'), @@ -77,7 +77,7 @@ public function add($id = null) $sadr = $this->Sadrs->patchEntity($sadr, $data); $this->Sadrs->save($sadr); - $this->Flash->success(__('The sadr has been saved.')); + $this->Flash->success(__('The sadr has been saved.')); $this->redirect(array('action' => 'edit', $sadr->id)); } @@ -95,21 +95,130 @@ public function edit($id = null) 'contain' => [], ]); if ($this->request->is(['patch', 'post', 'put'])) { - $sadr = $this->Sadrs->patchEntity($sadr, $this->request->getData()); - if ($this->Sadrs->save($sadr)) { - $this->Flash->success(__('The sadr has been saved.')); - return $this->redirect(['action' => 'index']); + $validate = false; + if (!empty($this->request->getData('submitReport'))) { + $validate = 'first'; + debug("submitting...."); } - $this->Flash->error(__('The sadr could not be saved. Please, try again.')); + // debug($this->request->getData()); + // exit; + $sadr = $this->Sadrs->patchEntity($sadr, $this->request->getData(), [ + 'associated' => ['Attachment'] + ]); + if ($this->Sadrs->save($sadr, array('validate' => $validate, 'deep' => true))) { + if (!empty($this->request->getData('submitReport'))) { + $this->Sadrs->saveField('submitted', 2); + $this->Sadrs->saveField('submitted_date', date("Y-m-d H:i:s")); + //lucian + // if(empty($sadr->reference_no)) { + if (!empty($sadr['reference_no']) && $sadr['reference_no'] == 'new') { + $count = $this->Sadrs->find('count', array( + 'fields' => 'Sadrs.reference_no', + 'conditions' => array( + 'Sadrs.submitted_date BETWEEN ? and ?' => array(date("Y-01-01 00:00:00"), date("Y-m-d H:i:s")), 'Sadrs.reference_no !=' => 'new' + ) + )); + $count++; + $count = ($count < 10) ? "0$count" : $count; + $reference = 'SADR/' . date('Y') . '/' . $count; + $this->Sadrs->saveField('reference_no', $reference); + } + //bokelo + // $sadr = $this->Sadr->read(null, $id); + + // //****************** Send Email and Notifications to Reporter and Managers ***************************** + // $this->loadModel('Message'); + // $html = new HtmlHelper(new ThemeView()); + // $message = $this->Message->find('first', array('conditions' => array('name' => 'reporter_sadr_submit'))); + // $variables = array( + // 'name' => $this->Auth->User('name'), 'reference_no' => $sadr['Sadr']['reference_no'], + // 'reference_link' => $html->link( + // $sadr['Sadr']['reference_no'], + // array('controller' => 'sadrs', 'action' => 'view', $sadr['Sadr']['id'], 'reporter' => true, 'full_base' => true), + // array('escape' => false) + // ), + // 'modified' => $sadr['Sadr']['modified'] + // ); + // $datum = array( + // 'email' => $sadr['Sadr']['reporter_email'], + // 'id' => $id, 'user_id' => $this->Auth->User('id'), 'type' => 'reporter_sadr_submit', 'model' => 'Sadr', + // 'subject' => CakeText::insert($message['Message']['subject'], $variables), + // 'message' => CakeText::insert($message['Message']['content'], $variables) + // ); + + // $this->loadModel('Queue.QueuedTask'); + // $this->QueuedTask->createJob('GenericEmail', $datum); + // $this->QueuedTask->createJob('GenericNotification', $datum); + + + // //Send SMS + // if (!empty($sadr['Sadr']['reporter_phone']) && strlen(substr($sadr['Sadr']['reporter_phone'], -9)) == 9 && is_numeric(substr($sadr['Sadr']['reporter_phone'], -9))) { + // $datum['phone'] = '254' . substr($sadr['Sadr']['reporter_phone'], -9); + // $variables['reference_url'] = Router::url(['controller' => 'sadrs', 'action' => 'view', $sadr['Sadr']['id'], 'reporter' => true, 'full_base' => true]); + // $datum['sms'] = CakeText::insert($message['Message']['sms'], $variables); + // $this->QueuedTask->createJob('GenericSms', $datum); + // } + + // //Notify managers + // $users = $this->Sadr->User->find('all', array( + // 'contain' => array(), + // 'conditions' => array('User.group_id' => 2, 'User.is_active' => '1') + // )); + // foreach ($users as $user) { + // $variables = array( + // 'name' => $user['User']['name'], 'reference_no' => $sadr['Sadr']['reference_no'], + // 'reference_link' => $html->link( + // $sadr['Sadr']['reference_no'], + // array('controller' => 'sadrs', 'action' => 'view', $sadr['Sadr']['id'], 'manager' => true, 'full_base' => true), + // array('escape' => false) + // ), + // 'modified' => $sadr['Sadr']['modified'] + // ); + // $datum = array( + // 'email' => $user['User']['email'], + // 'id' => $id, 'user_id' => $user['User']['id'], 'type' => 'reporter_sadr_submit', 'model' => 'Sadr', + // 'subject' => CakeText::insert($message['Message']['subject'], $variables), + // 'message' => CakeText::insert($message['Message']['content'], $variables) + // ); + + // $this->QueuedTask->createJob('GenericEmail', $datum); + // $this->QueuedTask->createJob('GenericNotification', $datum); + // } + //********************************** END ********************************* + + // If the report is serious sent an alert: + // $serious = $sadr['Sadr']['serious']; + // if ($serious == "Yes") { + // $this->notifyCountyPharmacist($sadr); + // } + + $this->Flash->success(__('The SADR has been submitted to PPB')); + $this->redirect(array('action' => 'view', $sadr->id)); + } + // debug($this->request->data); + $this->Flash->success(__('The SADR has been saved')); + $this->redirect($this->referer()); + } else { + $this->Flash->error(__('The SADR could not be saved. Please review the error(s) and resubmit and try again.')); + } + + // $sadr = $this->Sadrs->patchEntity($sadr, $this->request->getData()); + // if ($this->Sadrs->save($sadr)) { + // $this->Flash->success(__('The sadr has been saved.')); + + // return $this->redirect(['action' => 'index']); + // } + // $this->Flash->error(__('The sadr could not be saved. Please, try again.')); } + $users = $this->Sadrs->Users->find('list', ['limit' => 200])->all(); $pqmps = $this->Sadrs->Pqmps->find('list', ['limit' => 200])->all(); $medications = $this->Sadrs->Medications->find('list', ['limit' => 200])->all(); $counties = $this->Sadrs->Counties->find('list', ['limit' => 200])->all(); - $subCounties = $this->Sadrs->SubCounties->find('list', ['limit' => 200])->all(); + $sub_counties = $this->Sadrs->SubCounties->find('list', ['limit' => 200])->all(); $designations = $this->Sadrs->Designations->find('list', ['limit' => 200])->all(); - $this->set(compact('sadr', 'users', 'pqmps', 'medications', 'counties', 'subCounties', 'designations')); + $this->set(compact('sadr', 'users', 'pqmps', 'medications', 'counties', 'sub_counties', 'designations')); } /** diff --git a/src/Controller/Reporter/UsersController.php b/src/Controller/Reporter/UsersController.php index ef3d74a7b..501c803fc 100755 --- a/src/Controller/Reporter/UsersController.php +++ b/src/Controller/Reporter/UsersController.php @@ -32,7 +32,18 @@ public function dashboard(){ $users=[]; $this->set(compact('users')); - $sadrs=[]; + + $sadrs = $this->Users->Sadrs->find('all', array( + 'limit' => 7, + 'contain' => array(), + 'fields' => array('Sadrs.id', 'Sadrs.user_id', 'Sadrs.created', 'Sadrs.report_title', 'Sadrs.submitted', 'Sadrs.reference_no', 'Sadrs.created', 'Sadrs.serious'), + 'order' => array('Sadrs.created' => 'desc'), + 'conditions' => array( + // only show SADRs that have been not been deleted + 'Sadrs.deleted' => false, + 'Sadrs.user_id' => $this->Auth->User('id') + ), + )); $this->set(compact('sadrs')); $aefis=[]; $this->set(compact('aefis')); diff --git a/src/Model/Table/SadrsTable.php b/src/Model/Table/SadrsTable.php index 81477cac3..a8faf2569 100755 --- a/src/Model/Table/SadrsTable.php +++ b/src/Model/Table/SadrsTable.php @@ -102,6 +102,13 @@ public function initialize(array $config): void $this->hasMany('Sadrs', [ 'foreignKey' => 'sadr_id', ]); + + $this->hasMany('Attachment', [ + 'foreignKey' => 'foreign_key', + 'conditions' => array('Attachment.model' => 'Sadr', 'Attachment.group' => 'attachment'), + ]); + + } /** diff --git a/src/Model/Table/SubCountiesTable.php b/src/Model/Table/SubCountiesTable.php index 48c428932..80da14ed5 100755 --- a/src/Model/Table/SubCountiesTable.php +++ b/src/Model/Table/SubCountiesTable.php @@ -1,4 +1,5 @@ setTable('sub_counties'); - $this->setDisplayField('id'); + $this->setDisplayField('sub_county_name'); $this->setPrimaryKey('id'); $this->addBehavior('Timestamp'); @@ -144,4 +145,11 @@ public function buildRules(RulesChecker $rules): RulesChecker return $rules; } + + public function findByCountyId(Query $query, array $options): Query + { + $term = $options['term'] ?? ''; + // Example: searching by numeric term + return $query->where(['county_id LIKE' => "%$term%"]); + } } diff --git a/src/View/AppView.php b/src/View/AppView.php index 11f894ee6..9c69a0285 100755 --- a/src/View/AppView.php +++ b/src/View/AppView.php @@ -40,8 +40,13 @@ public function initialize(): void if ($this->request->getParam('action') === 'view' or $this->request->getParam('action') === 'followup' or $this->request->getParam('action') === 'download') { $this->loadHelper('Form', ['templates' => 'view_form',]); } else { - // $this->loadHelper('Form', ['templates' => 'app_form',]); - // $this->loadHelper('EdForm', ['templates' => 'app_form',]); + // $this->loadHelper('Form', ['templates' => 'app_form',]); + // $this->loadHelper('Form', [ + // 'templates' => [ + // 'checkboxWrapper' => '
{{input}}{{label}}
', + // 'checkboxContainer' => '{{label}}
{{input}}{{between}}{{after}}
' + // ] + // ]); } // $this->loadHelper('Util'); diff --git a/templates/Reporter/Sadrs/edit.php b/templates/Reporter/Sadrs/edit.php index 47ba2767b..df4214568 100755 --- a/templates/Reporter/Sadrs/edit.php +++ b/templates/Reporter/Sadrs/edit.php @@ -1,124 +1,7 @@ assign('SADR', 'active'); - -/** - * @var \App\View\AppView $this - * @var \App\Model\Entity\Sadr $sadr - * @var string[]|\Cake\Collection\CollectionInterface $users - * @var string[]|\Cake\Collection\CollectionInterface $pqmps - * @var string[]|\Cake\Collection\CollectionInterface $medications - * @var string[]|\Cake\Collection\CollectionInterface $counties - * @var string[]|\Cake\Collection\CollectionInterface $subCounties - * @var string[]|\Cake\Collection\CollectionInterface $designations - */ + $this->assign('SADR', 'active'); +?> + +element('sadr/sadr_edit'); ?> -
- -
-
- Form->create($sadr) ?> -
- - Form->control('sadr_id'); - echo $this->Form->control('user_id', ['options' => $users, 'empty' => true]); - echo $this->Form->control('pqmp_id', ['options' => $pqmps, 'empty' => true]); - echo $this->Form->control('medication_id', ['options' => $medications, 'empty' => true]); - echo $this->Form->control('county_id', ['options' => $counties, 'empty' => true]); - echo $this->Form->control('sub_county_id', ['options' => $subCounties, 'empty' => true]); - echo $this->Form->control('designation_id', ['options' => $designations, 'empty' => true]); - echo $this->Form->control('reference_no'); - echo $this->Form->control('vigiflow_id'); - echo $this->Form->control('report_title'); - echo $this->Form->control('report_type'); - echo $this->Form->control('report_sadr'); - echo $this->Form->control('report_therapeutic'); - echo $this->Form->control('report_misuse'); - echo $this->Form->control('report_off_label'); - echo $this->Form->control('product_category'); - echo $this->Form->control('medicinal_product'); - echo $this->Form->control('blood_products'); - echo $this->Form->control('herbal_product'); - echo $this->Form->control('cosmeceuticals'); - echo $this->Form->control('product_other'); - echo $this->Form->control('product_specify'); - echo $this->Form->control('name_of_institution'); - echo $this->Form->control('institution_code'); - echo $this->Form->control('address'); - echo $this->Form->control('contact'); - echo $this->Form->control('patient_name'); - echo $this->Form->control('ip_no'); - echo $this->Form->control('date_of_birth'); - echo $this->Form->control('age_group'); - echo $this->Form->control('patient_address'); - echo $this->Form->control('ward'); - echo $this->Form->control('gender'); - echo $this->Form->control('known_allergy'); - echo $this->Form->control('known_allergy_specify'); - echo $this->Form->control('pregnant'); - echo $this->Form->control('pregnancy_status'); - echo $this->Form->control('weight'); - echo $this->Form->control('height'); - echo $this->Form->control('diagnosis'); - echo $this->Form->control('reaction'); - echo $this->Form->control('medical_history'); - echo $this->Form->control('date_of_onset_of_reaction'); - echo $this->Form->control('description_of_reaction'); - echo $this->Form->control('reaction_resolve'); - echo $this->Form->control('reaction_reappear'); - echo $this->Form->control('lab_investigation'); - echo $this->Form->control('severity'); - echo $this->Form->control('serious'); - echo $this->Form->control('serious_reason'); - echo $this->Form->control('action_taken'); - echo $this->Form->control('outcome'); - echo $this->Form->control('causality'); - echo $this->Form->control('any_other_comment'); - echo $this->Form->control('reporter_name'); - echo $this->Form->control('reporter_email'); - echo $this->Form->control('reporter_phone'); - echo $this->Form->control('submitted'); - echo $this->Form->control('emails'); - echo $this->Form->control('active'); - echo $this->Form->control('device'); - echo $this->Form->control('deleted'); - echo $this->Form->control('archived'); - echo $this->Form->control('archived_date', ['empty' => true]); - echo $this->Form->control('deleted_date', ['empty' => true]); - echo $this->Form->control('notified'); - echo $this->Form->control('reporter_date', ['empty' => true]); - echo $this->Form->control('person_submitting'); - echo $this->Form->control('reporter_name_diff'); - echo $this->Form->control('reporter_designation_diff'); - echo $this->Form->control('reporter_email_diff'); - echo $this->Form->control('reporter_phone_diff'); - echo $this->Form->control('reporter_date_diff', ['empty' => true]); - echo $this->Form->control('assigned_to'); - echo $this->Form->control('assigned_by'); - echo $this->Form->control('assigned_date', ['empty' => true]); - echo $this->Form->control('vigiflow_message'); - echo $this->Form->control('vigiflow_ref'); - echo $this->Form->control('vigiflow_date', ['empty' => true]); - echo $this->Form->control('webradr_ref'); - echo $this->Form->control('webradr_date', ['empty' => true]); - echo $this->Form->control('submitted_date', ['empty' => true]); - echo $this->Form->control('webradr_message'); - echo $this->Form->control('copied'); - ?> -
- Form->button(__('Submit')) ?> - Form->end() ?> -
-
-
diff --git a/templates/Reporter/Users/dashboard.php b/templates/Reporter/Users/dashboard.php index 30a616959..97d84980c 100755 --- a/templates/Reporter/Users/dashboard.php +++ b/templates/Reporter/Users/dashboard.php @@ -16,21 +16,21 @@ '; foreach ($sadrs as $sadr) { - if ($sadr['Sadr']['submitted'] > 1) { + if ($sadr['submitted'] > 1) { echo "
  • "; echo $this->Html->link( - $sadr['Sadr']['report_title'] . ' (' . $sadr['Sadr']['reference_no'] . ')', - array('controller' => 'sadrs', 'action' => 'view', $sadr['Sadr']['id']), - array('escape' => false, 'class' => 'text-' . ((isset($sadr['Sadr']['serious']) && $sadr['Sadr']['serious'] == 'Yes') ? 'error' : 'success')) + $sadr['report_title'] . ' (' . $sadr['reference_no'] . ')', + array('controller' => 'sadrs', 'action' => 'view', $sadr['id']), + array('escape' => false, 'class' => 'text-' . ((isset($sadr['serious']) && $sadr['serious'] == 'Yes') ? 'error' : 'success')) ); echo " "; - echo $this->Form->postLink(' ', array('controller' => 'sadrs', 'action' => 'followup', $sadr['Sadr']['id']), array('escape' => false), __('Add a followup report?')); + echo $this->Form->postLink(' ', array('controller' => 'sadrs', 'action' => 'followup', $sadr['id']), array('escape' => false), __('Add a followup report?')); echo "
  • "; } else { echo "
  • "; echo $this->Html->link( - $sadr['Sadr']['reference_no'] . ' (unsubmitted)', - array('controller' => 'sadrs', 'action' => 'edit', $sadr['Sadr']['id']), + $sadr['reference_no'] . ' (unsubmitted)', + array('controller' => 'sadrs', 'action' => 'edit', $sadr['id']), array('escape' => false) ); echo "
  • "; @@ -84,21 +84,21 @@ '; foreach ($sadrs as $sadr) { - if ($sadr['Sadr']['submitted'] > 1) { + if ($sadr['submitted'] > 1) { echo "
  • "; echo $this->Html->link( - $sadr['Sadr']['report_title'] . ' (' . $sadr['Sadr']['reference_no'] . ')', - array('controller' => 'sadrs', 'action' => 'view', $sadr['Sadr']['id']), - array('escape' => false, 'class' => 'text-' . ((isset($sadr['Sadr']['serious']) && $sadr['Sadr']['serious'] == 'Yes') ? 'error' : 'success')) + $sadr['report_title'] . ' (' . $sadr['reference_no'] . ')', + array('controller' => 'sadrs', 'action' => 'view', $sadr['id']), + array('escape' => false, 'class' => 'text-' . ((isset($sadr['serious']) && $sadr['serious'] == 'Yes') ? 'error' : 'success')) ); echo " "; - echo $this->Form->postLink(' ', array('controller' => 'sadrs', 'action' => 'followup', $sadr['Sadr']['id']), array('escape' => false), __('Add a followup report?')); + echo $this->Form->postLink(' ', array('controller' => 'sadrs', 'action' => 'followup', $sadr['id']), array('escape' => false), __('Add a followup report?')); echo "
  • "; } else { echo "
  • "; echo $this->Html->link( - $sadr['Sadr']['reference_no'] . ' (unsubmitted)', - array('controller' => 'sadrs', 'action' => 'edit', $sadr['Sadr']['id']), + $sadr['reference_no'] . ' (unsubmitted)', + array('controller' => 'sadrs', 'action' => 'edit', $sadr['id']), array('escape' => false) ); echo "
  • "; @@ -357,13 +357,13 @@ '; foreach ($serious_sadr as $adr) { - if ($adr['Sadr']['submitted'] > 1) { + if ($adr['submitted'] > 1) { echo "
  • "; - $vname = (!empty($adr['Sadr']['report_title'])) ? $adr['Sadr']['report_title'] : $adr['Sadr']['reference_no']; + $vname = (!empty($adr['report_title'])) ? $adr['report_title'] : $adr['reference_no']; echo $this->Html->link( - $vname . ' (' . $adr['Sadr']['reference_no'] . ')', - array('controller' => 'sadrs', 'action' => 'view', $adr['Sadr']['id']), - array('escape' => false, 'class' => 'text-' . ((isset($adr['Sadr']['serious']) && $adr['Sadr']['serious'] == 'Yes') ? 'error' : 'success')) + $vname . ' (' . $adr['reference_no'] . ')', + array('controller' => 'sadrs', 'action' => 'view', $adr['id']), + array('escape' => false, 'class' => 'text-' . ((isset($adr['serious']) && $adr['serious'] == 'Yes') ? 'error' : 'success')) ); echo "
  • "; } diff --git a/templates/element/sadr/sadr_edit.php b/templates/element/sadr/sadr_edit.php new file mode 100644 index 000000000..1d2cc6fd8 --- /dev/null +++ b/templates/element/sadr/sadr_edit.php @@ -0,0 +1,1438 @@ +assign('SADR', 'active'); +echo $this->Html->script('jquery/combobox', array('inline' => false)); +echo $this->Html->script('sadrs', array('inline' => false)); +echo $this->Html->css('sadr', array('inline' => false)); + +?> + + +
    + + Form->create($sadr); + ?> +
    +
    + + Form->control('id', array('type' => 'hidden')); + echo $this->Form->control('report_type', array('type' => 'hidden')); + echo $this->Form->control('reference_no', array('type' => 'hidden')); + ?> + +

    (FOM001/HPT/VMS/SOP/001)

    +
    +
    + Html->image('confidence.png', array('alt' => 'in confidence', 'class' => 'pull-right')); + echo $this->Html->image('coa.png', array('alt' => 'COA', 'style' => 'margin-left: 45%;')); + ?> +
    +

    MINISTRY OF HEALTH

    +
    PHARMACY AND POISONS BOARD
    +
    P.O. Box 27663-00506 NAIROBI
    +
    Tel: +254795743049
    +
    Email: pv@ppb.go.ke
    +
    SUSPECTED ADVERSE DRUG REACTION REPORTING FORM
    +
    +
    +
    +
    + +
    +
    +
    +

    Tip: Fields + marked with * are mandatory

    + Form->control( + 'report_title', + array( + 'label' => array('class' => 'control-label required', 'text' => 'REPORT TITLE*', 'escape' => false), + 'placeholder' => 'this content title..', + 'title' => 'Report Title', + 'data-content' => 'Appropriate title for the report e.g Nevirapine related Rash', + 'after' => '

    e.g Nevirapine related rash

    ', + 'class' => 'span9', + ) + ); + ?> +
    +
    +

    + +

    +
    + +
    +
    +
    + +
    +
    +
    + The report is on *:"; + echo $this->Form->control('report_sadr', array( + 'type' => 'checkbox', + 'label' => array('class' => 'control-label', 'text' => 'Suspected adverse drug reaction'), + )); + + echo $this->Form->control('report_therapeutic', array( + 'type' => 'checkbox', + 'label' => array('class' => 'control-label', 'text' => 'Suspected Therapeutic ineffectiveness'), + )); + + echo $this->Form->control('report_misuse', array( + 'type' => 'checkbox', + 'label' => array('class' => 'control-label', 'text' => 'Suspected misuse, abuse and / or dependence on medicines'), + )); + + echo $this->Form->control('report_off_label', array( + 'type' => 'checkbox', + 'label' => array('class' => 'control-label', 'text' => 'Off-label Use'), + )); + ?> +
    +
    + Product category (Tick appropriate box) *"; + echo $this->Form->control( + 'product_category', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'product_category', + 'before' => '', + 'options' => array('Medicinal product' => 'Medicinal product'), + 'onclick' => '$("#SadrProductSpecify").attr("disabled","disabled")', + ) + ); + echo $this->Form->control( + 'product_category', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'product_category', + 'before' => '', + 'options' => array('Herbal product' => 'Herbal product'), + 'onclick' => '$(".product_specify").attr("disabled","disabled")', + ) + ); + echo $this->Form->control( + 'product_category', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'product_category', + 'before' => '', + 'options' => array('Cosmeceuticals' => 'Cosmeceuticals'), + 'onclick' => '$(".product_specify").attr("disabled","disabled")', + ) + ); + echo $this->Form->control( + 'product_category', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'product_category', + 'before' => '
    ', + 'options' => array('Others' => 'Others'), + 'onclick' => '$(".product_specify").removeAttr("disabled")', + ) + ); + + + ?> +
    + Form->control( + 'product_specify', + array( + 'label' => false, + 'placeholder' => '(If others, specify)', + 'div' => false, + 'between' => false, + 'after' => false, + 'class' => 'product_specify', + 'disabled' => true, + ) + ); + + ?> +
    +
    +
    +
    +
    + Form->control( + 'name_of_institution', + array( + 'label' => array('class' => 'control-label', 'text' => 'NAME OF INSTITUTION'), + 'placeholder' => '', + 'title' => '', + 'data-content' => '', + 'after' => '

    ', + ) + ); + + echo $this->Form->control( + 'address', + array( + 'label' => array('class' => 'control-label', 'text' => 'ADDRESS *', 'escape' => false), + ) + ); + echo $this->Form->control( + 'institution_code', + array( + 'label' => array( + 'class' => 'control-label', + 'text' => 'INSTITUTION CODE' + ), + ) + ); + + ?> +
    + +
    + Form->control( + 'county_id', + array( + 'label' => array( + 'class' => 'control-label required', + 'text' => 'COUNTY *', + 'escape' => false + ), + 'class' => 'county', + 'empty' => true, + 'between' => '
    ', + ) + ); + echo $this->Form->control( + 'sub_county_id', + array( + 'label' => array('class' => 'control-label'), + 'empty' => true, + 'between' => '
    ', + 'class' => 'sub_county' + ) + ); + echo $this->Form->control('contact', array('label' => array('class' => 'control-label', 'text' => 'INSTITUTION CONTACT'),)); + ?> +
    + +
    + +
    +
    PATIENT INFORMATION
    +
    +
    + Form->control( + 'patient_name', + array( + 'label' => array('class' => 'control-label required', 'text' => 'PATIENT\'S INITIALS *', 'escape' => false), + 'after' => '

    e.g E.O.O

    ', + 'class' => 'tooltipper', + ) + ); + echo $this->Form->control('ip_no', array('label' => array('class' => 'control-label', 'text' => 'IP/OP. NO.'),)); + ?> +
    + Form->control( + 'date_of_birth', + array( + 'type' => 'date', + // 'dateFormat' => 'DMY', 'minYear' => date('Y') - 100, 'maxYear' => date('Y'), 'empty' => true, + 'dateFormat' => 'DMY', + 'minYear' => date('Y') - 100, + 'maxYear' => date('Y'), + 'empty' => array('day' => '(choose day)', 'month' => '(choose month)', 'year' => '(choose year)'), + 'label' => array('class' => 'control-label required', 'text' => 'DATE OF BIRTH *', 'escape' => false), + 'title' => 'select beginning of the month if unsure', + 'data-content' => 'If selected, year is mandatory.', + 'after' => ' + clear! +

    If selected, year is mandatory.

    ', + 'class' => 'tooltipper birthdate autosave-ignore ', + //add onclick to clear disable age group + + + ) + ); + + ?> +
    --OR--
    + Form->control( + 'age_group', + array( + 'type' => 'select', + 'empty' => true, + 'options' => array( + 'neonate' => 'neonate [0-1 month]', + 'infant' => 'infant [1 month-1 year]', + 'child' => 'child [1 year - 11 years]', + 'adolescent' => 'adolescent [12-17 years]', + 'adult' => 'adult [18-64 years]', + 'elderly' => 'elderly [>65 years]', + ), + 'label' => array('class' => 'control-label required', 'text' => 'AGE GROUP'), + 'after' => ' + clear!
    ', + ) + ); + //disable age group if birthdate is selected + + + ?> +
    + Form->control( + 'known_allergy', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'known_allergy', + 'before' => '
    +
    ', + 'options' => array('yes' => 'yes'), + 'onclick' => '$(".known").removeAttr("disabled")', + ) + ); + echo $this->Form->control( + 'known_allergy', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'known_allergy', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => '
    ', + 'options' => array('No' => 'No'), + 'onclick' => '$(".known").attr("disabled","disabled")', + ) + ); + + echo $this->Form->control( + 'known_allergy_specify', + array( + 'class' => 'known', + 'label' => false, + 'disabled' => true, + 'placeholder' => 'If yes, specify', + 'after' => '

    (specify)

    ' + ) + ); + ?> +
    + +
    + Form->control( + 'ward', + array( + 'label' => array('class' => 'control-label required', 'text' => 'WARD / CLINIC'), + 'after' => '

    (Name/ Number)

    ' + ) + ); + echo $this->Form->control( + 'patient_address', + array( + 'label' => array('class' => 'control-label required', 'text' => 'PATIENT\'S ADDRESS'), + 'title' => 'Where does the patient reside', + 'data-content' => 'Where does the patient reside', + 'class' => 'tooltipper', + ) + ); + ?>

    Gender

    + Form->control( + 'gender', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'class' => 'gender', + 'hiddenField' => false, + 'error' => false, + 'options' => array('Male' => 'Male'), + ) + ); + echo $this->Form->control( + 'gender', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'class' => 'gender', + 'hiddenField' => false, + 'options' => array('Female' => 'Female'), + ) + ); + echo $this->Form->control( + 'gender', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'gender', + 'options' => array('Unknown' => 'Unknown'), + ) + ); ?> +

    Pregnancy Status

    + Form->control( + 'pregnancy_status', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'pregnancy_status', + 'options' => array('Not Applicable' => 'Not Applicable'), + ) + ); + echo $this->Form->control( + 'pregnancy_status', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'pregnancy_status', + 'before' => '', + 'options' => array('Not pregnant' => 'Not pregnant'), + ) + ); + echo $this->Form->control( + 'pregnancy_status', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'pregnancy_status', + 'options' => array('1st Trimester' => '1st Trimester'), + ) + ); + echo $this->Form->control( + 'pregnancy_status', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'pregnancy_status', + 'options' => array('2nd Trimester' => '2nd Trimester'), + ) + ); + echo $this->Form->control( + 'pregnancy_status', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'pregnancy_status', + 'options' => array('3rd Trimester' => '3rd Trimester'), + ) + ); + + echo $this->Form->control( + 'weight', + array( + 'label' => array('class' => 'control-label required', 'text' => 'WEIGHT (kg)'), + 'between' => '
    ', + 'after' => 'Kg
    ' + ) + ); + echo $this->Form->control( + 'height', + array( + 'label' => array('class' => 'control-label required', 'text' => 'HEIGHT (cm)'), + 'between' => '
    ', + 'after' => 'cm
    ' + ) + ); + + ?> + + + + +
    +
    +
    + Form->control( + 'diagnosis', + array( + 'class' => 'span8', + 'rows' => '2', + 'label' => array('class' => 'control-label required', 'text' => 'DIAGNOSIS'), + 'after' => '

    (What was the patient being treated for before getting the reaction)

    ', + ) + ); + echo $this->Form->control( + 'reaction', + array( + 'label' => array('class' => 'control-label required', 'text' => 'REACTION *', 'escape' => false), + 'placeholder' => 'type here...', + 'title' => 'Reaction', + 'data-content' => 'e.g Nevirapine related Rash', + 'after' => '
    ', + 'class' => 'span5 mapop', + ) + ); + + // echo $this->element('multi/sadr_reactions'); + + echo $this->Form->control( + 'date_of_onset_of_reaction', + array( + 'type' => 'date', + 'dateFormat' => 'DMY', + 'minYear' => date('Y') - 100, + 'maxYear' => date('Y'), + 'empty' => true, + 'label' => array('class' => 'control-label required', 'text' => 'DATE OF ONSET OF REACTION *', 'escape' => false), + 'after' => '

    When did the reaction start

    ', + ) + ); + + echo $this->Form->control( + 'description_of_reaction', + array( + 'class' => 'span8', + 'rows' => '2', + 'label' => array('class' => 'control-label required', 'text' => 'BRIEF DESCRIPTION OF REACTION *', 'escape' => false), + 'after' => '

    Please describe the reaction in terms of symptoms

    ', + ) + ); + + // echo $this->element('multi/sadr_descriptions'); + + echo $this->Form->control( + 'medical_history', + array( + 'class' => 'span8', + 'rows' => '2', + 'label' => array('class' => 'control-label required', 'text' => 'MEDICAL HISTORY'), + 'after' => '

    (Other relevant history including pre-existing medical conditions e.g. allergies, smoking, alcohol use, hepatic/ renal dysfunction etc)

    ', + ) + ); + ?> + + + + +
    + element('multi/list_of_drugs'); + ?> + + element('multi/list_of_medicines'); + ?> +
    +
    +
    Dechallenge/Rechallenge
    + Did the reaction resolve after the drug was stopped or when the dose was reduced?

    "; + + echo $this->Form->control( + 'reaction_resolve', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_resolve', + 'before' => '
    + ', + 'options' => array('Yes' => 'Yes'), + ) + ); + echo $this->Form->control( + 'reaction_resolve', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_resolve', + 'before' => '', + 'options' => array('No' => 'No') + ) + ); + echo $this->Form->control( + 'reaction_resolve', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_resolve', + 'before' => '', + 'options' => array('Unknown' => 'Unknown') + ) + ); + echo $this->Form->control( + 'reaction_resolve', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'reaction_resolve', + 'format' => array('before', 'label', 'between', 'control', 'after', 'error'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'controls required error')), + 'before' => ' + + clear! + +
    ', + 'options' => array('N/A' => 'N/A'), + ) + ); + ?> + Did the reaction reappear after the drug was reintroduced?

    "; + echo $this->Form->control( + 'reaction_reappear', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_reappear', + 'before' => '
    +
    + ', + 'options' => array('Yes' => 'Yes'), + ) + ); + echo $this->Form->control( + 'reaction_reappear', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_reappear', + 'before' => '', + 'options' => array('No' => 'No') + ) + ); + echo $this->Form->control( + 'reaction_reappear', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'reaction_reappear', + 'before' => '', + 'options' => array('Unknown' => 'Unknown') + ) + ); + echo $this->Form->control( + 'reaction_reappear', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'reaction_reappear', + 'format' => array('before', 'label', 'between', 'control', 'after', 'error'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'controls required error')), + 'before' => ' + + clear! + +
    +
    ', + 'options' => array('N/A' => 'N/A'), + ) + ); + ?> +
    + Form->control( + 'lab_investigation', + array( + 'rows' => 2, + 'label' => array('class' => 'control-label required ', 'text' => 'Any lab investigations and results'), + ) + ); + + + ?> +
    +

    Outcome *

    + Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'outcome', + 'before' => '
    ', + 'options' => array('recovered/resolved' => 'Recovered/resolved'), + ) + ); + echo $this->Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'outcome', + 'before' => '', + 'options' => array('recovering/resolving' => 'Recovering/resolving'), + ) + ); + echo $this->Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'outcome', + 'before' => '', + 'options' => array('recovered/resolved with sequelae' => 'Recovered/resolved with sequelae'), + ) + ); + echo $this->Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'outcome', + 'before' => '', + 'options' => array('not recovered/not resolved' => 'Not recovered/not resolved'), + ) + ); + echo $this->Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'outcome', + 'before' => '', + 'options' => array('fatal' => 'Fatal'), + ) + ); + echo $this->Form->control( + 'outcome', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'outcome', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => ' + + clear! +
    ', + 'options' => array('Unknown' => 'Unknown'), + ) + ); + ?> +
    +
    +
    Grading of the reaction /event
    +

    Severity of reaction

    + Html->link( + 'Click to view Severity scale below', + '#assessment1', + array( + 'class' => 'tooltipper', + 'onclick' => '$("#assessment1").click()', + 'id' => 'SadrSeverityT', + 'title' => 'Click here to expand content below' + ) + ); + + echo $this->Form->control( + 'severity', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'severity', + 'before' => '
    + ', + 'options' => array('Mild' => 'Mild'), + ) + ); + echo $this->Form->control( + 'severity', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'severity', + 'before' => '', + 'options' => array('Moderate' => 'Moderate'), + ) + ); + echo $this->Form->control( + 'severity', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'severity', + 'before' => '', + 'options' => array('Severe' => 'Severe'), + ) + ); + echo $this->Form->control( + 'severity', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'severity', + 'before' => '', + 'options' => array('Fatal' => 'Fatal'), + ) + ); + echo $this->Form->control( + 'severity', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'severity', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => ' + + clear! +
    ', + 'options' => array('Unknown' => 'Unknown'), + ) + ); + + + echo $this->Form->control( + 'serious', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'serious', + 'before' => '
    +
    ', + 'options' => array('Yes' => 'Yes'), + ) + ); + echo $this->Form->control( + 'serious', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'serious', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => ' + + + clear! + + +
    +
    ', + 'options' => array('No' => 'No'), + ) + ); + ?> +

    Criteria/reason for seriousness

    + Form->control( + 'serious_reason', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'serious_reason', + 'before' => '
    + ', + 'options' => array('Hospitalization/ Prolonged Hospitalization' => 'Hospitalization/ Prolonged Hospitalization'), + ) + ); + echo $this->Form->control( + 'serious_reason', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'serious_reason', + 'before' => '', + 'options' => array('Disability' => 'Disability') + ) + ); + echo $this->Form->control( + 'serious_reason', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'serious_reason', + 'before' => '', + 'options' => array('Congenital anomality' => 'Congenital anomality') + ) + ); + echo $this->Form->control( + 'serious_reason', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'serious_reason', + 'before' => '', + 'options' => array('Life threatening' => 'Life threatening') + ) + ); + + echo $this->Form->control( + 'serious_reason', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'serious_reason', + 'format' => array('before', 'label', 'between', 'control', 'after', 'error'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'controls required error')), + 'before' => ' + + clear! + +
    ', + 'options' => array('Death' => 'Death'), + ) + ); + ?> + +

    Action taken *

    + Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'action_taken', + 'before' => '
    ', + 'options' => array('Drug withdrawn' => 'Drug withdrawn'), + ) + ); + echo $this->Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'action_taken', + 'before' => '', + 'options' => array('Dose increased' => 'Dose increased'), + ) + ); + echo $this->Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'action_taken', + 'before' => '', + 'options' => array('Dose reduced' => 'Dose reduced'), + ) + ); + echo $this->Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'action_taken', + 'before' => '', + 'options' => array('Dose not changed' => 'Dose not changed'), + ) + ); + echo $this->Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'action_taken', + 'before' => '', + 'options' => array('Not applicable' => 'Not applicable'), + ) + ); + echo $this->Form->control( + 'action_taken', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'action_taken', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => ' + + clear! +
    ', + 'options' => array('Unknown' => 'Unknown'), + ) + ); + ?> + + +
    +
    + + element('help/assessment'); + ?> + +
    +
    + Form->control( + 'any_other_comment', + array( + 'class' => 'span8 ', + 'rows' => '2', + 'label' => array( + 'class' => 'control-label ', + 'text' => 'ANY OTHER COMMENT' + ) + ) + ); + ?> +
    + +
    + +
    + + element('multi/attachments', ['model' => 'Sadr', 'group' => 'attachment', 'examples' => '']); + ?> +
    +
    + Form->control( + 'reporter_name', + array( + 'div' => array('class' => 'control-group required'), + 'label' => array('class' => 'control-label required', 'text' => 'Name of Person Reporting *'), + ) + ); + echo $this->Form->control( + 'reporter_email', + array( + 'type' => 'email', + 'div' => array('class' => 'control-group required'), + 'label' => array('class' => 'control-label required', 'text' => 'E-MAIL ADDRESS *') + ) + ); + + ?> +
    + +
    + Form->control( + 'designation_id', + array('label' => array('class' => 'control-label required', 'text' => 'DESIGNATION' . ' *', 'escape' => false), 'empty' => true) + ); + echo $this->Form->control( + 'reporter_phone', + array( + 'div' => array('class' => 'control-group'), + 'label' => array('class' => 'control-label required', 'text' => 'PHONE NO.' . ' *', 'escape' => false) + ) + ); + + echo $this->Form->control( + 'reporter_date', + array( + 'type' => 'text', + 'class' => 'date-pick-field', + 'label' => array('class' => 'control-label required', 'text' => 'Date *', 'escape' => false), + ) + ); + ?> +
    + +
    + + + + + + + + +
    +
    Is the person submitting different from + reporter? 
    +
    + Form->control( + 'person_submitting', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'error' => false, + 'class' => 'person-submit', + 'before' => '
    + +   ', + 'options' => array('Yes' => 'Yes'), + ) + ); + echo $this->Form->control( + 'person_submitting', + array( + 'type' => 'radio', + 'label' => false, + 'legend' => false, + 'div' => false, + 'hiddenField' => false, + 'class' => 'person-submit', + 'format' => array('before', 'label', 'between', 'control', 'error', 'after'), + 'error' => array('attributes' => array('wrap' => 'p', 'class' => 'required error')), + 'before' => '
    ', + 'options' => array('No' => 'No'), + ) + ); + ?> +
    +
    +
    + Form->control( + 'reporter_name_diff', + array( + 'div' => array('class' => 'control-group required'), + 'class' => 'diff', + 'label' => array('class' => 'control-label required', 'text' => 'Name *', 'escape' => false), + ) + ); + echo $this->Form->control( + 'reporter_email_diff', + array( + 'type' => 'email', + 'div' => array('class' => 'control-group required'), + 'class' => 'diff', + 'label' => array('class' => 'control-label required', 'text' => 'E-MAIL ADDRESS *', 'escape' => false) + ) + ); + ?> +
    + +
    + Form->control( + 'reporter_designation_diff', + array( + 'type' => 'select', + 'options' => $designations, + 'empty' => true, + 'class' => 'diff', + 'label' => array('class' => 'control-label required', 'text' => 'Designation' . ' *'), + 'empty' => true + ) + ); + echo $this->Form->control( + 'reporter_phone_diff', + array( + 'div' => array('class' => 'control-group'), + 'class' => 'diff', + 'label' => array('class' => 'control-label required', 'text' => 'PHONE NO.' . ' *', 'escape' => false) + ) + ); + echo $this->Form->control( + 'reporter_date_diff', + array( + 'type' => 'text', + 'class' => 'date-pick-field diff', + 'label' => array('class' => 'control-label required', 'text' => 'Date'), + ) + ); + ?> +
    + +
    + + + element('help/explanatory'); + ?> + + + + +
    +
    +
    + Form->button( + ' Save Changes', + array( + 'name' => 'saveChanges', + 'escapeTitle' => false, + 'class' => 'btn btn-success mapop', + 'formnovalidate' => 'formnovalidate', + 'id' => 'SadrSaveChanges', + 'title' => 'Save & continue editing', + 'data-content' => 'Save changes to form without submitting it. + The form will still be available for further editing.', + 'div' => false, + ) + ); + ?> +
    +
    + Form->button( + ' Submit', + array( + 'name' => 'submitReport', + 'escapeTitle' => false, + 'onclick' => "return confirm('Are you sure you wish to submit the report?');", + 'class' => 'btn btn-primary btn-block mapop', + 'id' => 'SiteInspectionSubmitReport', + 'value' => 'submit', + 'title' => 'Save and Submit Report', + 'data-content' => 'Submit report for peer review and approval.', + 'div' => false, + ) + ); + + ?> +
    +
    + Html->link( + ' Download PDF', + array('action' => 'view', 'ext' => 'pdf', $this->request->getData('id')), + array( + 'escape' => false, + 'class' => 'btn btn-info btn-block mapop', + 'title' => 'Download PDF', + 'data-content' => 'Download the pdf version of the report', + ) + ); + ?> +
    +
    + Html->link( + ' Cancel', + array('controller' => 'users', 'action' => 'dashboard'), + array('escapeTitle' => false, 'class' => 'btn btn-danger btn-block') + ); + ?> +
    +
    +
    + + Form->end(); ?> +
    + + \ No newline at end of file diff --git a/tests/TestCase/Controller/Api/SubCountiesControllerTest.php b/tests/TestCase/Controller/Api/SubCountiesControllerTest.php new file mode 100644 index 000000000..44e655eea --- /dev/null +++ b/tests/TestCase/Controller/Api/SubCountiesControllerTest.php @@ -0,0 +1,89 @@ + + */ + protected $fixtures = [ + 'app.SubCounties', + 'app.Counties', + 'app.Aefis', + 'app.Aggregates', + 'app.Ce2bs', + 'app.Padrs', + 'app.Pqmps', + 'app.Sadrs', + ]; + + /** + * Test index method + * + * @return void + * @uses \App\Controller\Api\SubCountiesController::index() + */ + public function testIndex(): void + { + $this->markTestIncomplete('Not implemented yet.'); + } + + /** + * Test view method + * + * @return void + * @uses \App\Controller\Api\SubCountiesController::view() + */ + public function testView(): void + { + $this->markTestIncomplete('Not implemented yet.'); + } + + /** + * Test add method + * + * @return void + * @uses \App\Controller\Api\SubCountiesController::add() + */ + public function testAdd(): void + { + $this->markTestIncomplete('Not implemented yet.'); + } + + /** + * Test edit method + * + * @return void + * @uses \App\Controller\Api\SubCountiesController::edit() + */ + public function testEdit(): void + { + $this->markTestIncomplete('Not implemented yet.'); + } + + /** + * Test delete method + * + * @return void + * @uses \App\Controller\Api\SubCountiesController::delete() + */ + public function testDelete(): void + { + $this->markTestIncomplete('Not implemented yet.'); + } +} diff --git a/webroot/js/sadr.js b/webroot/js/sadr.js deleted file mode 100755 index 7032d5c30..000000000 --- a/webroot/js/sadr.js +++ /dev/null @@ -1,180 +0,0 @@ -$(document).ready(function () { - - $("#SadrCountyId").combobox(); - - if ($('#SadrReportType').val() == 'Followup') { - $('#SadrReporterEditForm :input').attr('readonly', 'readonly'); - $('.editable :input').prop('disabled', false).attr('readonly', false); - if ($('#SadrSeriousYes').is(':checked')) { - console.log('Yes was selected initially'); - $('#SadrSeriousNo').prop('disabled', true); // disable the "No" option - $('#clearButton').prop('disabled', true); - } - - // Handle the scale for severity - if ($('#SadrSeverityMild').is(':checked')) { - $('#SadrSeverityMild').prop('disabled', false); - $('#SadrSeverityModerate').prop('disabled', false); - $('#SadrSeveritySevere').prop('disabled', false); - $('#SadrSeverityFatal').prop('disabled', false); - $('#SadrSeverityUnknown').prop('disabled', true); - } - if ($('#SadrSeverityModerate').is(':checked')) { - $('#SadrSeverityMild').prop('disabled', true); - $('#SadrSeverityModerate').prop('disabled', false); - $('#SadrSeveritySevere').prop('disabled', false); - $('#SadrSeverityFatal').prop('disabled', false); - $('#SadrSeverityUnknown').prop('disabled', true); - } - if ($('#SadrSeveritySevere').is(':checked')) { - $('#SadrSeverityMild').prop('disabled', true); - $('#SadrSeverityModerate').prop('disabled', true); - $('#SadrSeveritySevere').prop('disabled', false); - $('#SadrSeverityFatal').prop('disabled', false); - $('#SadrSeverityUnknown').prop('disabled', true); - } - if ($('#SadrSeverityFatal').is(':checked')) { - $('#SadrSeverityMild').prop('disabled', true); - $('#SadrSeverityModerate').prop('disabled', true); - $('#SadrSeveritySevere').prop('disabled', true); - $('#SadrSeverityFatal').prop('disabled', false); - $('#SadrSeverityUnknown').prop('disabled', true); - } - if ($('#SadrSeverityUnknown').is(':checked')) { - $('#SadrSeverityMild').prop('disabled', false); - $('#SadrSeverityModerate').prop('disabled', false); - $('#SadrSeveritySevere').prop('disabled', false); - $('#SadrSeverityFatal').prop('disabled', false); - $('#SadrSeverityUnknown').prop('disabled', false); - } - - - - } - - //Person submitting - $('.person-submit').on('change', function () { - var pilih = $(this).val(); - if (pilih == 'Yes') { - $('.diff:input').prop('disabled', false); - } else { - $('.diff:input').val(''); - $('.diff:input').prop('disabled', true); - } - }); - if ($("#SadrPersonSubmittingNo").is(':checked')) { $('.diff:input').prop('disabled', true); } - - //If Male disable - - - $('input[name="data[Sadr][gender]"]').click(function () { - if ($(this).val() == 'Male') { - $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', this.checked).attr('checked', !this.checked); - } else { - $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', false); - } - }); - if ($('input[name="data[Sadr][gender]"][value="Male"]').is(':checked')) { $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', true).attr('checked', false); } - - //If not serious disable criteria - $('input[name="data[Sadr][serious]"]').click(function () { - if ($(this).val() == 'No') { - $('input[name="data[Sadr][serious_reason]"]').attr('disabled', this.checked).attr('checked', !this.checked); - $('#serious_reason_clear').hide(); - } else { - $('input[name="data[Sadr][serious_reason]"]').attr('disabled', false); - $('#serious_reason_clear').show(); - } - }); - if ($('input[name="data[Sadr][serious]"][value="No"]').is(':checked')) { $('input[name="data[Sadr][serious_reason]"]').attr('disabled', true).attr('checked', false); } - - $("#SadrReaction").autocomplete({ - source: "/meddras/autocomplete.json" - }); - $("#SadrReportTitle").autocomplete({ - source: "/meddras/autocomplete.json" - }); - var cache2 = {}, lastXhr; - $("#SadrInstitutionCode").autocomplete({ - source: function (request, response) { - var term = request.term; - if (term in cache2) { - response(cache2[term]); - return; - } - - lastXhr = $.getJSON("/facility_codes/autocomplete.json", request, function (data, status, xhr) { - cache2[term] = data; - if (xhr === lastXhr) { - response(data); - } - }); - }, - select: function (event, ui) { - $("#SadrNameOfInstitution").val(ui.item.label); - $("#SadrInstitutionCode").val(ui.item.value); - $("#SadrAddress").val(ui.item.addr); - $("#SadrInstitutionContact").val(ui.item.phone); - return false; - } - }); - - var cache3 = {}, lastXhr; - $("#SadrNameOfInstitution").autocomplete({ - source: function (request, response) { - var term = request.term; - if (term in cache3) { - response(cache3[term]); - return; - } - - lastXhr = $.getJSON("/facility_codes/autocomplete.json", request, function (data, status, xhr) { - cache3[term] = data; - if (xhr === lastXhr) { - response(data); - } - }); - }, - select: function (event, ui) { - $("#SadrNameOfInstitution").val(ui.item.label); - $("#SadrInstitutionCode").val(ui.item.value); - $("#SadrAddress").val(ui.item.addr); - $("#SadrInstitutionContact").val(ui.item.phone); - return false; - } - }) - // get the id of Sadr_medicinal_product_ - $('#SadrMedicinalProduct').change(function () { - $('#SadrHerbalProduct').attr("checked", false); - $('#SadrCosmeceuticals').attr("checked", false); - $('#SadrProductOther').attr("checked", false); - - - } - ); - // get the Sadr_herbal_product_ - $('#SadrHerbalProduct').change(function () { - $('#SadrMedicinalProduct').attr("checked", false); - $('#SadrCosmeceuticals').attr("checked", false); - $('#SadrProductOther').attr("checked", false); - } - ); - // Sadr_cosmeceuticals_ - $('#SadrCosmeceuticals').change(function () { - $('#SadrHerbalProduct').attr("checked", false); - $('#SadrMedicinalProduct').attr("checked", false); - $('#SadrProductOther').attr("checked", false); - } - ); - // Sadr_product_other_ - $('#SadrProductOther').change(function () { - $('#SadrHerbalProduct').attr("checked", false); - $('#SadrCosmeceuticals').attr("checked", false); - $('#SadrMedicinalProduct').attr("checked", false); - } - ); - - $("#SadrReactionReaction").autocomplete({ - source: "/meddras/autocomplete.json" - }); -}); diff --git a/webroot/js/sadrs.js b/webroot/js/sadrs.js new file mode 100755 index 000000000..af0f0fcce --- /dev/null +++ b/webroot/js/sadrs.js @@ -0,0 +1,228 @@ +$(document).ready(function () { + if ($('input[name="gender"]:checked').val() === "Male") { + $(".pregnancy_status").attr("disabled", "disabled"); + $(".pregnancy_status").prop("checked", false); + } + + $(".gender").on("click", function () { + var selectedValue = $('input[name="gender"]:checked').val(); + // Disable all elements with the class 'pregnancy_status' + $(".pregnancy_status").attr("disabled", "disabled"); + $(".pregnancy_status").prop("checked", false); + + // Conditionally enable based on selected value + if (selectedValue === "Female" || selectedValue === "Unknown") { + $(".pregnancy_status").removeAttr("disabled"); + } + }); + + $('.county').on('change', function() { + var selectedCounty = $(this).val(); + console.log('selected county **** '+selectedCounty); + var subCountySelect = $('.sub_county'); + + $.ajax({ + url: '/api/subCounties/autocomplete.json', // Replace with your API endpoint + type: 'GET', + data: { county: selectedCounty }, + success: function(response) { + console.log(response); + // Assuming the response is an array of sub-counties + if (Array.isArray(response.codes)) { + $.each(response.codes, function(index, subCounty) { + console.log(subCounty); + subCountySelect.append( + $('').val(subCounty.id).text(subCounty.name) + ); + }); + } + }, + error: function(xhr, status, error) { + console.error('Error fetching sub-counties:', error); + subCountySelect.append(''); + } + }); + + }); + + + $("#SadrCountyId").combobox(); + + if ($("#SadrReportType").val() == "Followup") { + $("#SadrReporterEditForm :input").attr("readonly", "readonly"); + $(".editable :input").prop("disabled", false).attr("readonly", false); + if ($("#SadrSeriousYes").is(":checked")) { + console.log("Yes was selected initially"); + $("#SadrSeriousNo").prop("disabled", true); // disable the "No" option + $("#clearButton").prop("disabled", true); + } + + // Handle the scale for severity + if ($("#SadrSeverityMild").is(":checked")) { + $("#SadrSeverityMild").prop("disabled", false); + $("#SadrSeverityModerate").prop("disabled", false); + $("#SadrSeveritySevere").prop("disabled", false); + $("#SadrSeverityFatal").prop("disabled", false); + $("#SadrSeverityUnknown").prop("disabled", true); + } + if ($("#SadrSeverityModerate").is(":checked")) { + $("#SadrSeverityMild").prop("disabled", true); + $("#SadrSeverityModerate").prop("disabled", false); + $("#SadrSeveritySevere").prop("disabled", false); + $("#SadrSeverityFatal").prop("disabled", false); + $("#SadrSeverityUnknown").prop("disabled", true); + } + if ($("#SadrSeveritySevere").is(":checked")) { + $("#SadrSeverityMild").prop("disabled", true); + $("#SadrSeverityModerate").prop("disabled", true); + $("#SadrSeveritySevere").prop("disabled", false); + $("#SadrSeverityFatal").prop("disabled", false); + $("#SadrSeverityUnknown").prop("disabled", true); + } + if ($("#SadrSeverityFatal").is(":checked")) { + $("#SadrSeverityMild").prop("disabled", true); + $("#SadrSeverityModerate").prop("disabled", true); + $("#SadrSeveritySevere").prop("disabled", true); + $("#SadrSeverityFatal").prop("disabled", false); + $("#SadrSeverityUnknown").prop("disabled", true); + } + if ($("#SadrSeverityUnknown").is(":checked")) { + $("#SadrSeverityMild").prop("disabled", false); + $("#SadrSeverityModerate").prop("disabled", false); + $("#SadrSeveritySevere").prop("disabled", false); + $("#SadrSeverityFatal").prop("disabled", false); + $("#SadrSeverityUnknown").prop("disabled", false); + } + } + + //Person submitting + $(".person-submit").on("change", function () { + var pilih = $(this).val(); + if (pilih == "Yes") { + $(".diff:input").prop("disabled", false); + } else { + $(".diff:input").val(""); + $(".diff:input").prop("disabled", true); + } + }); + if ($("#SadrPersonSubmittingNo").is(":checked")) { + $(".diff:input").prop("disabled", true); + } + + //If Male disable + + // $('input[name="data[Sadr][gender]"]').click(function () { + // if ($(this).val() == 'Male') { + // $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', this.checked).attr('checked', !this.checked); + // } else { + // $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', false); + // } + // }); + // if ($('input[name="data[Sadr][gender]"][value="Male"]').is(':checked')) { $('input[name="data[Sadr][pregnancy_status]"]').attr('disabled', true).attr('checked', false); } + + //If not serious disable criteria + // $('input[name="data[Sadr][serious]"]').click(function () { + // if ($(this).val() == 'No') { + // $('input[name="data[Sadr][serious_reason]"]').attr('disabled', this.checked).attr('checked', !this.checked); + // $('#serious_reason_clear').hide(); + // } else { + // $('input[name="data[Sadr][serious_reason]"]').attr('disabled', false); + // $('#serious_reason_clear').show(); + // } + // }); + // if ($('input[name="data[Sadr][serious]"][value="No"]').is(':checked')) { $('input[name="data[Sadr][serious_reason]"]').attr('disabled', true).attr('checked', false); } + + $("#SadrReaction").autocomplete({ + source: "/meddras/autocomplete.json", + }); + $("#SadrReportTitle").autocomplete({ + source: "/meddras/autocomplete.json", + }); + var cache2 = {}, + lastXhr; + $("#SadrInstitutionCode").autocomplete({ + source: function (request, response) { + var term = request.term; + if (term in cache2) { + response(cache2[term]); + return; + } + + lastXhr = $.getJSON( + "/facility_codes/autocomplete.json", + request, + function (data, status, xhr) { + cache2[term] = data; + if (xhr === lastXhr) { + response(data); + } + } + ); + }, + select: function (event, ui) { + $("#SadrNameOfInstitution").val(ui.item.label); + $("#SadrInstitutionCode").val(ui.item.value); + $("#SadrAddress").val(ui.item.addr); + $("#SadrInstitutionContact").val(ui.item.phone); + return false; + }, + }); + + var cache3 = {}, + lastXhr; + $("#SadrNameOfInstitution").autocomplete({ + source: function (request, response) { + var term = request.term; + if (term in cache3) { + response(cache3[term]); + return; + } + + lastXhr = $.getJSON( + "/facility_codes/autocomplete.json", + request, + function (data, status, xhr) { + cache3[term] = data; + if (xhr === lastXhr) { + response(data); + } + } + ); + }, + select: function (event, ui) { + $("#SadrNameOfInstitution").val(ui.item.label); + $("#SadrInstitutionCode").val(ui.item.value); + $("#SadrAddress").val(ui.item.addr); + $("#SadrInstitutionContact").val(ui.item.phone); + return false; + }, + }); + // get the id of Sadr_medicinal_product_ + $("#SadrMedicinalProduct").change(function () { + $("#SadrHerbalProduct").attr("checked", false); + $("#SadrCosmeceuticals").attr("checked", false); + $("#SadrProductOther").attr("checked", false); + }); + // get the Sadr_herbal_product_ + $("#SadrHerbalProduct").change(function () { + $("#SadrMedicinalProduct").attr("checked", false); + $("#SadrCosmeceuticals").attr("checked", false); + $("#SadrProductOther").attr("checked", false); + }); + // Sadr_cosmeceuticals_ + $("#SadrCosmeceuticals").change(function () { + $("#SadrHerbalProduct").attr("checked", false); + $("#SadrMedicinalProduct").attr("checked", false); + $("#SadrProductOther").attr("checked", false); + }); + // Sadr_product_other_ + $("#SadrProductOther").change(function () { + $("#SadrHerbalProduct").attr("checked", false); + $("#SadrCosmeceuticals").attr("checked", false); + $("#SadrMedicinalProduct").attr("checked", false); + }); + + $("#SadrReactionReaction").autocomplete({ + source: "/meddras/autocomplete.json", + }); +});