예제 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $topupRequest = TopupRequest::find($id);
     $commodities = Commodity::has('receipts')->lists('name', 'id');
     $sections = TestCategory::all()->lists('name', 'id');
     return View::make('topup.edit')->with('topupRequest', $topupRequest)->with('sections', $sections)->with('commodities', $commodities);
 }
 /**
  * Contains the testing sample data for the TopUpController.
  *
  * @return void
  */
 public function setVariables()
 {
     // Initial sample storage data
     $this->input = array('lab_section' => TestCategory::find(1)->id, 'commodity' => Commodity::find(1)->id, 'order_quantity' => '1000', 'remarks' => 'More quantity required');
     // Edition sample data
     $this->inputUpdate = array('lab_section' => TestCategory::find(1)->id, 'commodity' => Commodity::find(1)->id, 'order_quantity' => '1000', 'remarks' => 'More quantity required');
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Text', array(new ReadonlyField('Readonly', 'ReadonlyField'), new TextareaField('Textarea', 'TextareaField - 8 rows', 8), new TextField('Text', 'TextField'), new HtmlEditorField('HTMLField', 'HtmlEditorField'), new EmailField('Email', 'EmailField'), new PasswordField('Password', 'PasswordField'), new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage')));
     $fields->addFieldsToTab('Root.Numeric', array(new NumericField('Number', 'NumericField'), new CurrencyField('Price', 'CurrencyField'), new PhoneNumberField('PhoneNumber', 'PhoneNumberField'), new CreditCardField('CreditCard', 'CreditCardField')));
     $fields->addFieldsToTab('Root.Option', array(new CheckboxField('Checkbox', 'CheckboxField'), new CheckboxSetField('CheckboxSet', 'CheckboxSetField', TestCategory::map()), new DropdownField('DropdownID', 'DropdownField', TestCategory::map()), new GroupedDropdownField('GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())), new ListboxField('ListboxFieldID', 'ListboxField', TestCategory::map(), array(), 3), new OptionsetField('OptionSetID', 'OptionSetField', TestCategory::map())));
     // All these date/time fields generally have issues saving directly in the CMS
     $fields->addFieldsToTab('Root.DateTime', array($calendarDateField = new DateField('CalendarDate', 'DateField with calendar'), new DateField('Date', 'DateField'), $dmyDateField = new DateField('DMYDate', 'DateField with separate fields'), new TimeField('Time', 'TimeField'), $timeFieldDropdown = new TimeField('TimeDropdown', 'TimeField with dropdown'), new DatetimeField('DateTime', 'DateTime'), $dateTimeShowCalendar = new DatetimeField('DateTimeWithCalendar', 'DateTime with calendar')));
     $calendarDateField->setConfig('showcalendar', true);
     $dmyDateField->setConfig('dmyfields', true);
     $timeFieldDropdown->setConfig('showdropdown', true);
     $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
     $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
     $fields->addFieldsToTab('Root.File', array(UploadField::create('File', 'FileUploadField'), UploadField::create('Image', 'ImageUploadField'), UploadField::create('HasManyFiles', 'HasManyFilesUploadField'), UploadField::create('ManyManyFiles', 'ManyManyFilesUploadField')));
     $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
     foreach ($tabs as $tab) {
         $tabObj = $fields->fieldByName($tab);
         foreach ($tabObj->FieldList() as $field) {
             $disabledField = $field->performDisabledTransformation();
             $disabledField->setTitle($disabledField->Title() . ' (disabled)');
             $disabledField->setName($disabledField->getName() . '_disabled');
             $tabObj->insertAfter($disabledField, $field->getName());
             $readonlyField = $field->performReadonlyTransformation();
             $readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
             $readonlyField->setName($readonlyField->getName() . '_readonly');
             $tabObj->insertAfter($readonlyField, $field->getName());
         }
     }
     $fields->addFieldToTab('Root.Text', new TextField('Text_NoLabel', false, 'TextField without label'), 'Text_disabled');
     return $fields;
 }
예제 #4
0
 public function testSlugGeneration()
 {
     $category = new TestCategory();
     $category->setName('Test category');
     $this->assertAttributeEmpty('slug', $category, 'the slug is empty during creation');
     $category->generateSlug();
     $this->assertAttributeEquals('test-category', 'slug', $category, '::generateSlug() generates the slug from the name');
     $this->assertEquals('test-category', $category->getSlug(), '::getSlug() gets the slug');
     $category->setName('Renamed category');
     $category->generateSlug();
     $this->assertAttributeEquals('test-category', 'slug', $category, '::generateSlug() does not replace an existing slug');
     $category->setSlug('custom-slug');
     $this->assertAttributeEquals('custom-slug', 'slug', $category, '::setSlug() sets the slug');
     $category->setSlug('Malformed slug...');
     $this->assertAttributeEquals('malformed-slug', 'slug', $category, 'the slug is always formatted');
 }
 /**
  * Tests the update function in the TestCategoryController
  * @param  void
  * @return void
  */
 public function testDelete()
 {
     Input::replace($this->testCategoryData);
     $testCategory = new TestCategoryController();
     $testCategory->store();
     $testCategorystored = TestCategory::orderBy('id', 'desc')->take(1)->get()->toArray();
     $testCategory->delete($testCategorystored[0]['id']);
     $testCategoriesDeleted = TestCategory::withTrashed()->find($testCategorystored[0]['id']);
     $this->assertNotNull($testCategoriesDeleted->deleted_at);
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab('Root.Tree', array(TreeDropdownField::create('HasOnePage', 'HasOnePage', 'SiteTree'), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)));
     //		$fields->addFieldToTab("Root.Tests.ComplexTableField",
     //			new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     //		$fields->addFieldToTab("Root.Tests.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     return $fields;
 }
예제 #7
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $issue = Issue::find($id);
     $commodities = Commodity::all()->lists('name', 'id');
     $batches = Receipt::all()->lists('batch_no', 'id');
     $users = User::where('id', '!=', Auth::user()->id)->lists('name', 'id');
     $sections = TestCategory::all()->lists('name', 'id');
     //To DO:create function for this
     $available = $issue->topupRequest->commodity->available();
     return View::make('issue.edit')->with('commodities', $commodities)->with('available', $available)->with('users', $users)->with('sections', $sections)->with('issue', $issue)->with('batches', $batches);
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $description = 'This is <strong>bold</strong> help text';
     $fields->addFieldsToTab('Root.Text', array(Object::create('TextField', 'Required', 'Required field'), Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'), Object::create('ReadonlyField', 'Readonly', 'ReadonlyField'), Object::create('TextareaField', 'Textarea', 'TextareaField - 8 rows')->setRows(8), Object::create('TextField', 'Text', 'TextField'), Object::create('HtmlEditorField', 'HTMLField', 'HtmlEditorField'), Object::create('EmailField', 'Email', 'EmailField'), Object::create('PasswordField', 'Password', 'PasswordField')));
     $fields->addFieldsToTab('Root.Numeric', array(Object::create('NumericField', 'Number', 'NumericField'), Object::create('CurrencyField', 'Price', 'CurrencyField'), Object::create('MoneyField', 'Money', 'MoneyField', array('Amount' => 99.98999999999999, 'Currency' => 'EUR')), Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'), Object::create('CreditCardField', 'CreditCard', 'CreditCardField')));
     $fields->addFieldsToTab('Root.Option', array(Object::create('CheckboxField', 'Checkbox', 'CheckboxField'), Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()), Object::create('DropdownField', 'DropdownID', 'DropdownField', TestCategory::map())->setHasEmptyDefault(true), Object::create('GroupedDropdownField', 'GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())), Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map())->setSize(3), Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())->setMultiple(true)->setSize(3), Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()), Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(Object::create('TextField', 'ToggleCompositeTextField1'), Object::create('TextField', 'ToggleCompositeTextField2'), Object::create('DropdownField', 'ToggleCompositeDropdownField', 'ToggleCompositeDropdownField', TestCategory::map()), Object::create('TextField', 'ToggleCompositeTextField3')))));
     // All these date/time fields generally have issues saving directly in the CMS
     $fields->addFieldsToTab('Root.DateTime', array($calendarDateField = Object::create('DateField', 'CalendarDate', 'DateField with calendar'), Object::create('DateField', 'Date', 'DateField'), $dmyDateField = Object::create('DateField', 'DMYDate', 'DateField with separate fields'), Object::create('TimeField', 'Time', 'TimeField'), $timeFieldDropdown = Object::create('TimeField', 'TimeWithDropdown', 'TimeField with dropdown'), Object::create('DatetimeField', 'DateTime', 'DateTime'), $dateTimeShowCalendar = Object::create('DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar')));
     $calendarDateField->setConfig('showcalendar', true);
     $dmyDateField->setConfig('dmyfields', true);
     $timeFieldDropdown->setConfig('showdropdown', true);
     $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
     $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
     $fields->addFieldsToTab('Root.File', array($bla = UploadField::create('File', 'FileUploadField')->setDescription($description)->setConfig('allowedMaxFileNumber', 1)->setConfig('canPreviewFolder', false), UploadField::create('AttachedFile', 'UploadField with canUpload=false')->setDescription($description)->setConfig('canUpload', false), UploadField::create('Image', 'UploadField for image')->setDescription($description), UploadField::create('HasManyFiles', 'UploadField for has_many')->setDescription($description), UploadField::create('ManyManyFiles', 'UploadField for many_many')->setDescription($description)));
     $data = $this->getDefaultData();
     foreach ($fields->dataFields() as $field) {
         $name = $field->getName();
         if (isset($data[$name])) {
             $field->setValue($data[$name]);
         }
     }
     $blacklist = array('DMYDate', 'Required', 'Validated', 'ToggleCompositeField');
     $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File');
     foreach ($tabs as $tab) {
         $tabObj = $fields->fieldByName($tab);
         foreach ($tabObj->FieldList() as $field) {
             $field->setDescription($description);
             // ->addExtraClass('cms-description-tooltip');
             if (in_array($field->getName(), $blacklist)) {
                 continue;
             }
             $disabledField = $field->performDisabledTransformation();
             $disabledField->setTitle($disabledField->Title() . ' (disabled)');
             $disabledField->setName($disabledField->getName() . '_disabled');
             $tabObj->insertAfter($disabledField, $field->getName());
             $readonlyField = $field->performReadonlyTransformation();
             $readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
             $readonlyField->setName($readonlyField->getName() . '_readonly');
             $tabObj->insertAfter($readonlyField, $field->getName());
         }
     }
     $noLabelField = new TextField('Text_NoLabel', false, 'TextField without label');
     $noLabelField->setDescription($description);
     $fields->addFieldToTab('Root.Text', $noLabelField, 'Text_disabled');
     $fields->addFieldToTab('Root.Text', FieldGroup::create(TextField::create('MyFieldGroup1'), TextField::create('MyFieldGroup2'), DropdownField::create('MyFieldGroup3', false, TestCategory::map())));
     $fields->addFieldToTab('Root.Text', FieldGroup::create('MyLabelledFieldGroup', array(TextField::create('MyLabelledFieldGroup1'), TextField::create('MyLabelledFieldGroup2'), DropdownField::create('MyLabelledFieldGroup3', null, TestCategory::map())))->setTitle('My Labelled Field Group'));
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $allFields = array();
     $checkboxFields = array(new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
     $allFields += $checkboxFields;
     $treeFields = array(TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'), TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true));
     $fields->addFieldsToTab('Root.Tree', $treeFields);
     $allFields += $treeFields;
     foreach ($allFields as $field) {
         $field->setDescription('This is <strong>bold</strong> help text')->addExtraClass('cms-help');
         // ->addExtraClass('cms-help cms-help-tooltip');
     }
     return $fields;
 }
예제 #10
0
 public function run()
 {
     /* Users table */
     $usersData = array(array("username" => "administrator", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "kBLIS Administrator", "designation" => "Programmer"), array("username" => "external", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "External System User", "designation" => "Administrator", "image" => "/i/users/user-2.jpg"), array("username" => "lmorena", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "L. Morena", "designation" => "Lab Technologist", "image" => "/i/users/user-3.png"), array("username" => "abumeyang", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "A. Abumeyang", "designation" => "Doctor"));
     foreach ($usersData as $user) {
         $users[] = User::create($user);
     }
     $this->command->info('users seeded');
     /* Specimen Types table */
     $specTypesData = array(array("name" => "Ascitic Tap"), array("name" => "Aspirate"), array("name" => "CSF"), array("name" => "Dried Blood Spot"), array("name" => "High Vaginal Swab"), array("name" => "Nasal Swab"), array("name" => "Plasma"), array("name" => "Plasma EDTA"), array("name" => "Pleural Tap"), array("name" => "Pus Swab"), array("name" => "Rectal Swab"), array("name" => "S***n"), array("name" => "Serum"), array("name" => "Skin"), array("name" => "Sputum"), array("name" => "Stool"), array("name" => "Synovial Fluid"), array("name" => "Throat Swab"), array("name" => "Urethral Smear"), array("name" => "Urine"), array("name" => "Vaginal Smear"), array("name" => "Water"), array("name" => "Whole Blood"));
     foreach ($specTypesData as $specimenType) {
         $specTypes[] = SpecimenType::create($specimenType);
     }
     $this->command->info('specimen_types seeded');
     /* Test Categories table - These map on to the lab sections */
     $test_categories = TestCategory::create(array("name" => "PARASITOLOGY", "description" => ""));
     $lab_section_microbiology = TestCategory::create(array("name" => "MICROBIOLOGY", "description" => ""));
     $this->command->info('test_categories seeded');
     /* Measure Types */
     $measureTypes = array(array("id" => "1", "name" => "Numeric Range"), array("id" => "2", "name" => "Alphanumeric Values"), array("id" => "3", "name" => "Autocomplete"), array("id" => "4", "name" => "Free Text"));
     foreach ($measureTypes as $measureType) {
         MeasureType::create($measureType);
     }
     $this->command->info('measure_types seeded');
     /* Measures table */
     $measureBSforMPS = Measure::create(array("measure_type_id" => "2", "name" => "BS for mps", "unit" => ""));
     $measure1 = Measure::create(array("measure_type_id" => "2", "name" => "Grams stain", "unit" => ""));
     $measure2 = Measure::create(array("measure_type_id" => "2", "name" => "SERUM AMYLASE", "unit" => ""));
     $measure3 = Measure::create(array("measure_type_id" => "2", "name" => "calcium", "unit" => ""));
     $measure4 = Measure::create(array("measure_type_id" => "2", "name" => "SGOT", "unit" => ""));
     $measure5 = Measure::create(array("measure_type_id" => "2", "name" => "Indirect COOMBS test", "unit" => ""));
     $measure6 = Measure::create(array("measure_type_id" => "2", "name" => "Direct COOMBS test", "unit" => ""));
     $measure7 = Measure::create(array("measure_type_id" => "2", "name" => "Du test", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "No mps seen", "interpretation" => "Negative"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "+", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "++", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "+++", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure1->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure1->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure5->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure5->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure6->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure6->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure7->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure7->id, "alphanumeric" => "Negative"));
     $measures = array(array("measure_type_id" => "1", "name" => "URIC ACID", "unit" => "mg/dl"), array("measure_type_id" => "4", "name" => "CSF for biochemistry", "unit" => ""), array("measure_type_id" => "4", "name" => "PSA", "unit" => ""), array("measure_type_id" => "1", "name" => "Total", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Alkaline Phosphate", "unit" => "u/l"), array("measure_type_id" => "1", "name" => "Direct", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Total Proteins", "unit" => ""), array("measure_type_id" => "4", "name" => "LFTS", "unit" => "NULL"), array("measure_type_id" => "1", "name" => "Chloride", "unit" => "mmol/l"), array("measure_type_id" => "1", "name" => "Potassium", "unit" => "mmol/l"), array("measure_type_id" => "1", "name" => "Sodium", "unit" => "mmol/l"), array("measure_type_id" => "4", "name" => "Electrolytes", "unit" => ""), array("measure_type_id" => "1", "name" => "Creatinine", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Urea", "unit" => "mg/dl"), array("measure_type_id" => "4", "name" => "RFTS", "unit" => ""), array("measure_type_id" => "4", "name" => "TFT", "unit" => ""));
     foreach ($measures as $measure) {
         Measure::create($measure);
     }
     $measureGXM = Measure::create(array("measure_type_id" => "4", "name" => "GXM", "unit" => ""));
     $measureBG = Measure::create(array("measure_type_id" => "2", "name" => "Blood Grouping", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "O-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "O+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "A-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "A+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "B-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "B+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "AB-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "AB+"));
     $measureHB = Measure::create(array("measure_type_id" => Measure::NUMERIC, "name" => "HB", "unit" => "g/dL"));
     $measuresUrinalysisData = array(array("measure_type_id" => "4", "name" => "Urine microscopy", "unit" => ""), array("measure_type_id" => "4", "name" => "Pus cells", "unit" => ""), array("measure_type_id" => "4", "name" => "S. haematobium", "unit" => ""), array("measure_type_id" => "4", "name" => "T. vaginalis", "unit" => ""), array("measure_type_id" => "4", "name" => "Yeast cells", "unit" => ""), array("measure_type_id" => "4", "name" => "Red blood cells", "unit" => ""), array("measure_type_id" => "4", "name" => "Bacteria", "unit" => ""), array("measure_type_id" => "4", "name" => "Spermatozoa", "unit" => ""), array("measure_type_id" => "4", "name" => "Epithelial cells", "unit" => ""), array("measure_type_id" => "4", "name" => "ph", "unit" => ""), array("measure_type_id" => "4", "name" => "Urine chemistry", "unit" => ""), array("measure_type_id" => "4", "name" => "Glucose", "unit" => ""), array("measure_type_id" => "4", "name" => "Ketones", "unit" => ""), array("measure_type_id" => "4", "name" => "Proteins", "unit" => ""), array("measure_type_id" => "4", "name" => "Blood", "unit" => ""), array("measure_type_id" => "4", "name" => "Bilirubin", "unit" => ""), array("measure_type_id" => "4", "name" => "Urobilinogen Phenlpyruvic acid", "unit" => ""), array("measure_type_id" => "4", "name" => "pH", "unit" => ""));
     foreach ($measuresUrinalysisData as $measureU) {
         $measuresUrinalysis[] = Measure::create($measureU);
     }
     $measuresWBCData = array(array("measure_type_id" => Measure::NUMERIC, "name" => "WBC", "unit" => "x10³/µL"), array("measure_type_id" => Measure::NUMERIC, "name" => "Lym", "unit" => "L"), array("measure_type_id" => Measure::NUMERIC, "name" => "Mon", "unit" => "*"), array("measure_type_id" => Measure::NUMERIC, "name" => "Neu", "unit" => "*"), array("measure_type_id" => Measure::NUMERIC, "name" => "Eos", "unit" => ""), array("measure_type_id" => Measure::NUMERIC, "name" => "Baso", "unit" => ""));
     foreach ($measuresWBCData as $value) {
         $measuresWBC[] = Measure::create($value);
     }
     $measureRangesWBC = array(array("measure_id" => $measuresWBC[0]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 4, "range_upper" => 11), array("measure_id" => $measuresWBC[1]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 1.5, "range_upper" => 4), array("measure_id" => $measuresWBC[2]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0.1, "range_upper" => 9), array("measure_id" => $measuresWBC[3]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 2.5, "range_upper" => 7), array("measure_id" => $measuresWBC[4]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0, "range_upper" => 6), array("measure_id" => $measuresWBC[5]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0, "range_upper" => 2));
     foreach ($measureRangesWBC as $value) {
         MeasureRange::create($value);
     }
     $this->command->info('measures seeded');
     /* Test Types table */
     $testTypeBS = TestType::create(array("name" => "BS for mps", "test_category_id" => $test_categories->id, "orderable_test" => 1));
     $testTypeStoolCS = TestType::create(array("name" => "Stool for C/S", "test_category_id" => $lab_section_microbiology->id));
     $testTypeGXM = TestType::create(array("name" => "GXM", "test_category_id" => $test_categories->id));
     $testTypeHB = TestType::create(array("name" => "HB", "test_category_id" => $test_categories->id, "orderable_test" => 1));
     $testTypeUrinalysis = TestType::create(array("name" => "Urinalysis", "test_category_id" => $test_categories->id));
     $testTypeWBC = TestType::create(array("name" => "WBC", "test_category_id" => $test_categories->id));
     $this->command->info('test_types seeded');
     /* TestType Measure table */
     TestTypeMeasure::create(array("test_type_id" => $testTypeBS->id, "measure_id" => $measureBSforMPS->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeGXM->id, "measure_id" => $measureGXM->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeGXM->id, "measure_id" => $measureBG->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeHB->id, "measure_id" => $measureHB->id));
     foreach ($measuresUrinalysis as $value) {
         TestTypeMeasure::create(array("test_type_id" => $testTypeUrinalysis->id, "measure_id" => $value->id));
     }
     foreach ($measuresWBC as $value) {
         TestTypeMeasure::create(array("test_type_id" => $testTypeWBC->id, "measure_id" => $value->id));
     }
     $this->command->info('testtype_measures seeded');
     /* testtype_specimentypes table */
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeBS->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeGXM->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[6]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[7]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[12]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeUrinalysis->id, "specimen_type_id" => $specTypes[19]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeUrinalysis->id, "specimen_type_id" => $specTypes[20]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeWBC->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     $this->command->info('testtype_specimentypes seeded');
     /* Patients table */
     $patients_array = array(array("name" => "Jam Felicia", "email" => "*****@*****.**", "patient_number" => "1002", "dob" => "2000-01-01", "gender" => "1", "created_by" => "2"), array("name" => "Emma Wallace", "email" => "*****@*****.**", "patient_number" => "1003", "dob" => "1990-03-01", "gender" => "1", "created_by" => "2"), array("name" => "Jack Tee", "email" => "*****@*****.**", "patient_number" => "1004", "dob" => "1999-12-18", "gender" => "0", "created_by" => "1"), array("name" => "Hu Jintao", "email" => "*****@*****.**", "patient_number" => "1005", "dob" => "1956-10-28", "gender" => "0", "created_by" => "2"), array("name" => "Lance Opiyo", "email" => "*****@*****.**", "patient_number" => "2150", "dob" => "2012-01-01", "gender" => "0", "created_by" => "1"));
     foreach ($patients_array as $pat) {
         $patients[] = Patient::create($pat);
     }
     $this->command->info('patients seeded');
     /* Test Phase table */
     $test_phases = array(array("id" => "1", "name" => "Pre-Analytical"), array("id" => "2", "name" => "Analytical"), array("id" => "3", "name" => "Post-Analytical"));
     foreach ($test_phases as $test_phase) {
         TestPhase::create($test_phase);
     }
     $this->command->info('test_phases seeded');
     /* Test Status table */
     $test_statuses = array(array("id" => "1", "name" => "not-received", "test_phase_id" => "1"), array("id" => "2", "name" => "pending", "test_phase_id" => "1"), array("id" => "3", "name" => "started", "test_phase_id" => "2"), array("id" => "4", "name" => "completed", "test_phase_id" => "3"), array("id" => "5", "name" => "verified", "test_phase_id" => "3"));
     foreach ($test_statuses as $test_status) {
         TestStatus::create($test_status);
     }
     $this->command->info('test_statuses seeded');
     /* Specimen Status table */
     $specimen_statuses = array(array("id" => "1", "name" => "specimen-not-collected"), array("id" => "2", "name" => "specimen-accepted"), array("id" => "3", "name" => "specimen-rejected"));
     foreach ($specimen_statuses as $specimen_status) {
         SpecimenStatus::create($specimen_status);
     }
     $this->command->info('specimen_statuses seeded');
     /* Visits table */
     for ($i = 0; $i < 7; $i++) {
         $visits[] = Visit::create(array("patient_id" => $patients[rand(0, count($patients) - 1)]->id));
     }
     $this->command->info('visits seeded');
     /* Rejection Reasons table */
     $rejection_reasons_array = array(array("reason" => "Poorly labelled"), array("reason" => "Over saturation"), array("reason" => "Insufficient Sample"), array("reason" => "Scattered"), array("reason" => "Clotted Blood"), array("reason" => "Two layered spots"), array("reason" => "Serum rings"), array("reason" => "Scratched"), array("reason" => "Haemolysis"), array("reason" => "Spots that cannot elute"), array("reason" => "Leaking"), array("reason" => "Broken Sample Container"), array("reason" => "Mismatched sample and form labelling"), array("reason" => "Missing Labels on container and tracking form"), array("reason" => "Empty Container"), array("reason" => "Samples without tracking forms"), array("reason" => "Poor transport"), array("reason" => "Lipaemic"), array("reason" => "Wrong container/Anticoagulant"), array("reason" => "Request form without samples"), array("reason" => "Missing collection date on specimen / request form."), array("reason" => "Name and signature of requester missing"), array("reason" => "Mismatched information on request form and specimen container."), array("reason" => "Request form contaminated with specimen"), array("reason" => "Duplicate specimen received"), array("reason" => "Delay between specimen collection and arrival in the laboratory"), array("reason" => "Inappropriate specimen packing"), array("reason" => "Inappropriate specimen for the test"), array("reason" => "Inappropriate test for the clinical condition"), array("reason" => "No Label"), array("reason" => "Leaking"), array("reason" => "No Sample in the Container"), array("reason" => "No Request Form"), array("reason" => "Missing Information Required"));
     foreach ($rejection_reasons_array as $rejection_reason) {
         $rejection_reasons[] = RejectionReason::create($rejection_reason);
     }
     $this->command->info('rejection_reasons seeded');
     /* Specimen table */
     $this->command->info('specimens seeded');
     $now = new DateTime();
     /* Test table */
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::NOT_RECEIVED, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::NOT_RECEIVED, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeHB->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "created_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang"));
     $test_gxm_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Perfect match.", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT12M8S'))->format('Y-m-d H:i:s')));
     $test_hb_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeHB->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Do nothing!", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Genghiz Khan", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT5M23S'))->format('Y-m-d H:i:s')));
     $tests_accepted_started = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::STARTED, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id, "time_started" => $now->format('Y-m-d H:i:s')));
     $tests_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Positive", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Ariel Smith", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT7M34S'))->format('Y-m-d H:i:s')));
     $tests_accepted_verified = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::VERIFIED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Very high concentration of parasites.", "test_status_id" => Test::VERIFIED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "verified_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Genghiz Khan", "time_started" => $now, "time_completed" => $now->add(new DateInterval('PT5M17S'))->format('Y-m-d H:i:s'), "time_verified" => $now->add(new DateInterval('PT112M33S'))->format('Y-m-d H:i:s')));
     $tests_rejected_pending = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id, "time_started" => $now->format('Y-m-d H:i:s')));
     //  WBC Started
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeWBC->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Fred Astaire", "created_by" => $users[rand(0, count($users) - 1)]->id));
     $tests_rejected_started = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "test_status_id" => Test::STARTED, "created_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Bony Em", "time_started" => $now->format('Y-m-d H:i:s')));
     $tests_rejected_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Ed Buttler", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT30M4S'))->format('Y-m-d H:i:s')));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeUrinalysis->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeWBC->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     $test_urinalysis_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeUrinalysis->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Whats this !!!! ###%%% ^ *() /", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT12M8S'))->format('Y-m-d H:i:s'), "external_id" => 596699));
     $this->command->info('tests seeded');
     /* Test Results table */
     $testResults = array(array("test_id" => $tests_accepted_verified->id, "measure_id" => $measureBSforMPS->id, "result" => "+++"), array("test_id" => $tests_accepted_completed->id, "measure_id" => $measureBSforMPS->id, "result" => "++"), array("test_id" => $test_gxm_accepted_completed->id, "measure_id" => $measureGXM->id, "result" => "COMPATIBLE WITH 061832914 B/G A POS.EXPIRY19/8/14"), array("test_id" => $test_gxm_accepted_completed->id, "measure_id" => $measureBG->id, "result" => "A+"), array("test_id" => $test_hb_accepted_completed->id, "measure_id" => $measureHB->id, "result" => "13.7"), array("test_id" => $tests_rejected_completed->id, "measure_id" => $measureBSforMPS->id, "result" => "No mps seen"));
     foreach ($measuresUrinalysis as $key => $measure) {
         $testResults[] = array("test_id" => $test_urinalysis_accepted_completed->id, "measure_id" => $measure->id, "result" => $key . "50");
     }
     foreach ($testResults as $testResult) {
         TestResult::create($testResult);
     }
     $this->command->info('test results seeded');
     /* Permissions table */
     $permissions = array(array("name" => "view_names", "display_name" => "Can view patient names"), array("name" => "manage_patients", "display_name" => "Can add patients"), array("name" => "receive_external_test", "display_name" => "Can receive test requests"), array("name" => "request_test", "display_name" => "Can request new test"), array("name" => "accept_test_specimen", "display_name" => "Can accept test specimen"), array("name" => "reject_test_specimen", "display_name" => "Can reject test specimen"), array("name" => "change_test_specimen", "display_name" => "Can change test specimen"), array("name" => "start_test", "display_name" => "Can start tests"), array("name" => "enter_test_results", "display_name" => "Can enter tests results"), array("name" => "edit_test_results", "display_name" => "Can edit test results"), array("name" => "verify_test_results", "display_name" => "Can verify test results"), array("name" => "send_results_to_external_system", "display_name" => "Can send test results to external systems"), array("name" => "refer_specimens", "display_name" => "Can refer specimens"), array("name" => "manage_users", "display_name" => "Can manage users"), array("name" => "manage_test_catalog", "display_name" => "Can manage test catalog"), array("name" => "manage_lab_configurations", "display_name" => "Can manage lab configurations"), array("name" => "view_reports", "display_name" => "Can view reports"), array("name" => "manage_inventory", "display_name" => "Can manage inventory"), array("name" => "request_topup", "display_name" => "Can request top-up"), array("name" => "manage_qc", "display_name" => "Can manage Quality Control"));
     foreach ($permissions as $permission) {
         Permission::create($permission);
     }
     $this->command->info('Permissions table seeded');
     /* Roles table */
     $roles = array(array("name" => "Superadmin"), array("name" => "Technologist"), array("name" => "Receptionist"));
     foreach ($roles as $role) {
         Role::create($role);
     }
     $this->command->info('Roles table seeded');
     $user1 = User::find(1);
     $role1 = Role::find(1);
     $permissions = Permission::all();
     //Assign all permissions to role administrator
     foreach ($permissions as $permission) {
         $role1->attachPermission($permission);
     }
     //Assign role Administrator to user 1 administrator
     $user1->attachRole($role1);
     /* Instruments table */
     $instrumentsData = array("name" => "Celltac F Mek 8222", "description" => "Automatic analyzer with 22 parameters and WBC 5 part diff Hematology Analyzer", "driver_name" => "KBLIS\\Plugins\\CelltacFMachine", "ip" => "192.168.1.12", "hostname" => "HEMASERVER");
     $instrument = Instrument::create($instrumentsData);
     $instrument->testTypes()->attach(array($testTypeWBC->id));
     $this->command->info('Instruments table seeded');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596699,"parentLabNo":0,"requestingClinician":"frankenstein Dr",
     "investigation":"Urinalysis","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596700,"parentLabNo":596699,"requestingClinician":"frankenstein Dr",
     "investigation":"Urine microscopy","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596701,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Pus cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596702,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"S. haematobium","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596703,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"T. vaginalis","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596704,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Yeast cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596705,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Red blood cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596706,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Bacteria","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596707,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Spermatozoa","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596708,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Epithelial cells","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596709,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"ph","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596710,"parentLabNo":596699,"requestingClinician":"frankenstein Dr",
     "investigation":"Urine chemistry","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596711,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Glucose","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596712,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Ketones","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596713,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Proteins","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596714,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Blood","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596715,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Bilirubin","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596716,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Urobilinogen Phenlpyruvic acid","requestDate":"2014-10-14 10:20:37","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596717,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"pH","requestDate":"2014-10-14 10:20:37","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     for ($i = 0; $i < count($labRequestUrinalysis); $i++) {
         $dumper = new ExternalDump();
         $dumper->lab_no = $labRequestUrinalysis[$i]->labNo;
         $dumper->parent_lab_no = $labRequestUrinalysis[$i]->parentLabNo;
         $dumper->test_id = $i == 0 ? $test_urinalysis_accepted_completed->id : null;
         $dumper->requesting_clinician = $labRequestUrinalysis[$i]->requestingClinician;
         $dumper->investigation = $labRequestUrinalysis[$i]->investigation;
         $dumper->provisional_diagnosis = '';
         $dumper->request_date = $labRequestUrinalysis[$i]->requestDate;
         $dumper->order_stage = $labRequestUrinalysis[$i]->orderStage;
         $dumper->patient_visit_number = $labRequestUrinalysis[$i]->patientVisitNumber;
         $dumper->patient_id = $labRequestUrinalysis[$i]->patient->id;
         $dumper->full_name = $labRequestUrinalysis[$i]->patient->fullName;
         $dumper->dob = $labRequestUrinalysis[$i]->patient->dateOfBirth;
         $dumper->gender = $labRequestUrinalysis[$i]->patient->gender;
         $dumper->address = $labRequestUrinalysis[$i]->address->address;
         $dumper->postal_code = '';
         $dumper->phone_number = $labRequestUrinalysis[$i]->address->phoneNumber;
         $dumper->city = $labRequestUrinalysis[$i]->address->city;
         $dumper->cost = $labRequestUrinalysis[$i]->cost;
         $dumper->receipt_number = $labRequestUrinalysis[$i]->receiptNumber;
         $dumper->receipt_type = $labRequestUrinalysis[$i]->receiptType;
         $dumper->waiver_no = '';
         $dumper->system_id = "sanitas";
         $dumper->save();
     }
     $this->command->info('ExternalDump table seeded');
     //  Begin seed for prevalence rates report
     /* Test Categories table - These map on to the lab sections */
     $lab_section_hematology = TestCategory::create(array("name" => "HEMATOLOGY", "description" => ""));
     $lab_section_serology = TestCategory::create(array("name" => "SEROLOGY", "description" => ""));
     $lab_section_trans = TestCategory::create(array("name" => "BLOOD TRANSFUSION", "description" => ""));
     $this->command->info('Lab Sections seeded');
     /* Test Types for prevalence */
     $test_types_salmonella = TestType::create(array("name" => "Salmonella Antigen Test", "test_category_id" => $test_categories->id));
     $test_types_direct = TestType::create(array("name" => "Direct COOMBS Test", "test_category_id" => $lab_section_trans->id));
     $test_types_du = TestType::create(array("name" => "DU Test", "test_category_id" => $lab_section_trans->id));
     $test_types_sickling = TestType::create(array("name" => "Sickling Test", "test_category_id" => $lab_section_hematology->id));
     $test_types_borrelia = TestType::create(array("name" => "Borrelia", "test_category_id" => $test_categories->id));
     $test_types_vdrl = TestType::create(array("name" => "VDRL", "test_category_id" => $lab_section_serology->id));
     $test_types_pregnancy = TestType::create(array("name" => "Pregnancy Test", "test_category_id" => $lab_section_serology->id));
     $test_types_brucella = TestType::create(array("name" => "Brucella", "test_category_id" => $lab_section_serology->id));
     $test_types_pylori = TestType::create(array("name" => "H. Pylori", "test_category_id" => $lab_section_serology->id));
     $this->command->info('Test Types seeded');
     /* Test Types and specimen types relationship for prevalence */
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_salmonella->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_direct->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_du->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_sickling->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_borrelia->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_vdrl->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_pregnancy->id, "20"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_brucella->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_pylori->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($testTypeStoolCS->id, "16"));
     $this->command->info('TestTypes/SpecimenTypes seeded');
     /*New measures for prevalence*/
     $measure_salmonella = Measure::create(array("measure_type_id" => "2", "name" => "Salmonella Antigen Test", "unit" => ""));
     $measure_direct = Measure::create(array("measure_type_id" => "2", "name" => "Direct COOMBS Test", "unit" => ""));
     $measure_du = Measure::create(array("measure_type_id" => "2", "name" => "Du Test", "unit" => ""));
     $measure_sickling = Measure::create(array("measure_type_id" => "2", "name" => "Sickling Test", "unit" => ""));
     $measure_borrelia = Measure::create(array("measure_type_id" => "2", "name" => "Borrelia", "unit" => ""));
     $measure_vdrl = Measure::create(array("measure_type_id" => "2", "name" => "VDRL", "unit" => ""));
     $measure_pregnancy = Measure::create(array("measure_type_id" => "2", "name" => "Pregnancy Test", "unit" => ""));
     $measure_brucella = Measure::create(array("measure_type_id" => "2", "name" => "Brucella", "unit" => ""));
     $measure_pylori = Measure::create(array("measure_type_id" => "2", "name" => "H. Pylori", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measure_salmonella->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_salmonella->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_direct->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_direct->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_du->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_du->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_sickling->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_sickling->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_borrelia->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_borrelia->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_vdrl->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_vdrl->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_pregnancy->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_pregnancy->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_brucella->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_brucella->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_pylori->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_pylori->id, "alphanumeric" => "Negative"));
     $this->command->info('Measures seeded again');
     /* TestType Measure for prevalence */
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_salmonella->id, "measure_id" => $measure_salmonella->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_direct->id, "measure_id" => $measure_direct->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_du->id, "measure_id" => $measure_du->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_sickling->id, "measure_id" => $measure_sickling->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_borrelia->id, "measure_id" => $measure_borrelia->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_vdrl->id, "measure_id" => $measure_vdrl->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_pregnancy->id, "measure_id" => $measure_pregnancy->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_brucella->id, "measure_id" => $measure_brucella->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_pylori->id, "measure_id" => $measure_pylori->id));
     $this->command->info('Test Type Measures seeded again');
     /*  Tests for prevalence rates  */
     $tests_completed_one = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_salmonella->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-07-23 15:16:15", "time_started" => "2014-07-23 16:07:15", "time_completed" => "2014-07-23 16:17:19"));
     $tests_completed_two = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_direct->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-07-26 10:16:15", "time_started" => "2014-07-26 13:27:15", "time_completed" => "2014-07-26 13:57:01"));
     $tests_completed_three = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_du->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-13 09:16:15", "time_started" => "2014-08-13 10:07:15", "time_completed" => "2014-08-13 10:18:11"));
     $tests_completed_four = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_sickling->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-16 09:06:53", "time_started" => "2014-08-16 09:09:15", "time_completed" => "2014-08-16 09:23:37"));
     $tests_completed_five = Test::create(array("visit_id" => "5", "test_type_id" => $test_types_borrelia->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-23 10:16:15", "time_started" => "2014-08-23 11:54:39", "time_completed" => "2014-08-23 12:07:18"));
     $tests_completed_six = Test::create(array("visit_id" => "6", "test_type_id" => $test_types_vdrl->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-09-07 07:23:15", "time_started" => "2014-09-07 08:07:20", "time_completed" => "2014-09-07 08:41:13"));
     $tests_completed_seven = Test::create(array("visit_id" => "7", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-03 11:52:15", "time_started" => "2014-10-03 12:31:04", "time_completed" => "2014-10-03 12:45:18"));
     $tests_completed_eight = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_brucella->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-15 17:01:15", "time_started" => "2014-10-15 17:05:24", "time_completed" => "2014-10-15 18:07:15"));
     $tests_completed_nine = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_pylori->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-23 16:06:15", "time_started" => "2014-10-23 16:07:15", "time_completed" => "2014-10-23 16:39:02"));
     $tests_completed_ten = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_salmonella->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-21 19:16:15", "time_started" => "2014-10-21 19:17:15", "time_completed" => "2014-10-21 19:52:40"));
     $tests_verified_one = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_direct->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-07-21 19:16:15", "time_started" => "2014-07-21 19:17:15", "time_completed" => "2014-07-21 19:52:40", "time_verified" => "2014-07-21 19:53:48"));
     $tests_verified_two = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_du->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-08-21 19:16:15", "time_started" => "2014-08-21 19:17:15", "time_completed" => "2014-08-21 19:52:40", "time_verified" => "2014-08-21 19:53:48"));
     $tests_verified_three = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_sickling->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-08-26 19:16:15", "time_started" => "2014-08-26 19:17:15", "time_completed" => "2014-08-26 19:52:40", "time_verified" => "2014-08-26 19:53:48"));
     $tests_verified_four = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_borrelia->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-21 19:16:15", "time_started" => "2014-09-21 19:17:15", "time_completed" => "2014-09-21 19:52:40", "time_verified" => "2014-09-21 19:53:48"));
     $tests_verified_five = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_vdrl->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-22 19:16:15", "time_started" => "2014-09-22 19:17:15", "time_completed" => "2014-09-22 19:52:40", "time_verified" => "2014-09-22 19:53:48"));
     $tests_verified_six = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-23 19:16:15", "time_started" => "2014-09-23 19:17:15", "time_completed" => "2014-09-23 19:52:40", "time_verified" => "2014-09-23 19:53:48"));
     $tests_verified_seven = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_brucella->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-27 19:16:15", "time_started" => "2014-09-27 19:17:15", "time_completed" => "2014-09-27 19:52:40", "time_verified" => "2014-09-27 19:53:48"));
     $tests_verified_eight = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_pylori->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-22 19:16:15", "time_started" => "2014-10-22 19:17:15", "time_completed" => "2014-10-22 19:52:40", "time_verified" => "2014-10-22 19:53:48"));
     $tests_verified_nine = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-17 19:16:15", "time_started" => "2014-10-17 19:17:15", "time_completed" => "2014-10-17 19:52:40", "time_verified" => "2014-10-17 19:53:48"));
     $tests_verified_ten = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-02 19:16:15", "time_started" => "2014-10-02 19:17:15", "time_completed" => "2014-10-02 19:52:40", "time_verified" => "2014-10-02 19:53:48"));
     $this->command->info('Tests seeded again');
     //  Test results for prevalence
     $results = array(array("test_id" => $tests_completed_one->id, "measure_id" => $measure_salmonella->id, "result" => "Positive"), array("test_id" => $tests_completed_two->id, "measure_id" => $measure_direct->id, "result" => "Positive"), array("test_id" => $tests_completed_three->id, "measure_id" => $measure_du->id, "result" => "Positive"), array("test_id" => $tests_completed_four->id, "measure_id" => $measure_sickling->id, "result" => "Positive"), array("test_id" => $tests_completed_five->id, "measure_id" => $measure_borrelia->id, "result" => "Positive"), array("test_id" => $tests_completed_six->id, "measure_id" => $measure_vdrl->id, "result" => "Positive"), array("test_id" => $tests_completed_seven->id, "measure_id" => $measure_pregnancy->id, "result" => "Positive"), array("test_id" => $tests_completed_eight->id, "measure_id" => $measure_brucella->id, "result" => "Positive"), array("test_id" => $tests_completed_nine->id, "measure_id" => $measure_pylori->id, "result" => "Positive"), array("test_id" => $tests_completed_ten->id, "measure_id" => $measure_salmonella->id, "result" => "Positive"), array("test_id" => $tests_verified_one->id, "measure_id" => $measure_direct->id, "result" => "Negative"), array("test_id" => $tests_verified_two->id, "measure_id" => $measure_du->id, "result" => "Positive"), array("test_id" => $tests_verified_three->id, "measure_id" => $measure_sickling->id, "result" => "Positive"), array("test_id" => $tests_verified_four->id, "measure_id" => $measure_borrelia->id, "result" => "Negative"), array("test_id" => $tests_verified_five->id, "measure_id" => $measure_vdrl->id, "result" => "Negative"), array("test_id" => $tests_verified_six->id, "measure_id" => $measure_pregnancy->id, "result" => "Negative"), array("test_id" => $tests_verified_seven->id, "measure_id" => $measure_brucella->id, "result" => "Positive"), array("test_id" => $tests_verified_eight->id, "measure_id" => $measure_pylori->id, "result" => "Positive"), array("test_id" => $tests_verified_nine->id, "measure_id" => $measure_pregnancy->id, "result" => "Negative"), array("test_id" => $tests_verified_ten->id, "measure_id" => $measure_pregnancy->id, "result" => "Positive"));
     foreach ($results as $result) {
         TestResult::create($result);
     }
     $this->command->info('Test results seeded again');
     //  End prevalence rates seed
     //Seed for facilities
     $facilitiesSeed = array(array('name' => "WALTER REED"), array('name' => "AGA KHAN UNIVERSITY HOSPITAL"), array('name' => "TEL AVIV GENERAL HOSPITAL"), array('name' => "GK PRISON DISPENSARY"), array('name' => "KEMRI ALUPE"), array('name' => "AMPATH"));
     foreach ($facilitiesSeed as $facility) {
         Facility::create($facility);
     }
     $this->command->info('Facilities table seeded');
     //Seed for suppliers
     $supplier = Supplier::create(array("name" => "UNICEF", "phone_no" => "0775112233", "email" => "*****@*****.**", "physical_address" => "un-hqtr"));
     $this->command->info('Suppliers table seeded');
     //Seed for metrics
     $metric = Metric::create(array("name" => "mg", "description" => "milligram"));
     $this->command->info('Metrics table seeded');
     //Seed for commodities
     $commodity = Commodity::create(array("name" => "Ampicillin", "description" => "Capsule 250mg", "metric_id" => $metric->id, "unit_price" => "500", "item_code" => "no clue", "storage_req" => "no clue", "min_level" => "100000", "max_level" => "400000"));
     $this->command->info('Commodities table seeded');
     //Seed for receipts
     $receipt = Receipt::create(array("commodity_id" => $commodity->id, "supplier_id" => $supplier->id, "quantity" => "130000", "batch_no" => "002720", "expiry_date" => "2018-10-14", "user_id" => "1"));
     $this->command->info('Receipts table seeded');
     //Seed for Top Up Request
     $topUpRequest = TopupRequest::create(array("commodity_id" => $commodity->id, "test_category_id" => 1, "order_quantity" => "1500", "user_id" => 1, "remarks" => "-"));
     $this->command->info('Top Up Requests table seeded');
     //Seed for Issues
     Issue::create(array("receipt_id" => $receipt->id, "topup_request_id" => $topUpRequest->id, "quantity_issued" => "1700", "issued_to" => 1, "user_id" => 1, "remarks" => "-"));
     $this->command->info('Issues table seeded');
     //Seed for diseases
     $malaria = Disease::create(array('name' => "Malaria"));
     $typhoid = Disease::create(array('name' => "Typhoid"));
     $dysentry = Disease::create(array('name' => "Shigella Dysentry"));
     $this->command->info("Dieases table seeded");
     $reportDiseases = array(array("test_type_id" => $testTypeBS->id, "disease_id" => $malaria->id), array("test_type_id" => $test_types_salmonella->id, "disease_id" => $typhoid->id), array("test_type_id" => $testTypeStoolCS->id, "disease_id" => $dysentry->id));
     foreach ($reportDiseases as $reportDisease) {
         ReportDisease::create($reportDisease);
     }
     $this->command->info("Report Disease table seeded");
     //Seeding for QC
     $lots = array(array('number' => '0001', 'description' => 'First lot', 'expiry' => date('Y-m-d H:i:s', strtotime("+6 months")), 'instrument_id' => 1), array('number' => '0002', 'description' => 'Second lot', 'expiry' => date('Y-m-d H:i:s', strtotime("+7 months")), 'instrument_id' => 1));
     foreach ($lots as $lot) {
         $lot = Lot::create($lot);
     }
     $this->command->info("Lot table seeded");
     //Control seeding
     $controls = array(array('name' => 'Humatrol P', 'description' => 'HUMATROL P control serum has been designed to provide a suitable basis for the quality control (imprecision, inaccuracy) in the clinical chemical laboratory.', 'lot_id' => 1), array('name' => 'Full Blood Count', 'description' => 'Né pas touchér', 'lot_id' => 1));
     foreach ($controls as $control) {
         Control::create($control);
     }
     $this->command->info("Control table seeded");
     //Control measures
     $controlMeasures = array(array('name' => 'ca', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'pi', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'mg', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'na', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'K', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'WBC', 'unit' => 'x 103/uL', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'RBC', 'unit' => 'x 106/uL', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'HGB', 'unit' => 'g/dl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'HCT', 'unit' => '%', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCV', 'unit' => 'fl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCH', 'unit' => 'pg', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCHC', 'unit' => 'g/dl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'PLT', 'unit' => 'x 103/uL', 'control_id' => 2, 'control_measure_type_id' => 1));
     foreach ($controlMeasures as $controlMeasure) {
         ControlMeasure::create($controlMeasure);
     }
     $this->command->info("Control Measure table seeded");
     //Control measure ranges
     $controlMeasureRanges = array(array('upper_range' => '2.63', 'lower_range' => '7.19', 'control_measure_id' => 1), array('upper_range' => '11.65', 'lower_range' => '15.43', 'control_measure_id' => 2), array('upper_range' => '12.13', 'lower_range' => '19.11', 'control_measure_id' => 3), array('upper_range' => '15.73', 'lower_range' => '25.01', 'control_measure_id' => 4), array('upper_range' => '17.63', 'lower_range' => '20.12', 'control_measure_id' => 5), array('upper_range' => '6.5', 'lower_range' => '7.5', 'control_measure_id' => 6), array('upper_range' => '4.36', 'lower_range' => '5.78', 'control_measure_id' => 7), array('upper_range' => '13.8', 'lower_range' => '17.3', 'control_measure_id' => 8), array('upper_range' => '81.0', 'lower_range' => '95.0', 'control_measure_id' => 9), array('upper_range' => '1.99', 'lower_range' => '2.63', 'control_measure_id' => 10), array('upper_range' => '27.6', 'lower_range' => '33.0', 'control_measure_id' => 11), array('upper_range' => '32.8', 'lower_range' => '36.4', 'control_measure_id' => 12), array('upper_range' => '141', 'lower_range' => ' 320.0', 'control_measure_id' => 13));
     foreach ($controlMeasureRanges as $controlMeasureRange) {
         ControlMeasureRange::create($controlMeasureRange);
     }
     $this->command->info("Control Measure ranges table seeded");
     //Control Tests
     $controlTests = array(array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('entered_by' => 1, 'control_id' => 2, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('entered_by' => 1, 'control_id' => 2, 'created_at' => date('Y-m-d', strtotime('-2 days'))));
     foreach ($controlTests as $controltest) {
         ControlTest::create($controltest);
     }
     $this->command->info("Control test table seeded");
     //Control results
     $controlResults = array(array('results' => '2.78', 'control_measure_id' => 1, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '13.56', 'control_measure_id' => 2, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '14.77', 'control_measure_id' => 3, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '25.92', 'control_measure_id' => 4, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '18.87', 'control_measure_id' => 5, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '6.78', 'control_measure_id' => 1, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '15.56', 'control_measure_id' => 2, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '18.77', 'control_measure_id' => 3, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '30.92', 'control_measure_id' => 4, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '17.87', 'control_measure_id' => 5, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '8.78', 'control_measure_id' => 1, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '17.56', 'control_measure_id' => 2, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '21.77', 'control_measure_id' => 3, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '27.92', 'control_measure_id' => 4, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '22.87', 'control_measure_id' => 5, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '6.78', 'control_measure_id' => 1, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '18.56', 'control_measure_id' => 2, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '19.77', 'control_measure_id' => 3, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '12.92', 'control_measure_id' => 4, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '22.87', 'control_measure_id' => 5, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '3.78', 'control_measure_id' => 1, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '16.56', 'control_measure_id' => 2, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '17.77', 'control_measure_id' => 3, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '28.92', 'control_measure_id' => 4, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '19.87', 'control_measure_id' => 5, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '5.78', 'control_measure_id' => 1, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '15.56', 'control_measure_id' => 2, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '11.77', 'control_measure_id' => 3, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '29.92', 'control_measure_id' => 4, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '14.87', 'control_measure_id' => 5, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '9.78', 'control_measure_id' => 1, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '11.56', 'control_measure_id' => 2, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '19.77', 'control_measure_id' => 3, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '32.92', 'control_measure_id' => 4, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '29.87', 'control_measure_id' => 5, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '5.45', 'control_measure_id' => 6, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '5.01', 'control_measure_id' => 7, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '12.3', 'control_measure_id' => 8, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '89.7', 'control_measure_id' => 9, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '2.15', 'control_measure_id' => 10, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '34.0', 'control_measure_id' => 11, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '37.2', 'control_measure_id' => 12, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '141.5', 'control_measure_id' => 13, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '7.45', 'control_measure_id' => 6, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '9.01', 'control_measure_id' => 7, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '9.3', 'control_measure_id' => 8, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '94.7', 'control_measure_id' => 9, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '12.15', 'control_measure_id' => 10, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '37.0', 'control_measure_id' => 11, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '30.2', 'control_measure_id' => 12, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '121.5', 'control_measure_id' => 13, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))));
     foreach ($controlResults as $controlResult) {
         ControlMeasureResult::create($controlResult);
     }
     $this->command->info("Control results table seeded");
 }
예제 #11
0
 /**
  * turnaroundTime() function returns the turnaround time blade with necessary contents
  *
  * @return Response
  */
 public function turnaroundTime()
 {
     $today = date('Y-m-d');
     $from = Input::get('start');
     $to = Input::get('end');
     if (!$to) {
         $to = $today;
     }
     $testCategory = Input::get('section_id');
     $testType = Input::get('test_type');
     $labSections = TestCategory::lists('name', 'id');
     $interval = Input::get('period');
     $error = null;
     if ($testCategory) {
         $testTypes = TestCategory::find($testCategory)->testTypes->lists('name', 'id');
     } else {
         $testTypes = array("" => "");
     }
     if ($from || $to) {
         if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($today) || strtotime($to) > strtotime($today)) {
             $error = trans('messages.check-date-range');
         } else {
             $toPlusOne = date_add(new DateTime($to), date_interval_create_from_date_string('1 day'));
             Session::flash('fine', '');
         }
     }
     $resultset = self::getTatStats($from, $to, $testCategory, $testType, $interval);
     return View::make('reports.tat.index')->with('labSections', $labSections)->with('testTypes', $testTypes)->with('resultset', $resultset)->with('testCategory', $testCategory)->with('testType', $testType)->with('interval', $interval)->with('error', $error)->withInput(Input::all());
 }
예제 #12
0
//Total score
if ($origin != 'learnpath' || $origin == 'learnpath' && isset($_GET['fb_type'])) {
    if ($show_results || $show_only_total_score) {
        $total_score_text .= '<div class="question_row">';
        $my_total_score_temp = $totalScore;
        if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
            $my_total_score_temp = 0;
        }
        $total_score_text .= ExerciseLib::get_question_ribbon($objExercise, $my_total_score_temp, $totalWeighting, true);
        $total_score_text .= '</div>';
    }
}
if (!empty($category_list) && ($show_results || $show_only_total_score)) {
    // Adding total
    $category_list['total'] = array('score' => $my_total_score_temp, 'total' => $totalWeighting);
    echo TestCategory::get_stats_table_by_attempt($objExercise->id, $category_list);
}
echo $total_score_text;
echo $exercise_content;
echo $total_score_text;
if ($isFeedbackAllowed) {
    if (is_array($arrid) && is_array($arrmarks)) {
        $strids = implode(",", $arrid);
        $marksid = implode(",", $arrmarks);
    }
}
if ($isFeedbackAllowed) {
    if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
        echo '<form name="myform" id="myform" action="' . api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '&filter=2&comments=update&exeid=' . $id . '&origin=' . $origin . '&details=true&course=' . Security::remove_XSS($_GET['cidReq']) . $fromlink . '" method="post">';
        echo '<input type = "hidden" name="lp_item_id"       value="' . $learnpath_id . '">';
        echo '<input type = "hidden" name="lp_item_view_id"  value="' . $lp_item_view_id . '">';
 /**
  * Recycle tests categories
  */
 public function recycle_test_category()
 {
     if (isset($this->course->resources[RESOURCE_TEST_CATEGORY])) {
         foreach ($this->course->resources[RESOURCE_TEST_CATEGORY] as $tab_test_cat) {
             $obj_cat = new TestCategory($tab_test_cat->source_id);
             $obj_cat->removeCategory();
         }
     }
 }
예제 #14
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //Get the testtype
     $testtype = TestType::find($id);
     $measures = Measure::all();
     $measuretype = MeasureType::all()->sortBy('id');
     $specimentypes = SpecimenType::orderBy('name')->get();
     $testcategory = TestCategory::all();
     $organisms = Organism::orderBy('name')->get();
     //Open the Edit View and pass to it the $testtype
     return View::make('testtype.edit')->with('testtype', $testtype)->with('testcategory', $testcategory)->with('measures', $measures)->with('measuretype', $measuretype)->with('specimentypes', $specimentypes)->with('organisms', $organisms);
 }
예제 #15
0
/**
 * Return the name of the category for the question in a course
 * @author hubert.borderiou 13-10-2011
 */
function get_question_categorie_for_question($in_courseid, $in_questionid)
{
    $cat = TestCategory::getCategoryNameForQuestion($in_questionid, $in_courseid);
    return $cat;
}
예제 #16
0
     }
 }
 // Number of questions
 $random_label = null;
 if ($row['random'] > 0 || $row['random'] == -1) {
     // if random == -1 means use random questions with all questions
     $random_number_of_question = $row['random'];
     if ($random_number_of_question == -1) {
         $random_number_of_question = $rowi;
     }
     if ($row['random_by_category'] > 0) {
         $nbQuestionsTotal = TestCategory::getNumberOfQuestionRandomByCategory($my_exercise_id, $random_number_of_question);
         $number_of_questions = $nbQuestionsTotal . " ";
         $number_of_questions .= $nbQuestionsTotal > 1 ? get_lang("QuestionsLowerCase") : get_lang("QuestionLowerCase");
         $number_of_questions .= " - ";
         $number_of_questions .= min(TestCategory::getNumberMaxQuestionByCat($my_exercise_id), $random_number_of_question) . ' ' . get_lang('QuestionByCategory');
     } else {
         $random_label = ' (' . get_lang('Random') . ') ';
         $number_of_questions = $random_number_of_question . ' ' . $random_label;
         //Bug if we set a random value bigger than the real number of questions
         if ($random_number_of_question > $rowi) {
             $number_of_questions = $rowi . ' ' . $random_label;
         }
     }
 } else {
     $number_of_questions = $rowi;
 }
 //Attempts
 //$attempts = ExerciseLib::get_count_exam_results($row['id']).' '.get_lang('Attempts');
 //$item .=  Display::tag('td',$attempts);
 $item .= Display::tag('td', $number_of_questions);
예제 #17
0
    /**
     * MOH 706
     *
     */
    public function moh706()
    {
        //	Variables definition
        $date = date('Y-m-d');
        $from = Input::get('start');
        if (!$from) {
            $from = date('Y-m-01');
        }
        $end = Input::get('end');
        if (!$end) {
            $end = $date;
        }
        $toPlusOne = date_add(new DateTime($end), date_interval_create_from_date_string('1 day'));
        $to = date_add(new DateTime($end), date_interval_create_from_date_string('1 day'))->format('Y-m-d');
        $ageRanges = array('0-5', '5-14', '14-120');
        $sex = array(Patient::MALE, Patient::FEMALE);
        $ranges = array('Low', 'Normal', 'High');
        $specimen_types = array('Urine', 'Pus', 'HVS', 'Throat', 'Stool', 'Blood', 'CSF', 'Water', 'Food', 'Other fluids');
        $isolates = array('Naisseria', 'Klebsiella', 'Staphylococci', 'Streptoccoci' . 'Proteus', 'Shigella', 'Salmonella', 'V. cholera', 'E. coli', 'C. neoformans', 'Cardinella vaginalis', 'Haemophilus', 'Bordotella pertusis', 'Pseudomonas', 'Coliforms', 'Faecal coliforms', 'Enterococcus faecalis', 'Total viable counts-22C', 'Total viable counts-37C', 'Clostridium', 'Others');
        //	Get specimen_types for microbiology
        $labSecId = TestCategory::getTestCatIdByName('microbiology');
        $specTypeIds = DB::select(DB::raw("select distinct(specimen_types.id) as spec_id from testtype_specimentypes" . " join test_types on test_types.id=testtype_specimentypes.test_type_id" . " join specimen_types on testtype_specimentypes.specimen_type_id=specimen_types.id" . "  where test_types.test_category_id=?"), array($labSecId));
        //	Referred out specimen
        $referredSpecimens = DB::select(DB::raw("SELECT specimen_type_id, specimen_types.name as spec, count(specimens.id) as tot," . " facility_id, facilities.name as facility FROM iblis.specimens" . " join referrals on specimens.referral_id=referrals.id" . " join specimen_types on specimen_type_id=specimen_types.id" . " join facilities on referrals.facility_id=facilities.id" . " where referral_id is not null and status=1" . " and time_accepted between ? and ?" . " group by facility_id;"), array($from, $toPlusOne));
        $table = '<!-- URINALYSIS -->
			<div class="col-sm-12">
				<strong>URINE ANALYSIS</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Urine Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>';
        $urinaId = TestType::getTestTypeIdByTestName('Urinalysis');
        $urinalysis = TestType::find($urinaId);
        $urineChem = TestType::getTestTypeIdByTestName('Urine Chemistry');
        $urineChemistry = TestType::find($urineChem);
        $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tbody>
						<tr>
							<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [$gender], null, $from, $toPlusOne)) . '</td>';
        }
        $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, null, null, $from, $toPlusOne)) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            if (in_array($tMeasure->name, ['ph', 'Epithelial cells', 'Pus cells', 'S. haematobium', 'T. vaginalis', 'Yeast cells', 'Red blood cells', 'Bacteria', 'Spermatozoa'])) {
                continue;
            }
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ageRanges as $ageRange) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Urine Microscopy</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>

					<tbody>
						<tr>
							<td>Totals</td>';
        $urineMic = TestType::getTestTypeIdByTestName('Urine Microscopy');
        $urineMicroscopy = TestType::find($urineMic);
        $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get();
        foreach ($sex as $gender) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [$gender], null, $from, $toPlusOne)) . '</td>';
        }
        $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, null, null, $from, $toPlusOne)) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            if (in_array($tMeasure->name, ['Leucocytes', 'Nitrites', 'Glucose', 'pH', 'Bilirubin', 'Ketones', 'Proteins', 'Blood', 'Urobilinogen Phenlpyruvic acid'])) {
                continue;
            }
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ageRanges as $ageRange) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Blood Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $bloodChem = TestType::getTestTypeIdByTestName('Blood Sugar');
        $bloodChemistry = TestType::find($bloodChem);
        $measures = TestTypeMeasure::where('test_type_id', $bloodChem)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
							<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, ['Low', 'Normal', 'High'], null) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>OGTT</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Renal function tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $rfts = TestType::getTestTypeIdByTestName('RFTS');
        $rft = TestType::find($rfts);
        $measures = TestTypeMeasure::where('test_type_id', $rfts)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
						<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($rft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($rft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($rft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            if ($name == 'Electrolytes') {
                continue;
            }
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Liver Function Tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $lfts = TestType::getTestTypeIdByTestName('LFTS');
        $lft = TestType::find($lfts);
        $measures = TestTypeMeasure::where('test_type_id', $lfts)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
						<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($lft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($lft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($lft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            if ($name == 'SGOT') {
                $name = 'ASAT (SGOT)';
            }
            if ($name == 'ALAT') {
                $name = 'ASAT (SGPT)';
            }
            if ($name == 'Total Proteins') {
                $name = 'Serum Protein';
            }
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Gamma GT</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Lipid Profile</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Totals</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr><tr>
							<td>Amylase</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('Serum Amylase'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>Total cholestrol</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('cholestrol'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>Tryglycerides</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('Tryglycerides'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>HDL</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('HDL'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>LDL</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('LDL'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">CSF Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $csf = TestType::getTestTypeIdByTestName('CSF for biochemistry');
        $bioCsf = TestType::find($csf);
        $table .= '<tr>
					<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        $measures = TestTypeMeasure::where('test_type_id', $csf)->orderBy('measure_id', 'DESC')->get();
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            $table .= '<tr>
							<td>' . $name . '</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>';
        }
        $table .= '</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Body Fluids</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Totals</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
						</tr>
						<tr>
							<td>Proteins</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Glucose</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Acid phosphatase</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Bence jones protein</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Thyroid Function Tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $tfts = TestType::getTestTypeIdByTestName('TFT');
        $tft = TestType::find($tfts);
        $table .= '<tr>
					<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($tft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($tft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($tft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        $measures = TestTypeMeasure::where('test_type_id', $tfts)->orderBy('measure_id', 'ASC')->get();
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
						<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range]) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
			</div>
			<!-- URINALYSIS -->
			<!-- PARASITOLOGY -->
			<div class="col-sm-12">
				<strong>PARASITOLOGY</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th colspan="5">Blood Smears</th>
						</tr>
						<tr>
							<th rowspan="2">Malaria</th>
							<th colspan="4">Positive</th>
						</tr>
						<tr>
							<th>Total Done</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>';
        $bs = TestType::getTestTypeIdByTestName('Bs for mps');
        $bs4mps = TestType::find($bs);
        $table .= '<tbody>
						<tr>
							<td></td>
							<td>' . $this->getGroupedTestCounts($bs4mps, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bs4mps, null, $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>
						<tr style="text-align:right;">
							<td>Falciparum</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Ovale</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Malariae</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Vivax</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Borrelia</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Microfilariae</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Trypanosomes</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="5"><strong>Genital Smears</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>T. vaginalis</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>S. haematobium</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Yeast cells</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="5"><strong>Spleen/bone marrow</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>L. donovani</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>';
        $stool = TestType::getTestTypeIdByTestName('Stool for O/C');
        $stoolForOc = TestType::find($stool);
        $measures = TestTypeMeasure::where('test_type_id', $stool)->orderBy('measure_id', 'DESC')->get();
        $table .= '<td colspan="5"><strong>Stool</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td>' . $this->getGroupedTestCounts($stoolForOc, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($stoolForOc, null, $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            foreach ($tMeasure->measureRanges as $range) {
                if ($range->alphanumeric == 'O#C not seen') {
                    continue;
                }
                $table .= '<tr>
									<td>' . $range->alphanumeric . '</td>';
                $table .= '<td style="background-color: #CCCCCC;"></td>';
                foreach ($ageRanges as $ageRange) {
                    $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range->alphanumeric]) . '</td>';
                }
                $table .= '</tr>';
            }
        }
        $table .= '<tr>
							<td colspan="5"><strong>Lavages</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
			</div>
			<!-- PARASITOLOGY -->
			<!-- BACTERIOLOGY -->
			<div class="col-sm-12">
				<strong>BACTERIOLOGY</strong>
				<div class="row">
					<div class="col-sm-4">
						<table class="table table-condensed report-table-border" style="padding-right:5px;">
							<tbody style="text-align:right;">
								<tr>
									<td>Total examinations done</td>
									<td></td>
								</tr>';
        foreach ($specTypeIds as $key) {
            if (in_array(SpecimenType::find($key->spec_id)->name, ['Aspirate', 'Pleural Tap', 'Synovial Fluid', 'Sputum', 'Ascitic Tap', 'S***n', 'Skin'])) {
                continue;
            }
            $totalCount = DB::select(DB::raw("select count(specimen_id) as per_spec_count from tests" . " join specimens on tests.specimen_id=specimens.id" . " join test_types on tests.test_type_id=test_types.id" . " where specimens.specimen_type_id=?" . " and test_types.test_category_id=?" . " and test_status_id in(?,?)" . " and tests.time_created BETWEEN ? and ?;"), [$key->spec_id, $labSecId, Test::COMPLETED, Test::VERIFIED, $from, $toPlusOne]);
            $table .= '<tr>
									<td>' . SpecimenType::find($key->spec_id)->name . '</td>
									<td>' . $totalCount[0]->per_spec_count . '</td>
								</tr>';
        }
        $table .= '</tr>
									<td>Rectal swab</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Water</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Food</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Other (specify)....</td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="col-sm-8">
						<table class="table table-condensed report-table-border">
							<tbody>
								<tr>
									<td colspan="3">Drugs</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="3">Sensitivity (Total done)</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="3">Resistance per drug</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="3">KOH Preparations</td>
									<td>Fungi</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td colspan="2">Others (specify)</td>
								</tr>
								<tr>
									<td>Others</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td>...</td>
									<td></td>
								</tr>
								<tr>
									<td>Total</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td>...</td>
									<td></td>
								</tr>
							</tbody>
						</table>
						<p>SPUTUM</p>
						<table class="table table-condensed report-table-border">
							<tbody>
								<tr>
									<td></td>
									<td>Total</td>
									<td>Positive</td>
								</tr>
								<tr>
									<td>TB new suspects</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>Followup</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>TB smears</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>MDR</td>
									<td></td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<table class="table table-condensed report-table-border">
					<tbody>
						<tr><td></td>';
        foreach ($specimen_types as $spec) {
            $table .= '<td>' . $spec . '</td>';
        }
        $table .= '</tr>';
        foreach ($isolates as $isolate) {
            $table .= '<tr>
							<td>' . $isolate . '</td>';
            foreach ($specimen_types as $spec) {
                $table .= '<td>' . TestResult::microCounts($isolate, $spec, $from, $toPlusOne)[0]->total . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td colspan="11">Specify species of each isolate</td>
						</tr>
					</tbody>
				</table>
				<div class="row">
					<div class="col-sm-12">
						<strong>HEMATOLOGY REPORT</strong>
						<table class="table table-condensed report-table-border">
							<thead>
								<tr>
									<th colspan="2">Type of examination</th>
									<th>No. of Tests</th>
									<th>Controls</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td colspan="2">Full blood count</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Full haemogram')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Manual WBC counts</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Peripheral blood films</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Erythrocyte Sedimentation rate</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('ESR')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Sickling test</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Sickling test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">HB electrophoresis</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">G6PD screening</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Bleeding time</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Bleeding time test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Clotting time</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Clotting time test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Prothrombin test</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Partial prothrombin time</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Bone Marrow Aspirates</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td colspan="2">Reticulocyte counts</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td colspan="2">Others</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td rowspan="2">Haemoglobin</td>
									<td>No. Tests</td>
									<td>&lt;5</td>
									<td>5&lt;Hb&lt;10</td>
								</tr>
								<tr>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('HB')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">CD4/CD8</td>
									<td>No. Tests</td>
									<td>&lt;200</td>
									<td>200-350</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">CD4%</td>
									<td>No. Tests</td>
									<td>&lt;25%</td>
									<td>&gt;25%</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">Peripheral Blood Films</td>
									<td>Parasites</td>
									<td colspan="2">No. smears with inclusions</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td colspan="2"></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="col-sm-12">
						<strong>BLOOD GROUPING AND CROSSMATCH REPORT</strong>
						<div class="row">
							<div class="col-sm-6">
								<table class="table table-condensed report-table-border">
									<tbody>
										<tr>
											<td>Total groupings done</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('GXM')), null, null, $from, $toPlusOne) . '</td>
										</tr>
										<tr>
											<td>Blood units grouped</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Blood Grouping')), null, null, $from, $toPlusOne) . '</td>
										</tr>
										<tr>
											<td>Total transfusion reactions</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood cross matches</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Cross Match')), null, null, $from, $toPlusOne) . '</td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="col-sm-6">
								<strong>Blood safety</strong>
								<table class="table table-condensed report-table-border">
									<tbody>
										<tr>
											<td>Measure</td>
											<td>Number</td>
										</tr>
										<tr>
											<td>A. Blood units collected from regional blood transfusion centres</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units collected from other centres and screened at health facility</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units screened at health facility that are HIV positive</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units screened at health facility that are Hepatitis positive</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units positive for other infections</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units transfered</td>
											<td></td>
										</tr>
										<tr>
											<td rowspan="2">General remarks .............................</td>
											<td rowspan="2"></td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- BACTERIOLOGY -->
			<!-- HISTOLOGY AND CYTOLOGY -->
			<div class="col-sm-12">
				<strong>HISTOLOGY AND CYTOLOGY REPORT</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2"></th>
							<th rowspan="2">Total</th>
							<th rowspan="2">Normal</th>
							<th rowspan="2">Infective</th>
							<th colspan="2">Non-infective</th>
							<th colspan="3">Positive findings</th>
						</tr>
						<tr>
							<th>Benign</th>
							<th>Malignant</th>
							<th>&lt;5 yrs</th>
							<th>5-14 yrs</th>
							<th>&gt;14 yrs</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td colspan="9">SMEARS</td>
						</tr>
						<tr>
							<td>Pap Smear</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Tissue Impressions</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">TISSUE ASPIRATES (FNA)</td>
						</tr>
						<tr>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">FLUID CYTOLOGY</td>
						</tr>
						<tr>
							<td>Ascitic fluid</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>CSF</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Pleural fluid</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">TISSUE HISTOLOGY</td>
						</tr>
						<tr>
							<td>Cervix</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Prostrate</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Breast</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Ovarian cyst</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Fibroids</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Lymph nodes</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<strong>SEROLOGY REPORT</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Serological test</th>
							<th colspan="2">Total</th>
							<th colspan="2">&lt;5 yrs</th>
							<th colspan="2">5-14 yrs</th>
							<th colspan="2">&gt;14 yrs</th>
						</tr>
						<tr>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Rapid Plasma Region</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange)) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange) as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>TPHA</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>ASO Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>HIV Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Widal Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Brucella Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Rheumatoid Factor Tests</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Cryptococcal Antigen</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Helicobacter pylori test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Hepatitis A test</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>';
        $table .= '</tr>
						<tr>
							<td>Hepatitis B test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Hepatitis C test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Viral Load</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'))) == 0) {
            $table .= '<td>0</td>
									<td style="background-color: #CCCCCC;"></td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td style="background-color: #CCCCCC;"></td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td style="background-color: #CCCCCC;"></td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td style="background-color: #CCCCCC;"></td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Formal Gel Test</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Other Tests</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<br />
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th>Dried Blood Spots</th>
							<th>Tested</th>
							<th># +ve</th>
							<th>Discrepant</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Early Infant Diagnosis of HIV</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        $table .= '<td></td>
						</tr>
						<tr>
							<td>Quality Assurance</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Discordant couples</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<p><strong>Specimen referral to higher levels</strong></p>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th>Specimen</th>
							<th>No</th>
							<th>Sent to</th>
							<th>No. of Reports/results received</th>
						</tr>
					</thead>
					<tbody>';
        if ($referredSpecimens) {
            foreach ($referredSpecimens as $referredSpecimen) {
                $table .= '<tr>
								<td>' . $referredSpecimen->spec . '</td>
								<td>' . $referredSpecimen->tot . '</td>
								<td>' . $referredSpecimen->facility . '</td>
								<td></td>
							</tr>';
            }
        } else {
            $table .= '<tr>
								<td colspan="4">' . trans('messages.no-records-found') . '</td>
							</tr>';
        }
        $table .= '</tbody>
				</table>
			</div>
			<!-- HISTOLOGY AND CYTOLOGY -->';
        if (Input::has('excel')) {
            $date = date("Ymdhi");
            $fileName = "MOH706_" . $date . ".xls";
            $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName);
            $content = $table;
            return Response::make($content, 200, $headers);
        } else {
            //return View::make('reports.moh.706');
            return View::make('reports.moh.index')->with('table', $table)->with('from', $from)->with('end', $end);
        }
    }
예제 #18
0
 /**
  * Shows question title an description
  *
  * @param string $feedback_type
  * @param int $counter
  * @param float $score
  */
 function return_header($feedback_type = null, $counter = null, $score = null)
 {
     $counter_label = '';
     if (!empty($counter)) {
         $counter_label = intval($counter);
     }
     $score_label = get_lang('Wrong');
     $class = 'error';
     if ($score['pass'] == true) {
         $score_label = get_lang('Correct');
         $class = 'success';
     }
     if ($this->type == FREE_ANSWER || $this->type == ORAL_EXPRESSION) {
         $score['revised'] = isset($score['revised']) ? $score['revised'] : false;
         if ($score['revised'] == true) {
             $score_label = get_lang('Revised');
             $class = '';
         } else {
             $score_label = get_lang('NotRevised');
             $class = 'error';
         }
     }
     $question_title = $this->question;
     // display question category, if any
     $header = TestCategory::returnCategoryAndTitle($this->id);
     $show_media = null;
     if ($show_media) {
         $header .= $this->show_media_content();
     }
     $header .= Display::page_subheader2($counter_label . ". " . $question_title);
     $header .= Display::div("<div class=\"rib rib-{$class}\"><h3>{$score_label}</h3></div> <h4>{$score['result']}</h4>", array('class' => 'ribbon'));
     $header .= Display::div($this->description, array('id' => 'question_description'));
     return $header;
 }
예제 #19
0
 /**
  * @param int $courseId
  * @param int $sessionId
  * @return string
  */
 public function displayCategories($courseId, $sessionId = 0)
 {
     $categories = $this->getCategories($courseId, $sessionId);
     $html = '';
     foreach ($categories as $category) {
         $tmpobj = new TestCategory($category['id']);
         $nb_question = $tmpobj->getCategoryQuestionsNumber();
         $rowname = self::protectJSDialogQuote($category['title']);
         $nb_question_label = $nb_question == 1 ? $nb_question . ' ' . get_lang('Question') : $nb_question . ' ' . get_lang('Questions');
         //$html .= '<div class="sectiontitle" id="id_cat' . $category['id'] . '">';
         $content = "<span style='float:right'>" . $nb_question_label . "</span>";
         $content .= '<div class="sectioncomment">';
         $content .= $category['description'];
         $content .= '</div>';
         $links = '<a href="' . api_get_self() . '?action=editcategory&category_id=' . $category['id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
         $links .= ' <a href="' . api_get_self() . '?action=deletecategory&category_id=' . $category['id'] . '" ';
         $links .= 'onclick="return confirmDelete(\'' . self::protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure') . '[' . $rowname) . '] ?\', \'id_cat' . $category['id'] . '\');">';
         $links .= Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
         $html .= Display::panel($content, $category['title'] . $links);
     }
     return $html;
 }
 /**
  * Build the test category
  * @param int $session_id Internal session ID
  * @param int $courseId Internal course ID
  * @param bool $with_base_content Whether to include content from the course without session or not
  * @param array $id_list If you want to restrict the structure to only the given IDs
  * @todo add course session
  */
 public function build_test_category($session_id = 0, $courseId = 0, $with_base_content = false, $id_list = array())
 {
     // get all test category in course
     $tab_test_categories_id = TestCategory::getCategoryListInfo("id", $courseId);
     foreach ($tab_test_categories_id as $test_category_id) {
         $test_category = new TestCategory($test_category_id);
         $copy_course_test_category = new CourseCopyTestcategory($test_category_id, $test_category->name, $test_category->description);
         $this->course->add_resource($copy_course_test_category);
     }
 }
예제 #21
0
/**
 * form to add a category
 * @todo move to TestCategory.class.php
 * @param string $action
 */
function add_category_form($action)
{
    $action = Security::remove_XSS($action);
    // initiate the object
    $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $action);
    // Setting the form elements
    $form->addElement('header', get_lang('AddACategory'));
    $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95'));
    $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200'));
    $form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote');
    // setting the rules
    $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required');
    // The validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER);
            $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER);
            $objcat = new TestCategory(0, $v_name, $v_description);
            if ($objcat->addCategoryInBDD()) {
                Display::display_confirmation_message(get_lang('AddCategoryDone'));
            } else {
                Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists'));
            }
        }
        Security::clear_token();
    } else {
        display_goback();
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
예제 #22
0
 /**
  * Display the exercise results
  * @param Exercise $objExercise
  * @param int $exe_id
  * @param bool $save_user_result save users results (true) or just show the results (false)
  */
 public static function display_question_list_by_attempt($objExercise, $exe_id, $save_user_result = false)
 {
     global $origin;
     // Getting attempt info
     $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
     // Getting question list
     $question_list = array();
     if (!empty($exercise_stat_info['data_tracking'])) {
         $question_list = explode(',', $exercise_stat_info['data_tracking']);
     } else {
         // Try getting the question list only if save result is off
         if ($save_user_result == false) {
             $question_list = $objExercise->get_validated_question_list();
         }
     }
     $counter = 1;
     $total_score = $total_weight = 0;
     $exercise_content = null;
     // Hide results
     $show_results = false;
     $show_only_score = false;
     if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS) {
         $show_results = true;
     }
     if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES))) {
         $show_only_score = true;
     }
     // Not display expected answer, but score, and feedback
     $show_all_but_expected_answer = false;
     if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
         $show_all_but_expected_answer = true;
         $show_results = true;
         $show_only_score = false;
     }
     if ($show_results || $show_only_score) {
         $user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
         //Shows exercise header
         echo $objExercise->show_exercise_result_header($user_info, api_convert_and_format_date($exercise_stat_info['start_date'], DATE_TIME_FORMAT_LONG), $exercise_stat_info['duration'], $exercise_stat_info['user_ip']);
     }
     // Display text when test is finished #4074 and for LP #4227
     $end_of_message = $objExercise->selectTextWhenFinished();
     if (!empty($end_of_message)) {
         Display::display_normal_message($end_of_message, false);
         echo "<div class='clear'>&nbsp;</div>";
     }
     $question_list_answers = array();
     $media_list = array();
     $category_list = array();
     // Loop over all question to show results for each of them, one by one
     if (!empty($question_list)) {
         foreach ($question_list as $questionId) {
             // creates a temporary Question object
             $objQuestionTmp = Question::read($questionId);
             // This variable came from exercise_submit_modal.php
             ob_start();
             // We're inside *one* question. Go through each possible answer for this question
             $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null, 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), array());
             if (empty($result)) {
                 continue;
             }
             // In case of global score, make sure the calculated total score is integer
             /*if (!is_int($result['score'])) {
                   $result['score'] = round($result['score']);
               }*/
             $total_score += $result['score'];
             $total_weight += $result['weight'];
             $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer'], 'answer_type' => $result['answer_type']);
             $my_total_score = $result['score'];
             $my_total_weight = $result['weight'];
             // Category report
             $category_was_added_for_this_test = false;
             if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
                 if (!isset($category_list[$objQuestionTmp->category]['score'])) {
                     $category_list[$objQuestionTmp->category]['score'] = 0;
                 }
                 if (!isset($category_list[$objQuestionTmp->category]['total'])) {
                     $category_list[$objQuestionTmp->category]['total'] = 0;
                 }
                 $category_list[$objQuestionTmp->category]['score'] += $my_total_score;
                 $category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
                 $category_was_added_for_this_test = true;
             }
             if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
                 foreach ($objQuestionTmp->category_list as $category_id) {
                     $category_list[$category_id]['score'] += $my_total_score;
                     $category_list[$category_id]['total'] += $my_total_weight;
                     $category_was_added_for_this_test = true;
                 }
             }
             // No category for this question!
             if ($category_was_added_for_this_test == false) {
                 if (!isset($category_list['none']['score'])) {
                     $category_list['none']['score'] = 0;
                 }
                 if (!isset($category_list['none']['total'])) {
                     $category_list['none']['total'] = 0;
                 }
                 $category_list['none']['score'] += $my_total_score;
                 $category_list['none']['total'] += $my_total_weight;
             }
             if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
                 $my_total_score = 0;
             }
             $comnt = null;
             if ($show_results) {
                 $comnt = Event::get_comments($exe_id, $questionId);
                 if (!empty($comnt)) {
                     echo '<b>' . get_lang('Feedback') . '</b>';
                     echo '<div id="question_feedback">' . $comnt . '</div>';
                 }
             }
             if ($show_results) {
                 $score = array('result' => get_lang('Score') . " : " . self::show_score($my_total_score, $my_total_weight, false, true), 'pass' => $my_total_score >= $my_total_weight ? true : false, 'score' => $my_total_score, 'weight' => $my_total_weight, 'comments' => $comnt);
             } else {
                 $score = array();
             }
             $contents = ob_get_clean();
             $question_content = '';
             if ($show_results) {
                 $question_content = '<div class="question_row_answer">';
                 $show_media = false;
                 /*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) {
                       $show_media = true;
                       $media_list[] = $objQuestionTmp->parent_id;
                   }*/
                 //Shows question title an description
                 $question_content .= $objQuestionTmp->return_header(null, $counter, $score);
             }
             $counter++;
             $question_content .= $contents;
             if ($show_results) {
                 $question_content .= '</div>';
             }
             $exercise_content .= $question_content;
         }
         // end foreach() block that loops over all questions
     }
     $total_score_text = null;
     if ($origin != 'learnpath') {
         if ($show_results || $show_only_score) {
             $total_score_text .= '<div class="question_row_score">';
             $total_score_text .= self::get_question_ribbon($objExercise, $total_score, $total_weight, true);
             $total_score_text .= '</div>';
         }
     }
     if (!empty($category_list) && ($show_results || $show_only_score)) {
         //Adding total
         $category_list['total'] = array('score' => $total_score, 'total' => $total_weight);
         echo TestCategory::get_stats_table_by_attempt($objExercise->id, $category_list);
     }
     if ($show_all_but_expected_answer) {
         $exercise_content .= "<div class='normal-message'>" . get_lang("ExerciseWithFeedbackWithoutCorrectionComment") . "</div>";
     }
     // Remove audio auto play from questions on results page - refs BT#7939
     $exercise_content = preg_replace(['/autoplay[\\=\\".+\\"]+/', '/autostart[\\=\\".+\\"]+/'], '', $exercise_content);
     echo $total_score_text;
     echo $exercise_content;
     if (!$show_only_score) {
         echo $total_score_text;
     }
     if ($save_user_result) {
         // Tracking of results
         $learnpath_id = $exercise_stat_info['orig_lp_id'];
         $learnpath_item_id = $exercise_stat_info['orig_lp_item_id'];
         $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
         if (api_is_allowed_to_session_edit()) {
             Event::update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $exercise_stat_info['exe_duration'], $question_list, '', array());
         }
         // Send notification ..
         if (!api_is_allowed_to_edit(null, true) && !api_is_excluded_user_type()) {
             if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1) {
                 $objExercise->send_mail_notification_for_exam($question_list_answers, $origin, $exe_id);
             }
             $objExercise->send_notification_for_open_questions($question_list_answers, $origin, $exe_id);
             $objExercise->send_notification_for_oral_questions($question_list_answers, $origin, $exe_id);
         }
     }
 }
 /**
  * Remove the specified resource from storage (soft delete).
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the test category
     $testcategory = TestCategory::find($id);
     $testCategoryInUse = TestType::where('test_category_id', '=', $id)->first();
     if (empty($testCategoryInUse)) {
         // The test category is not in use
         $testcategory->delete();
     } else {
         // The test category is in use
         $url = Session::get('SOURCE_URL');
         return Redirect::to($url)->with('message', trans('messages.failure-test-category-in-use'));
     }
     // redirect
     $url = Session::get('SOURCE_URL');
     return Redirect::to($url)->with('message', trans('messages.success-deleting-test-category'));
 }
예제 #24
0
 /**
  * Calculate the max_score of the quiz, depending of question inside, and quiz advanced option
  */
 public function get_max_score()
 {
     $out_max_score = 0;
     $tab_question_list = $this->selectQuestionList(true);
     // list of question's id !!! the array key start at 1 !!!
     // test is randomQuestions - see field random of test
     if ($this->random > 0 && $this->randomByCat == 0) {
         $nb_random_questions = $this->random;
         $tab_questions_score = array();
         for ($i = 1; $i <= count($tab_question_list); $i++) {
             $tmpobj_question = Question::read($tab_question_list[$i]);
             $tab_questions_score[] = $tmpobj_question->weighting;
         }
         rsort($tab_questions_score);
         // add the first $nb_random_questions value of score array to get max_score
         for ($i = 0; $i < min($nb_random_questions, count($tab_questions_score)); $i++) {
             $out_max_score += $tab_questions_score[$i];
         }
     } else {
         if ($this->random > 0 && $this->randomByCat > 0) {
             $nb_random_questions = $this->random;
             $tab_categories_scores = array();
             for ($i = 1; $i <= count($tab_question_list); $i++) {
                 $question_category_id = TestCategory::getCategoryForQuestion($tab_question_list[$i]);
                 if (!is_array($tab_categories_scores[$question_category_id])) {
                     $tab_categories_scores[$question_category_id] = array();
                 }
                 $tmpobj_question = Question::read($tab_question_list[$i]);
                 $tab_categories_scores[$question_category_id][] = $tmpobj_question->weighting;
             }
             // here we've got an array with first key, the category_id, second key, score of question for this cat
             while (list($key, $tab_scores) = each($tab_categories_scores)) {
                 rsort($tab_scores);
                 for ($i = 0; $i < min($nb_random_questions, count($tab_scores)); $i++) {
                     $out_max_score += $tab_scores[$i];
                 }
             }
         } else {
             for ($i = 1; $i <= count($tab_question_list); $i++) {
                 $tmpobj_question = Question::read($tab_question_list[$i]);
                 $out_max_score += $tmpobj_question->weighting;
             }
         }
     }
     return $out_max_score;
 }
