Skip to content

Commit

Permalink
Merge pull request #15 from openeyes/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
splatEric committed Apr 9, 2020
2 parents 123511c + a49f3c9 commit 269b1cf
Show file tree
Hide file tree
Showing 115 changed files with 806 additions and 3,086 deletions.
6 changes: 3 additions & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
-->

<!--
Include all sniffs in the PEAR standard. Note that the
Include all sniffs in the PSR12 standard. Note that the
path to the standard does not have to be specified as the
PEAR standard exists inside the PHP_CodeSniffer install
PSR12 standard exists inside the PHP_CodeSniffer install
directory.
-->
<rule ref="PSR2">
<rule ref="PSR12">
<!-- Too many classes are already defined in OE that do not conform to this rule -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion protected/assets/js/OpenEyes.UI.RestrictData.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ OpenEyes.UI = OpenEyes.UI || {};
Switch to array for better support
*/
let arr = Array.prototype.slice.call(collapseData);
arr.forEach( ( elem ) => { hideShowBtn( elem ); });
arr.forEach( ( elem ) => { hideShowBtn( elem );$(elem).trigger('loaded'); });
};

exports.RestrictDataController = RestrictDataController;
Expand Down
10 changes: 6 additions & 4 deletions protected/assets/js/analytics/analytics_cataract.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ var analytics_cataract = (function () {

function toggleAllSurgeonOpt() {
$(this).toggleClass('green hint');
$(this).blur();
if ($('#analytics_allsurgeons').val() == 'on') {
$('#analytics_allsurgeons').val('');
} else {
Expand All @@ -282,10 +283,11 @@ var analytics_cataract = (function () {
}

function clearDate(event_date) {
var date_from = analytics_toolbox.processDate(new Date(event_date['date_from']))
var date_to = analytics_toolbox.processDate(new Date(event_date['date_to']))
$('#analytics_datepicker_from').val(date_from);
$('#analytics_datepicker_to').val(date_to);
var date_from = new Date(event_date['date_from']);
var date_to = new Date(event_date['date_to']);
pickmeup('#analytics_datepicker_from').set_date(date_from);

pickmeup('#analytics_datepicker_to').set_date(date_to);
}

var init = function (data) {
Expand Down
10 changes: 6 additions & 4 deletions protected/assets/js/analytics/analytics_drill_down.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var analytics_drill_down = (function () {

var request_url = '/analytics/getdrilldown';
function patientDetails() {
$('#js-analytics-spinner').show();
var link = $(this).data('link');
window.location.href = link;
$(this).css('background-color', '#28303b');
window.open(link, '_blank');
}

function getPatient() {
Expand Down Expand Up @@ -187,10 +187,12 @@ var analytics_drill_down = (function () {
patient_list_container.addClass('analytics-event-list');
$('<th class="text-left" style="vertical-align: center;">Eye</th>').insertBefore('.analytics-patient-list .patient_procedures');
$('<th style="vertical-align: center;">Date</th>').insertAfter('.analytics-patient-list .patient_procedures');
colGroup.append('<col style="width: 350px;"><col style="width: 50px;"><col style="width: 400px;"><col style="width: 100px;">');
// the width for eye, procedures, date columns
colGroup.append('<col style="width: 3.5%x;"><col style="width: 24%;"><col style="width: 7%;">');
} else {
// set up patient list dom layout for non cataract
colGroup.append('<col style="width: 450px;"><col style="width: 450px;">');
// for procedures column
colGroup.append('<col style="width: 24%;">');
}
// deep copy from passed in data
g_data = custom_data.slice();
Expand Down
9 changes: 2 additions & 7 deletions protected/assets/js/analytics/analytics_toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,16 @@ var analytics_toolbox = (function () {
function initDatePicker(def) {
var date_from = typeof (def) === 'undefined' ? false : new Date(def['date_from']);
var date_to = typeof (def) === 'undefined' ? false : new Date(def['date_to']);
if (date_from && date_to) {
date_from = processDate(date_from);

date_to = processDate(date_to);
}

pickmeup('#analytics_datepicker_from', {
format: 'Y-m-d',
format: 'd-b-Y',
date: date_from,
hide_on_select: true,
default_date: date_from,
});

pickmeup('#analytics_datepicker_to', {
format: 'Y-m-d',
format: 'd-b-Y',
date: date_to,
hide_on_select: true,
default_date: date_to,
Expand Down
3 changes: 3 additions & 0 deletions protected/assets/js/dashboard/OpenEyes.Dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@
chart.data[1]['customdata'] = incompletedData.map(function (item) {
return item;
});
hovertemplate = '%{x} %{y} of Total ' + data['total'] + ' Ops';
chart.data[0]['hovertemplate'] = hovertemplate;
chart.data[1]['hovertemplate'] = hovertemplate;
Plotly.redraw(chart);
},

Expand Down
19 changes: 10 additions & 9 deletions protected/commands/ImportDrugsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ public function copyToOE()

$cmd = "UPDATE medication
SET default_dose_unit_term = 'drop'
WHERE m.preferred_term like '%eye drop%'";
WHERE preferred_term like '%eye drop%'";

Yii::app()->db->createCommand($cmd)->execute();

Expand Down Expand Up @@ -948,7 +948,7 @@ private function convertMappedUOMsToPlural()

$cmd = "UPDATE medication_attribute_option SET description = CONCAT(description,\"(s)\") WHERE ";
foreach ($this->uom_to_forms_mapping as $uom => $forms) {
if ($uom != "Drop"){ // we don't want plural for Drop(s) as they are almost always 1 drop in opthalmology (DA decision 02/04/2020)
if (strtolower($uom) != "drop") { // we don't want plural for Drop(s) as they are almost always 1 drop in opthalmology (DA decision 02/04/2020)
$cmd .= "(BINARY description = \"$uom\") OR ";
}
}
Expand Down Expand Up @@ -976,20 +976,21 @@ private function applyUOMToMedications()
";
Yii::app()->db->createCommand($cmd)->execute();


$cmd = "UPDATE medication as med
JOIN (
foreach (['UNIT_OF_MEASURE', 'UNIT_DOSE_UNIT_OF_MEASURE'] as $uom_attr) {
$cmd = "UPDATE medication as med
INNER JOIN (
SELECT maa.medication_id AS med_id, mao.description AS UOM
FROM medication_attribute_option mao
JOIN medication_attribute_assignment maa
INNER JOIN medication_attribute_assignment maa
ON maa.medication_attribute_option_id = mao.id
JOIN medication_attribute ma
INNER JOIN medication_attribute ma
ON mao.medication_attribute_id = ma.id
WHERE ma.name = \"UNIT_OF_MEASURE\"
WHERE ma.name = \"{$uom_attr}\"
) AS uom_table ON med.id = uom_table.med_id
SET med.default_dose_unit_term = uom_table.UOM";

Yii::app()->db->createCommand($cmd)->execute();
Yii::app()->db->createCommand($cmd)->execute();
}

$cmd = "UPDATE medication
SET default_dose = 1
Expand Down
4 changes: 2 additions & 2 deletions protected/commands/OldMedicationAndDrugDeletionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ private function deleteOldDrugAndMedicationTables()
'site_subspecialty_drug',
'medication_drug',
];
$tables_to_ignore = ['drug_duration'];

foreach (Yii::app()->db->getSchema()->getTableNames() as $table_to_rename) {
if (((substr($table_to_rename, 0, strlen($drugTableSuffix)) === $drugTableSuffix) || in_array($table_to_rename, $tables_to_rename)) && !in_array($table_to_rename, $tables_to_ignore)) {
if (((substr($table_to_rename, 0, strlen($drugTableSuffix)) === $drugTableSuffix) || in_array($table_to_rename, $tables_to_rename))) {
Yii::app()->db->createCommand("RENAME TABLE " . $table_to_rename . " TO archive_" . $table_to_rename)->execute();
}
}
Expand Down
44 changes: 33 additions & 11 deletions protected/commands/PopulateAutoMedicationSetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

class PopulateAutoMedicationSetsCommand extends CConsoleCommand
{
private $_pid;
private $_pidfile = '/tmp/oe_populatesets.pid';
private $lock_name = "PopulateAutoMedicationSetsCommand_lock";

public function getHelp()
{
Expand All @@ -30,13 +29,15 @@ public function run($args)
$t = microtime(true);
echo "[" . (date("Y-m-d H:i:s")) . "] PopulateAutoMedicationSets ... ";

$this->_pid = getmypid();

if ($this->_isRunning()) {
if ($this->_isRunning() || !$this->acquireLock()) {
echo "Another process is already being run." . PHP_EOL;
exit(1);
}

register_shutdown_function(function () {
$this->releaseLock();
});

//populate whole set unless we are given specific set number to reduce time on rebuilding sets on admin page
if (empty($args)) {
MedicationSet::populateAutoSets();
Expand All @@ -53,12 +54,33 @@ public function run($args)

private function _isRunning()
{
if (file_exists($this->_pidfile)) {
$pid = filter_var(file_get_contents($this->_pidfile), FILTER_SANITIZE_NUMBER_INT);
return file_exists("/proc/$pid");
} else {
return false;
}
return (bool) Yii::app()->db->createCommand(
'SELECT IS_USED_LOCK(:name)'
)->bindValue(':name', $this->lock_name)
->queryScalar();
}

/**
* @return bool acquiring result
*/
private function acquireLock()
{
return (bool) Yii::app()->db->createCommand(
'SELECT GET_LOCK(:name, :timeout)',
)->bindValue(':name', $this->lock_name)
->bindValue(':timeout', 0) // timeout = 0 means that the method will return false immediately in case lock is used
->queryScalar();
}

/**
* @return bool release result
*/
private function releaseLock()
{
return (bool) Yii::app()->db->createCommand(
'SELECT RELEASE_LOCK(:name)'
)->bindValue(':name', $this->lock_name)
->queryScalar();
}

public function actionCheckRunning()
Expand Down
7 changes: 7 additions & 0 deletions protected/components/DbFixtureManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class DbFixtureManager extends CDbFixtureManager
{
protected $fixtures = array();

/**
* @throws CDbException
* @throws CException
*/
public function init()
{
$paths = array($this->basePath ?: Yii::getPathOfAlias('application.tests.fixtures'));
Expand Down Expand Up @@ -64,6 +68,7 @@ public function getFixtures()

/**
* @param string $tableName
* @throws CException
*/
public function resetTable($tableName)
{
Expand All @@ -79,6 +84,8 @@ public function resetTable($tableName)
* @param string $table_name
*
* @return array|false
* @throws CDbException
* @throws CException
*/
public function loadFixture($table_name)
{
Expand Down
Loading

0 comments on commit 269b1cf

Please sign in to comment.