Skip to content

Commit

Permalink
Dicom viewer update (openemr#3762)
Browse files Browse the repository at this point in the history
* Dicom viewer update
- more controller zip stuff
- add viewer to menu

* - fix php 8 warning final for private functions
  • Loading branch information
sjpadgett authored Jul 19, 2020
1 parent e7408da commit 65636bc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
10 changes: 8 additions & 2 deletions controllers/C_Document.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ function zip_dicom_folder($study_name = null)
foreach ($_FILES['dicom_folder']['name'] as $i => $name) {
$zfn = $GLOBALS['temporary_files_dir'] . "/" . $name;
$fparts = pathinfo($name);
if (empty($fparts['extension'])) {
// viewer requires lowercase.
$fparts['extension'] = "dcm";
$name = $fparts['filename'] . ".dcm";
}
if ($fparts['extension'] == "DCM") {
// viewer requires lowercase.
$fparts['extension'] = "dcm";
Expand Down Expand Up @@ -250,9 +255,10 @@ function upload_action_process()
unset($head);
// if here -then a DICOM
$parts = pathinfo($stat['name']);
if ($parts['extension'] != "dcm") { // required extension for viewer
if ($parts['extension'] != "dcm" || empty($parts['extension'])) { // required extension for viewer
$new_name = $parts['filename'] . ".dcm";
$za->renameName($i, $new_name); // viewer requires lowercase
$za->renameIndex($i, $new_name);
$za->renameName($parts['filename'], $new_name);
}
} else { // Rarely here
$mimetype = "application/zip";
Expand Down
12 changes: 12 additions & 0 deletions interface/main/tabs/menu/menus/standard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,18 @@
"portal"
]
},
{
"label": "Dicom Viewer",
"menu_id": "dvwr",
"target": "msc",
"url": "/library/dicom_frame.php",
"children": [],
"requirement": 0,
"acl_req": [
"patients",
"docs"
]
},
{
"label": "Patient Education",
"menu_id": "ped0",
Expand Down
76 changes: 38 additions & 38 deletions portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Criteria
private $_or = array ();
public $PrimaryKeyField;
public $PrimaryKeyValue;

/**
*
* @var $Filters a CriteriaFilter or array of CriteriaFilters to be applied to the query
Expand All @@ -47,13 +47,13 @@ public function __construct($where = "", $order = "")
{
$this->_constructor_where = $where;
$this->_constructor_order = $order;

$this->_where = $where;
$this->_order = $order;

$this->Init();
}

/**
* Init is called directly after construction and can be overridden.
* If the
Expand All @@ -65,7 +65,7 @@ protected function Init()
{
$this->_map_object_class = str_replace("Criteria", "Map", get_class($this));
}

/**
* Add a CriteriaFilter to the criteria for custom filtering of results
*
Expand All @@ -79,7 +79,7 @@ public function AddFilter(CriteriaFilter $filter)

$this->Filters [] = $filter;
}

/**
* Return an array of CriteriaFilters that have been added to this criteria
*
Expand All @@ -89,15 +89,15 @@ public function GetFilters()
{
return $this->Filters;
}

/**
* Remove all filters that are currently attached
*/
public function ClearFilters()
{
$this->Filters = null;
}

/**
* Adds a criteria to be joined w/ an "and" statement.
* Criterias to foreign objects may be added as long as they
Expand All @@ -113,7 +113,7 @@ public function AddAnd(Criteria $criteria, $keymap_id = null)
{
$this->_and [] = $criteria;
}

/**
* Return any and criterias that have been added to this criteria
*
Expand All @@ -123,7 +123,7 @@ public function GetAnds()
{
return $this->_and;
}

/**
* Escape values for insertion into a SQL query string
*
Expand All @@ -133,7 +133,7 @@ public function Escape($val)
{
return DataAdapter::Escape($val);
}

/**
* Returns DataAdapter::GetQuotedSql($val)
*
Expand All @@ -145,7 +145,7 @@ public function GetQuotedSql($val)
{
return DataAdapter::GetQuotedSql($val);
}

/**
* Adds a criteria to be joined w/ an "or" statement.
* Criterias to foreign objects may be added as long as they
Expand All @@ -161,7 +161,7 @@ public function AddOr(Criteria $criteria, $keymap_id = null)
{
$this->_or [] = $criteria;
}

/**
* Return any 'or' criterias that have been added to this criteria
*
Expand All @@ -171,7 +171,7 @@ public function GetOrs()
{
return $this->_or;
}

/**
* Reset the Criteria for re-use.
* This is called by querybuilder after the criteria has been used
Expand All @@ -183,7 +183,7 @@ public function Reset()
$this->_where = $this->_constructor_where;
$this->_order = $this->_constructor_order;
}

/**
* Prepare is called just prior to execution and will fire OnPrepare after it completes
* If this is a base Criteria class, then we can only do a lookup by PrimaryKeyField or
Expand All @@ -192,7 +192,7 @@ public function Reset()
* used by inherited Criteria classes because we don't know what table this is associated
* with, so we can't translate property names to column names.
*/
final private function Prepare()
final protected function Prepare()
{
if (! $this->_is_prepared) {
if (get_class($this) == "Criteria") {
Expand All @@ -207,18 +207,18 @@ final private function Prepare()
// build a query based on any values that have been set
$this->_where = '';
$this->_where_delim = '';

$props = get_object_vars($this);
foreach ($props as $prop => $val) {
// TODO: tighten this up a bit to reduce redundant code
if ($prop == "Filters" && isset($val) && (is_array($val) || is_a($val, 'CriteriaFilter'))) {
// a filter object will take care of generating it's own where statement

// normalize the input to accept either an individual filter or multiple filters
$filters = (is_array($val)) ? $val : array (
$val
);

foreach ($filters as $filter) {
$this->_where .= $this->_where_delim . ' ' . $filter->GetWhere($this);
$this->_where_delim = " and";
Expand Down Expand Up @@ -288,7 +288,7 @@ final private function Prepare()
if (! is_array($val)) {
$val = explode(',', $val);
}

// if the count is zero, technically the user is saying that they don't
// want any results. the only way to do that is to make the criteria
// something that will for sure not match any existing records. we cannot
Expand All @@ -297,7 +297,7 @@ final private function Prepare()
if (count($val) == 0) {
array_push($val, "$prop EMPTY PHREEZE CRITERIA ARRAY");
}

$dbfield = $this->GetFieldFromProp(str_replace("_In", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " in (";
$indelim = "";
Expand All @@ -313,7 +313,7 @@ final private function Prepare()
if (! is_array($val)) {
$val = explode(',', $val);
}

// if the count is zero, technically the user is saying that they don't
// want any results. the only way to do that is to make the criteria
// something that will for sure not match any existing records. we cannot
Expand All @@ -322,7 +322,7 @@ final private function Prepare()
if (count($val) == 0) {
array_push($val, "$prop EMPTY PHREEZE CRITERIA ARRAY");
}

$dbfield = $this->GetFieldFromProp(str_replace("_NotIn", "", $prop));
$this->_where .= $this->_where_delim . " " . $dbfield . " not in (";
$indelim = "";
Expand All @@ -336,17 +336,17 @@ final private function Prepare()
}
}
}

// prepend the sql so the statement will work correctly
if ($this->_where) {
$this->_where = " where " . $this->_where;
}

// if the user has called SetOrder then use that for the order
if ($this->_set_order) {
$this->_order = $this->_set_order;
}

// if any of the filters have an order by then add those
if (is_array($this->Filters)) {
$orderDelim = $this->_order ? ',' : '';
Expand All @@ -358,11 +358,11 @@ final private function Prepare()
}
}
}

if ($this->_order) {
$this->_order = " order by " . $this->_order;
}

$this->OnPrepare();
$this->_is_prepared = true;
}
Expand All @@ -385,7 +385,7 @@ final public function GetOrder()
$this->Prepare();
return $this->_order;
}

/**
* Adds an object property to the order by clause.
* If any sorting needs to be done
Expand All @@ -404,9 +404,9 @@ public function SetOrder($property, $desc = false)
// no property was specified.
return;
}

$this->_order_delim = ($this->_set_order) ? "," : "";

if ($property == '?') {
$this->_set_order = "RAND()" . $this->_order_delim . $this->_set_order;
} else {
Expand All @@ -420,7 +420,7 @@ private function InitMaps()
// we have to open the file to get the fieldmaps
$mapname = $this->_map_object_class;
$this->IncludeMap($mapname);

$this->_fieldmaps = call_user_func(array (
$mapname,
"GetFieldMaps"
Expand All @@ -431,7 +431,7 @@ private function InitMaps()
));
}
}

/**
* If the map class is not already defined, attempts to require_once the definition.
* If the Map file cannot be located, an exception is thrown
Expand Down Expand Up @@ -463,20 +463,20 @@ public function GetFieldFromProp($propname)
if (get_class($this) == "Criteria") {
throw new Exception("Phreeze is unable to determine field mapping. The base Criteria class should only be used to query by primary key without sorting");
}

$fms = $this->GetFieldMaps();

// make sure this property is defined
if (! isset($fms [$propname])) {
throw new Exception(get_class($this) . " is unable to determine the database column for the property: '$propname'");
}

// print_r($this->_fieldmaps);
$fm = $fms [$propname];

return $fm->FieldType == FM_CALCULATION ? "(" . $fm->ColumnName . ")" : "`" . $fm->TableName . "`.`" . $fm->ColumnName . "`";
}

/**
* Throw an exception if an undeclared property is accessed
*
Expand All @@ -490,7 +490,7 @@ public function __get($key)
throw new Exception("Unknown property: $key");
}
}

/**
* Throw an exception if an undeclared property is accessed
*
Expand Down

0 comments on commit 65636bc

Please sign in to comment.