예제 #25
0
/**
 * Handles a given Excel spreadsheets as in the template provided
 */
function lp_upload_quiz_action_handling()
{
    global $debug;
    $_course = api_get_course_info();
    $courseId = $_course['real_id'];
    if (!isset($_POST['submit_upload_quiz'])) {
        return;
    }
    // Get the extension of the document.
    $path_info = pathinfo($_FILES['user_upload_quiz']['name']);
    // Check if the document is an Excel document
    if ($path_info['extension'] != 'xls') {
        return;
    }
    // Read the Excel document
    $data = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    $data->setOutputEncoding(api_get_system_encoding());
    // Reading the xls document.
    $data->read($_FILES['user_upload_quiz']['tmp_name']);
    $correctScore = isset($_POST['correct_score']) ? $_POST['correct_score'] : null;
    $incorrectScore = isset($_POST['incorrect_score']) ? $_POST['incorrect_score'] : null;
    $useCustomScore = isset($_POST['user_custom_score']) ? true : false;
    $propagateNegative = 0;
    if ($useCustomScore && !empty($incorrectScore)) {
        if ($incorrectScore < 0) {
            $propagateNegative = 1;
        }
    }
    // Variables
    $quiz_index = 0;
    $question_title_index = array();
    $question_name_index_init = array();
    $question_name_index_end = array();
    $score_index = array();
    $feedback_true_index = array();
    $feedback_false_index = array();
    $number_questions = 0;
    $question_description_index = array();
    $noNegativeScoreIndex = array();
    $questionTypeList = array();
    $questionTypeIndex = array();
    $categoryList = array();
    // Reading all the first column items sequentially to create breakpoints
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) {
            $quiz_index = $i;
            // Quiz title position, only occurs once
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') {
            $question_title_index[] = $i;
            // Question title position line
            $question_name_index_init[] = $i + 1;
            // Questions name 1st position line
            $number_questions++;
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Score') {
            $question_name_index_end[] = $i - 1;
            // Question name position
            $score_index[] = $i;
            // Question score position
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') {
            $feedback_true_index[] = $i;
            // FeedbackTrue position (line)
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') {
            $feedback_false_index[] = $i;
            // FeedbackFalse position (line)
        } elseif ($data->sheets[0]['cells'][$i][1] == 'EnrichQuestion') {
            $question_description_index[] = $i;
        } elseif ($data->sheets[0]['cells'][$i][1] == 'NoNegativeScore') {
            $noNegativeScoreIndex[] = $i;
        } elseif ($data->sheets[0]['cells'][$i][1] == 'QuestionType') {
            $questionTypeIndex[] = $i;
        }
    }
    // Variables
    $quiz = array();
    $question = array();
    $new_answer = array();
    $score_list = array();
    $feedback_true_list = array();
    $feedback_false_list = array();
    $question_description = array();
    $noNegativeScoreList = array();
    // Getting questions.
    $k = $z = $q = $l = $m = $n = 0;
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if (is_array($data->sheets[0]['cells'][$i])) {
            $column_data = $data->sheets[0]['cells'][$i];
            // Fill all column with data to have a full array
            for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                if (empty($column_data[$x])) {
                    $data->sheets[0]['cells'][$i][$x] = '';
                }
            }
            // Array filled with data
            $column_data = $data->sheets[0]['cells'][$i];
        } else {
            $column_data = '';
        }
        // Fill quiz data
        if ($quiz_index == $i) {
            // The title always in the first position
            $quiz = $column_data;
        } elseif (in_array($i, $question_title_index)) {
            //a complete line where 1st column is 'Question'
            $question[$k] = $column_data;
            for ($counter = 0; $counter < 12; $counter++) {
                $myData = isset($data->sheets[0]['cells'][$i + $counter]) ? $data->sheets[0]['cells'][$i + $counter] : null;
                if (isset($myData[1]) && $myData[1] == 'QuestionType') {
                    $questionTypeList[$k] = $myData[3];
                }
                if (isset($myData[1]) && $myData[1] == 'Category') {
                    $categoryList[$k] = $myData[2];
                }
            }
            if (!isset($questionTypeList[$k])) {
                $questionTypeList[$k] = null;
            }
            $k++;
        } elseif (in_array($i, $score_index)) {
            //a complete line where 1st column is 'Score'
            $score_list[$z] = $column_data;
            $z++;
        } elseif (in_array($i, $feedback_true_index)) {
            //a complete line where 1st column is 'FeedbackTrue'
            $feedback_true_list[$q] = $column_data;
            $q++;
        } elseif (in_array($i, $feedback_false_index)) {
            //a complete line where 1st column is 'FeedbackFalse' for wrong answers
            $feedback_false_list[$l] = $column_data;
            $l++;
        } elseif (in_array($i, $question_description_index)) {
            //a complete line where 1st column is 'EnrichQuestion'
            $question_description[$m] = $column_data;
            $m++;
        } elseif (in_array($i, $noNegativeScoreIndex)) {
            //a complete line where 1st column is 'NoNegativeScore'
            $noNegativeScoreList[$z - 1] = $column_data;
        }
    }
    // Get answers
    for ($i = 0; $i < count($question_name_index_init); $i++) {
        for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) {
            if (is_array($data->sheets[0]['cells'][$j])) {
                $column_data = $data->sheets[0]['cells'][$j];
                // Fill all column with data
                for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                    if (empty($column_data[$x])) {
                        $data->sheets[0]['cells'][$j][$x] = '';
                    }
                }
                $column_data = $data->sheets[0]['cells'][$j];
                // Array filled of data
                if (is_array($column_data) && count($column_data) > 0) {
                    $new_answer[$i][$j] = $column_data;
                }
            }
        }
    }
    // Quiz title.
    $quiz_title = $quiz[2];
    if ($quiz_title != '') {
        // Variables
        $type = 2;
        $random = $active = $results = $max_attempt = $expired_time = 0;
        // Make sure feedback is enabled (3 to disable), otherwise the fields
        // added to the XLS are not shown, which is confusing
        $feedback = 0;
        // Quiz object
        $exercise = new Exercise();
        //
        $quiz_id = $exercise->createExercise($quiz_title, $expired_time, $type, $random, $active, $results, $max_attempt, $feedback, $propagateNegative);
        if ($quiz_id) {
            // insert into the item_property table
            api_item_property_update($_course, TOOL_QUIZ, $quiz_id, 'QuizAdded', api_get_user_id());
            // Import questions.
            for ($i = 0; $i < $number_questions; $i++) {
                // Question name
                $question_title = $question[$i][2];
                $description = isset($question_description[$i][2]) ? $question_description[$i][2] : '';
                $categoryId = null;
                if (isset($categoryList[$i]) && !empty($categoryList[$i])) {
                    $categoryName = $categoryList[$i];
                    $categoryId = TestCategory::get_category_id_for_title($categoryName, $courseId);
                    if (empty($categoryId)) {
                        $category = new TestCategory(null, $categoryName, '');
                        $categoryId = $category->addCategoryInBDD();
                    }
                }
                $question_description_text = "<p></p>";
                if (!empty($description)) {
                    // Question description.
                    $question_description_text = "<p>" . $description . "</p>";
                }
                // Unique answers are the only question types available for now
                // through xls-format import
                $answerList = isset($new_answer[$i]) ? $new_answer[$i] : '';
                $question_id = null;
                if (isset($questionTypeList[$i])) {
                    $detectQuestionType = intval($questionTypeList[$i]);
                } else {
                    $detectQuestionType = detectQuestionType($answerList, $score_list);
                }
                /** @var Question $answer */
                switch ($detectQuestionType) {
                    case FREE_ANSWER:
                        $answer = new FreeAnswer();
                        break;
                    case GLOBAL_MULTIPLE_ANSWER:
                        $answer = new GlobalMultipleAnswer();
                        break;
                    case MULTIPLE_ANSWER:
                        $answer = new MultipleAnswer();
                        break;
                    case FILL_IN_BLANKS:
                        $answer = new FillBlanks();
                        $question_description_text = '';
                        break;
                    case MATCHING:
                        $answer = new Matching();
                        break;
                    case UNIQUE_ANSWER:
                    default:
                        $answer = new UniqueAnswer();
                        break;
                }
                if ($question_title != '') {
                    $question_id = $answer->create_question($quiz_id, $question_title, $question_description_text, 0, $answer->type);
                    if (!empty($categoryId)) {
                        TestCategory::add_category_for_question_id($categoryId, $question_id, $courseId);
                    }
                }
                switch ($detectQuestionType) {
                    case GLOBAL_MULTIPLE_ANSWER:
                    case MULTIPLE_ANSWER:
                    case UNIQUE_ANSWER:
                        $total = 0;
                        if (is_array($answerList) && !empty($question_id)) {
                            $id = 1;
                            $globalScore = null;
                            $objAnswer = new Answer($question_id, $courseId);
                            $globalScore = $score_list[$i][3];
                            // Calculate the number of correct answers to divide the
                            // score between them when importing from CSV
                            $numberRightAnswers = 0;
                            foreach ($answerList as $answer_data) {
                                if (strtolower($answer_data[3]) == 'x') {
                                    $numberRightAnswers++;
                                }
                            }
                            foreach ($answerList as $answer_data) {
                                $answerValue = $answer_data[2];
                                $correct = 0;
                                $score = 0;
                                if (strtolower($answer_data[3]) == 'x') {
                                    $correct = 1;
                                    $score = $score_list[$i][3];
                                    $comment = $feedback_true_list[$i][2];
                                } else {
                                    $comment = $feedback_false_list[$i][2];
                                    $floatVal = (double) $answer_data[3];
                                    if (is_numeric($floatVal)) {
                                        $score = $answer_data[3];
                                    }
                                }
                                if ($useCustomScore) {
                                    if ($correct) {
                                        $score = $correctScore;
                                    } else {
                                        $score = $incorrectScore;
                                    }
                                }
                                // Fixing scores:
                                switch ($detectQuestionType) {
                                    case GLOBAL_MULTIPLE_ANSWER:
                                        if (isset($noNegativeScoreList[$i][3])) {
                                            if (!(strtolower($noNegativeScoreList[$i][3]) == 'x') && !$correct) {
                                                $score = $score_list[$i][3] * -1;
                                            }
                                        } else {
                                            $score = $score_list[$i][3] * -1;
                                        }
                                        $score /= $numberRightAnswers;
                                        break;
                                    case UNIQUE_ANSWER:
                                        break;
                                    case MULTIPLE_ANSWER:
                                        if (!$correct) {
                                            //$total = $total - $score;
                                        }
                                        break;
                                }
                                $objAnswer->createAnswer($answerValue, $correct, $comment, $score, $id);
                                $total += $score;
                                $id++;
                            }
                            $objAnswer->save();
                            $questionObj = Question::read($question_id, $courseId);
                            switch ($detectQuestionType) {
                                case GLOBAL_MULTIPLE_ANSWER:
                                    $questionObj->updateWeighting($globalScore);
                                    break;
                                case UNIQUE_ANSWER:
                                case MULTIPLE_ANSWER:
                                default:
                                    $questionObj->updateWeighting($total);
                                    break;
                            }
                            $questionObj->save();
                        }
                        break;
                    case FREE_ANSWER:
                        $questionObj = Question::read($question_id, $courseId);
                        $globalScore = $score_list[$i][3];
                        $questionObj->updateWeighting($globalScore);
                        $questionObj->save();
                        break;
                    case FILL_IN_BLANKS:
                        $scoreList = array();
                        $size = array();
                        $globalScore = 0;
                        foreach ($answerList as $data) {
                            $score = isset($data[3]) ? $data[3] : 0;
                            $globalScore += $score;
                            $scoreList[] = $score;
                            $size[] = 200;
                        }
                        $scoreToString = implode(',', $scoreList);
                        $sizeToString = implode(',', $size);
                        //<p>Texte long avec les [mots] à [remplir] mis entre [crochets]</p>::10,10,10:200.36363999999998,200,200:0@'
                        $answerValue = $description . '::' . $scoreToString . ':' . $sizeToString . ':0@';
                        $objAnswer = new Answer($question_id, $courseId);
                        $objAnswer->createAnswer($answerValue, '', '', $globalScore, 1);
                        $objAnswer->save();
                        $questionObj = Question::read($question_id, $courseId);
                        $questionObj->updateWeighting($globalScore);
                        $questionObj->save();
                        break;
                    case MATCHING:
                        $globalScore = $score_list[$i][3];
                        $position = 1;
                        $objAnswer = new Answer($question_id, $courseId);
                        foreach ($answerList as $data) {
                            $option = isset($data[3]) ? $data[3] : '';
                            $objAnswer->createAnswer($option, 0, '', 0, $position);
                            $position++;
                        }
                        $counter = 1;
                        foreach ($answerList as $data) {
                            $value = isset($data[2]) ? $data[2] : '';
                            $position++;
                            $objAnswer->createAnswer($value, $counter, ' ', $globalScore, $position);
                            $counter++;
                        }
                        $objAnswer->save();
                        $questionObj = Question::read($question_id, $courseId);
                        $questionObj->updateWeighting($globalScore);
                        $questionObj->save();
                        break;
                }
            }
        }
        $lpFromSession = Session::read('lpobject');
        if (isset($lpFromSession)) {
            if ($debug > 0) {
                error_log('New LP - SESSION[lpobject] is defined', 0);
            }
            $oLP = unserialize($lpFromSession);
            if (is_object($oLP)) {
                if ($debug > 0) {
                    error_log('New LP - oLP is object', 0);
                }
                if (empty($oLP->cc) or $oLP->cc != api_get_course_id()) {
                    if ($debug > 0) {
                        error_log('New LP - Course has changed, discard lp object', 0);
                    }
                    $oLP = null;
                    Session::erase('oLP');
                    Session::erase('lpobject');
                } else {
                    Session::write('oLP', $oLP);
                }
            }
        }
        /** @var learnpath $lpFromSession */
        $lpFromSession = Session::read('oLP');
        if (isset($lpFromSession) && isset($_GET['lp_id'])) {
            $previous = $lpFromSession->select_previous_item_id();
            $parent = 0;
            // Add a Quiz as Lp Item
            $lpFromSession->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, '');
            // Redirect to home page for add more content
            header('location: ../newscorm/lp_controller.php?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . intval($_GET['lp_id']));
            exit;
        } else {
            echo '<script>window.location.href = "' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidReq() . '&exerciseId=' . $quiz_id . '&session_id=' . api_get_session_id() . '"</script>';
        }
    }
}
 if ($objExercise->edit_exercise_in_lp == true) {
     $delete_link = '<a id="delete_' . $id . '" class="opener"  href="' . api_get_self() . '?' . api_get_cidreq() . '&exerciseId=' . $exerciseId . '&deleteQuestion=' . $id . '" >' . Display::return_icon('delete.png', get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL) . '</a>';
 }
 $edit_link = Display::tag('div', $edit_link, array('style' => 'float:left; padding:0px; margin:0px'));
 $clone_link = Display::tag('div', $clone_link, array('style' => 'float:left; padding:0px; margin:0px'));
 $delete_link = Display::tag('div', $delete_link, array('style' => 'float:left; padding:0px; margin:0px'));
 $actions = Display::tag('div', $edit_link . $clone_link . $delete_link, array('class' => 'edition', 'style' => 'width:100px; right:10px; margin-top: 8px; position: absolute; top: 10%;'));
 $title = Security::remove_XSS($objQuestionTmp->selectTitle());
 $move = Display::return_icon('all_directions.png', get_lang('Move'), array('class' => 'moved', 'style' => 'margin-bottom:-0.5em;'));
 // Question name
 $questionName = Display::tag('div', '<a href="#" title = "' . Security::remove_XSS($title) . '">' . $move . ' ' . cut($title, 42) . '</a>', array('style' => $styleQuestion));
 // Question type
 list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
 $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style' => $styleType));
 // Question category
 $txtQuestionCat = Security::remove_XSS(TestCategory::getCategoryNameForQuestion($objQuestionTmp->id));
 if (empty($txtQuestionCat)) {
     $txtQuestionCat = "-";
 }
 $questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="' . $txtQuestionCat . '">' . cut($txtQuestionCat, 42) . '</a>', array('style' => $styleCat));
 // Question level
 $txtQuestionLevel = $objQuestionTmp->level;
 if (empty($objQuestionTmp->level)) {
     $txtQuestionLevel = '-';
 }
 $questionLevel = Display::tag('div', $txtQuestionLevel, array('style' => $styleLevel));
 // Question score
 $questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style' => $styleScore));
 echo '<div id="question_id_list_' . $id . '" >';
 echo '<div class="header_operations">';
 echo $questionName;
 /**
  * @todo : add session id when used for session
  */
 public function restore_test_category($session_id, $respect_base_content, $destination_course_code)
 {
     $course_id = api_get_course_int_id();
     // Let's restore the categories
     $tab_test_category_id_old_new = array();
     // used to build the quiz_question_rel_category table
     if ($this->course->has_resources(RESOURCE_TEST_CATEGORY)) {
         $resources = $this->course->resources;
         foreach ($resources[RESOURCE_TEST_CATEGORY] as $id => $CourseCopyTestcategory) {
             $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
             // check if this test_category already exist in the destination BDD
             // do not Database::escape_string $title and $description, it will be done later
             $title = $CourseCopyTestcategory->title;
             $description = $CourseCopyTestcategory->description;
             if (TestCategory::category_exists_with_title($title)) {
                 switch ($this->file_option) {
                     case FILE_SKIP:
                         //Do nothing
                         break;
                     case FILE_RENAME:
                         $new_title = $title . "_";
                         while (TestCategory::category_exists_with_title($new_title)) {
                             $new_title .= "_";
                         }
                         $test_category = new TestCategory(0, $new_title, $description);
                         $new_id = $test_category->addCategoryInBDD();
                         $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $new_id;
                         break;
                     case FILE_OVERWRITE:
                         $id = TestCategory::get_category_id_for_title($title);
                         $my_cat = new TestCategory($id);
                         $my_cat->name = $title;
                         $my_cat->modifyCategory();
                         $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $id;
                         break;
                 }
             } else {
                 // create a new test_category
                 $test_category = new TestCategory(0, $title, $description);
                 $new_id = $test_category->addCategoryInBDD();
                 $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id] = $new_id;
             }
             $this->course->resources[RESOURCE_TEST_CATEGORY][$id]->destination_id = $tab_test_category_id_old_new[$CourseCopyTestcategory->source_id];
         }
     }
     // lets check if quizzes-question are restored too, to redo the link between test_category and quizzes question for questions restored
     // we can use the source_id field
     // question source_id => category source_id
     if ($this->course->has_resources(RESOURCE_QUIZQUESTION)) {
         // check the category number of each question restored
         if (!empty($resources[RESOURCE_QUIZQUESTION])) {
             foreach ($resources[RESOURCE_QUIZQUESTION] as $id => $CourseCopyQuestion) {
                 $new_quiz_question_id = $resources[RESOURCE_QUIZQUESTION][$id]->destination_id;
                 $question_category = $CourseCopyQuestion->question_category;
                 if ($question_category > 0) {
                     TestCategory::add_category_for_question_id($tab_test_category_id_old_new[$question_category], $new_quiz_question_id, $course_id);
                 }
             }
         }
     }
 }
예제 #28
0
 /**
  * @param int $exerciseId
  * @param int $mediaId
  * @return array
  */
 public function getQuestionCategoriesOfMediaQuestions($exerciseId, $mediaId)
 {
     $questions = $this->getQuestionsPerMediaWithCategories($exerciseId, $mediaId);
     $questionCategoryList = array();
     if (!empty($questions)) {
         foreach ($questions as $question) {
             $categories = TestCategory::getCategoryForQuestionWithCategoryData($question['iid']);
             if (!empty($categories)) {
                 foreach ($categories as $category) {
                     $questionCategoryList[$question['iid']][] = $category['iid'];
                 }
             }
         }
     }
     return $questionCategoryList;
 }
예제 #29
0
if ($from != $to) {
    $subtitle = trans("messages.from") . ' ' . $from . ' ' . trans("messages.to") . ' ' . $to;
} else {
    $subtitle = trans("messages.for") . ' ' . date('Y');
}
if ($interval == 'M') {
    $subtitle .= ' (' . trans("messages.monthly") . ') ';
} else {
    if ($interval == 'D') {
        $subtitle .= ' (' . trans("messages.daily") . ') ';
    } else {
        $subtitle .= ' (' . trans("messages.weekly") . ') ';
    }
}
if ($testCategory) {
    $subtitle .= ' - ' . TestCategory::find($testCategory)->name;
}
if ($testType) {
    $subtitle .= '(' . TestType::find($testType)->name . ')';
}
echo '"' . $subtitle . '"';
?>
		   },
		  credits: {
		        enabled: 'false'
		  },
		  xAxis: {
			 type: 'datetime',
			 dateTimeLabelFormats: { 
				month: '%e. %b',
				year: '%b'