From 8aaa4ce1bc92209516a9d9ac21c2e6d5858ed77d Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 20 Dec 2020 11:06:04 +0200 Subject: [PATCH 01/37] readme file --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index 23911e6..4a528c4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,47 @@ +## What is clinikal? + +Clinikal is a Electric Medical Records application. +Clinical offers a new experience of administrative and medical management for variety of clinics. +The foundation of the application is the popular open source [OpenEMR](https://github.com/openemr/openemr), we developed new layer of Fhir API base on ZF2 modules and new and modern React.js application to enjoy from wonderful user experience. +Clinikal continues to use OpenEMR interfaces as Content Management System for manage users, permissions, lists etc. (we doesn't supply compatibility with all Openemr screens) + +The principle that guides us is **clean and clear**. +Each user sees only the screens and forms relevant to his role in the clinic. +This ability is caused by using a system of roles and privileges for each profession in the clinic and a different installation process for each medical field which creates an innovative and convenient user experience! + +### Get started and documentation +To get started and documentation at https://clinikal-documentation.readthedocs.io/ + +### Clinikal-beckend +The product composed of a few component, Server-side modules and client-side application. +This repository contains several modules and configurations that common for all the medical fields in the system. +The repository contains: +* API layer +* General functionality +* Custom menus +* Import data module +* More helpers + +### Resources +* [Docker installation](https://clinikal-documentation.readthedocs.io/en/latest/get_started/docker_installation/) +* [Manual installation](https://clinikal-documentation.readthedocs.io/en/latest/get_started/openemr_modules/) +* [Internationalization](https://clinikal-documentation.readthedocs.io/en/latest/get_started/internationalization/) +* [FHIR API](https://clinikal-documentation.readthedocs.io/en/latest/api/fhir/) + +### License +Please see the [license agreement](https://github.com/israeli-moh/clinikal-react/blob/develop/LICENSE). + +### Acknowledgement +The Clinikal team would like to thank Israeli Ministry Of Health that sponsored this project. + + + + + + + + + # Description This repository contains modules that add functionality to Openemr. From bd9a3a6f219f10dc0c7fa4adfbc5d159bdf3edda Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 20 Dec 2020 11:08:57 +0200 Subject: [PATCH 02/37] readme file --- README.md | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/README.md b/README.md index 4a528c4..b67e4a5 100644 --- a/README.md +++ b/README.md @@ -34,52 +34,3 @@ Please see the [license agreement](https://github.com/israeli-moh/clinikal-react ### Acknowledgement The Clinikal team would like to thank Israeli Ministry Of Health that sponsored this project. - - - - - - - - -# Description -This repository contains modules that add functionality to Openemr. - -# Installation -These instructions assume you have a working installation of Openemr. - -Add the following to the openemr/composer.json: -``` json -"repositories": [ - { - "type": "vcs", - "url": "git@github.com:israeli-moh/clinikal-backend.git" - }, - { - "type": "vcs", - "url": "git@github.com:israeli-moh/composer-installers-clinikal-extender.git" - } -], -"require": { - "clinikal/clinikal-backend": "dev-master", - "clinikal/composer-installers-clinikal-extender": "dev-master" -}, -"extra": { - "installer-types": [ - "clinikal-vertical" - ], -} -``` - -In a terminal, `cd` into the openemr root directory (where the composer.json is), and run: -``` -composer update clinikal -``` - -This downloads the modules code into the openemr/vendor/clinikal and triggers the composer installer extension in the composer-installers-clinikal-extender repository. -The extension creates links from the files in vendor/clinikal to there appropriate places in the openemr codebase. -This enables us to use any modules, styles, and menus downloaded by composer into the vendor/clinikal directory. - -All modules can now be registered and enabled in the Manage Modules screen. - -This project is sponsored by the Israeli Ministry Of Health. From d53ed91feffc72fa4bd0b94e3d0a0f87bcb5de01 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 20 Dec 2020 11:50:13 +0200 Subject: [PATCH 03/37] readme file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b67e4a5..216015c 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ To get started and documentation at https://clinikal-documentation.readthedocs.i ### Clinikal-beckend The product composed of a few component, Server-side modules and client-side application. -This repository contains several modules and configurations that common for all the medical fields in the system. -The repository contains: +This repository is part of server-side components and contains several modules and configurations that common for all the medical fields in the system. +Main contents: * API layer * General functionality * Custom menus From 5ce1e215446f06174b17c02fe202c1150de6983f Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 20 Dec 2020 11:52:07 +0200 Subject: [PATCH 04/37] readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 216015c..7400e6d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This ability is caused by using a system of roles and privileges for each profes To get started and documentation at https://clinikal-documentation.readthedocs.io/ ### Clinikal-beckend -The product composed of a few component, Server-side modules and client-side application. +The product composed of a few component, Server-side modules and client-side application. This repository is part of server-side components and contains several modules and configurations that common for all the medical fields in the system. Main contents: * API layer From 0e84b83af9e413d63077b2a5768748083561877c Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 20 Dec 2020 14:11:37 +0200 Subject: [PATCH 05/37] up modules versions --- .../sql/1_0_0-to-2_0_0_upgrade.sql | 92 +++++++++++++++++++ modules/ClinikalAPI/version.php | 6 +- .../FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql | 92 +++++++++++++++++++ modules/FhirAPI/version.php | 6 +- .../sql/1_0_0-to-2_0_0_upgrade.sql | 92 +++++++++++++++++++ modules/GenericTools/version.php | 6 +- .../ImportData/sql/1_0_0-to-2_0_0_upgrade.sql | 92 +++++++++++++++++++ modules/ImportData/version.php | 6 +- modules/ReportTool/version.php | 5 + 9 files changed, 385 insertions(+), 12 deletions(-) create mode 100644 modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql create mode 100644 modules/FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql create mode 100644 modules/GenericTools/sql/1_0_0-to-2_0_0_upgrade.sql create mode 100644 modules/ImportData/sql/1_0_0-to-2_0_0_upgrade.sql create mode 100644 modules/ReportTool/version.php diff --git a/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql b/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql new file mode 100644 index 0000000..8a631ba --- /dev/null +++ b/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql @@ -0,0 +1,92 @@ +-- +-- Comment Meta Language Constructs: +-- +-- #IfNotTable +-- argument: table_name +-- behavior: if the table_name does not exist, the block will be executed + +-- #IfTable +-- argument: table_name +-- behavior: if the table_name does exist, the block will be executed + +-- #IfColumn +-- arguments: table_name colname +-- behavior: if the table and column exist, the block will be executed + +-- #IfMissingColumn +-- arguments: table_name colname +-- behavior: if the table exists but the column does not, the block will be executed + +-- #IfNotColumnType +-- arguments: table_name colname value +-- behavior: If the table table_name does not have a column colname with a data type equal to value, then the block will be executed + +-- #IfNotRow +-- arguments: table_name colname value +-- behavior: If the table table_name does not have a row where colname = value, the block will be executed. + +-- #IfNotRow2D +-- arguments: table_name colname value colname2 value2 +-- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2, the block will be executed. + +-- #IfNotRow3D +-- arguments: table_name colname value colname2 value2 colname3 value3 +-- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed. + +-- #IfNotRow4D +-- arguments: table_name colname value colname2 value2 colname3 value3 colname4 value4 +-- behavior: If the table table_name does not have a row where colname = value AND colname2 = value2 AND colname3 = value3 AND colname4 = value4, the block will be executed. + +-- #IfNotRow2Dx2 +-- desc: This is a very specialized function to allow adding items to the list_options table to avoid both redundant option_id and title in each element. +-- arguments: table_name colname value colname2 value2 colname3 value3 +-- behavior: The block will be executed if both statements below are true: +-- 1) The table table_name does not have a row where colname = value AND colname2 = value2. +-- 2) The table table_name does not have a row where colname = value AND colname3 = value3. + +-- #IfRow2D +-- arguments: table_name colname value colname2 value2 +-- behavior: If the table table_name does have a row where colname = value AND colname2 = value2, the block will be executed. + +-- #IfRow3D +-- arguments: table_name colname value colname2 value2 colname3 value3 +-- behavior: If the table table_name does have a row where colname = value AND colname2 = value2 AND colname3 = value3, the block will be executed. + +-- #IfIndex +-- desc: This function is most often used for dropping of indexes/keys. +-- arguments: table_name colname +-- behavior: If the table and index exist the relevant statements are executed, otherwise not. + +-- #IfNotIndex +-- desc: This function will allow adding of indexes/keys. +-- arguments: table_name colname +-- behavior: If the index does not exist, it will be created + +-- #EndIf +-- all blocks are terminated with a #EndIf statement. + +-- #IfNotListReaction +-- Custom function for creating Reaction List + +-- #IfNotListOccupation +-- Custom function for creating Occupation List + +-- #IfTextNullFixNeeded +-- desc: convert all text fields without default null to have default null. +-- arguments: none + +-- #IfTableEngine +-- desc: Execute SQL if the table has been created with given engine specified. +-- arguments: table_name engine +-- behavior: Use when engine conversion requires more than one ALTER TABLE + +-- #IfInnoDBMigrationNeeded +-- desc: find all MyISAM tables and convert them to InnoDB. +-- arguments: none +-- behavior: can take a long time. + +-- #IfTranslationNeeded +-- desc: find all MyISAM tables and convert them to InnoDB. +-- arguments: constant_name english hebrew +-- behavior: can take a long time. + diff --git a/modules/ClinikalAPI/version.php b/modules/ClinikalAPI/version.php index e2d742c..e5e2435 100644 --- a/modules/ClinikalAPI/version.php +++ b/modules/ClinikalAPI/version.php @@ -1,5 +1,5 @@ Date: Mon, 28 Dec 2020 15:07:37 +0200 Subject: [PATCH 06/37] fix EM-460 --- .../Controller/PdfBaseController.php | 13 +++++++++++- .../FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql | 16 ++++++++++++++ modules/FhirAPI/sql/install.sql | 21 +++++++++---------- .../Observation/FhirObservationMapping.php | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php index 326a13a..bd6fe29 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php @@ -279,6 +279,11 @@ public function getConstantVitals($pid,$category,$acitivity,$order) foreach ($v as $key => $value) { if ($key !== 'height' && $key !== 'weight') { unset($vitals[$k][$key]); + } else { + $vitals[$k][$key][2] = (is_null($value[2]) || $value[2] == "" || $value[2] == 0 && $value[2] == "0.00") ?"-":$value[2]; + if ($key === 'weight' && $vitals[$k][$key][2] !== '-') { + $vitals[$k][$key][2] = number_format($value[2],1); + } } } } @@ -301,7 +306,7 @@ public function getVariantVitals($pid,$category,$acitivity,$order) $vitals[$key]['pressure'][$k] = $vitals[$key]['bpd'][$k]; } else { - $vitals[$key]['pressure'][$k] = $vitals[$key]['bpd'][$k] . "/" . $vitals[$key]['bps'][$k]; + $vitals[$key]['pressure'][$k] = $vitals[$key]['bps'][$k] . "/" . $vitals[$key]['bpd'][$k]; } } @@ -316,6 +321,12 @@ public function getVariantVitals($pid,$category,$acitivity,$order) case 'head_circ': unset($vitals[$key][$k]); break; + case 'temperature': + $vitals[$key][$k][2] = number_format($vitals[$key][$k][2],1); + case 'pulse': + case 'respiration': + case 'oxygen_saturation': + $vitals[$key][$k][2] = number_format($vitals[$key][$k][2],0); case 'date': $time = explode(":",$vitals[$key][$k][1]); unset($time[2]); diff --git a/modules/FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql b/modules/FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql index 8a631ba..4790d2b 100644 --- a/modules/FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql +++ b/modules/FhirAPI/sql/1_0_0-to-2_0_0_upgrade.sql @@ -90,3 +90,19 @@ -- arguments: constant_name english hebrew -- behavior: can take a long time. +REPLACE INTO `list_options` (`list_id`, `option_id`, `title`, `seq`,`mapping` ,`notes`, `activity`,`subtype`) VALUES +('loinc_org', '8480-6', 'Systolic blood pressure', 10,'bps','{"mask": "___","label":"Blood pressure"}', 1,'mmHg'), +('loinc_org', '8462-4', 'Diastolic blood pressure', 20,'bpd','{"mask": "___","label":"Blood pressure"}', 1,'mmHg'), +('loinc_org', '8308-9', 'Body height --standing', 30,'height','{"label": "Height","mask":"___"}', 1,'cm'), +('loinc_org', '8335-2', 'Body weight Estimated', 40,'weight','{"label": "Weight","mask":"___._"}', 1,'Kg'), +('loinc_org', '69000-8','Heart rate --sitting', 50,'pulse','{"label": "Pulse","mask": "___"}', 1,'PRA'), +('loinc_org', '8310-5', 'Body temperature', 60,'temperature','{"label": "Fever","mask": "__._"}', 1,'C'), +('loinc_org', '8327-9', 'Body temperature measurement site', 70,'temp_method','', 1,''), +('loinc_org', '20564-1', 'Oxygen saturation in Blood', 80,'oxygen_saturation','{"label": "Saturation","mask": "___%"}', 1,'%'), +('loinc_org', '39156-5', 'Body mass index (BMI) [Ratio]', 90,'BMI','', 1,'kg/m2'), +('loinc_org', '59574-4', 'Body mass index (BMI) [Percentile]', 100,'BMI_status','', 1,''), +('loinc_org', '8280-0', 'Waist Circumference at umbilicus by Tape measure', 110,'waist_circ','', 1,'cm'), +('loinc_org', '8287-5', 'Head Occipital-frontal circumference by Tape measure', 120,'head_circ','', 1,'cm'), +('loinc_org', '9303-9', 'Respiratory rate --resting', 130,'respiration','{"label": "Breaths per minute","mask": "__"}', 1,'BPM'), +('loinc_org', '72514-3', 'Pain severity - 0-10 verbal numeric rating [Score] - Reported', 140,'pain_severity','{"label": "Pain level","mask": "__"}', 1,''), +('loinc_org', '74774-1', 'Glucose [Mass/volume] in Serum, Plasma or Blood', 150,'glucose','{"label": "Blood sugar","mask": "___"}', 1,'mg/dL'); diff --git a/modules/FhirAPI/sql/install.sql b/modules/FhirAPI/sql/install.sql index 502740d..de3b81a 100644 --- a/modules/FhirAPI/sql/install.sql +++ b/modules/FhirAPI/sql/install.sql @@ -246,22 +246,21 @@ ADD `status_update_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `seco INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`,`mapping` ,`notes`, `activity`,`subtype`) VALUES -('lists', 'loinc_org', 'http://loinc.org', 0,'','', 1,''), -('loinc_org', '8480-6', 'Systolic blood pressure', 10,'bps','{"mask": "999","label":"Blood pressure"}', 1,'mmHg'), -('loinc_org', '8462-4', 'Diastolic blood pressure', 20,'bpd','{"mask": "999","label":"Blood pressure"}', 1,'mmHg'), -('loinc_org', '8308-9', 'Body height --standing', 30,'height','{"label": "Height","mask":"999"}', 1,'cm'), -('loinc_org', '8335-2', 'Body weight Estimated', 40,'weight','{"label": "Weight","mask":"999.9"}', 1,'Kg'), -('loinc_org', '69000-8','Heart rate --sitting', 50,'pulse','{"label": "Pulse","mask": "99"}', 1,'PRA'), -('loinc_org', '8310-5', 'Body temperature', 60,'temperature','{"label": "Fever","mask": "99.9"}', 1,'C'), +('loinc_org', '8480-6', 'Systolic blood pressure', 10,'bps','{"mask": "___","label":"Blood pressure"}', 1,'mmHg'), +('loinc_org', '8462-4', 'Diastolic blood pressure', 20,'bpd','{"mask": "___","label":"Blood pressure"}', 1,'mmHg'), +('loinc_org', '8308-9', 'Body height --standing', 30,'height','{"label": "Height","mask":"___"}', 1,'cm'), +('loinc_org', '8335-2', 'Body weight Estimated', 40,'weight','{"label": "Weight","mask":"___._"}', 1,'Kg'), +('loinc_org', '69000-8','Heart rate --sitting', 50,'pulse','{"label": "Pulse","mask": "___"}', 1,'PRA'), +('loinc_org', '8310-5', 'Body temperature', 60,'temperature','{"label": "Fever","mask": "__._"}', 1,'C'), ('loinc_org', '8327-9', 'Body temperature measurement site', 70,'temp_method','', 1,''), -('loinc_org', '20564-1', 'Oxygen saturation in Blood', 80,'oxygen_saturation','{"label": "Saturation","mask": "999%"}', 1,'%'), +('loinc_org', '20564-1', 'Oxygen saturation in Blood', 80,'oxygen_saturation','{"label": "Saturation","mask": "___%"}', 1,'%'), ('loinc_org', '39156-5', 'Body mass index (BMI) [Ratio]', 90,'BMI','', 1,'kg/m2'), ('loinc_org', '59574-4', 'Body mass index (BMI) [Percentile]', 100,'BMI_status','', 1,''), ('loinc_org', '8280-0', 'Waist Circumference at umbilicus by Tape measure', 110,'waist_circ','', 1,'cm'), ('loinc_org', '8287-5', 'Head Occipital-frontal circumference by Tape measure', 120,'head_circ','', 1,'cm'), -('loinc_org', '9303-9', 'Respiratory rate --resting', 130,'respiration','{"label": "Breaths per minute","mask": "99"}', 1,'BPM'), -('loinc_org', '72514-3', 'Pain severity - 0-10 verbal numeric rating [Score] - Reported', 140,'pain_severity','{"label": "Pain level","mask": "99"}', 1,''), -('loinc_org', '74774-1', 'Glucose [Mass/volume] in Serum, Plasma or Blood', 150,'glucose','{"label": "Blood sugar","mask": "999"}', 1,'mg/dL'); +('loinc_org', '9303-9', 'Respiratory rate --resting', 130,'respiration','{"label": "Breaths per minute","mask": "__"}', 1,'BPM'), +('loinc_org', '72514-3', 'Pain severity - 0-10 verbal numeric rating [Score] - Reported', 140,'pain_severity','{"label": "Pain level","mask": "__"}', 1,''), +('loinc_org', '74774-1', 'Glucose [Mass/volume] in Serum, Plasma or Blood', 150,'glucose','{"label": "Blood sugar","mask": "___"}', 1,'mg/dL'); ALTER TABLE `form_vitals` ADD `glucose` INT NULL AFTER `external_id`, diff --git a/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Observation/FhirObservationMapping.php b/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Observation/FhirObservationMapping.php index f520cf4..9246536 100644 --- a/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Observation/FhirObservationMapping.php +++ b/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Observation/FhirObservationMapping.php @@ -191,7 +191,7 @@ public function fhirToDb($FHIRObservation) } $Quantity=$comp->getValueQuantity()->getValue(); - $QuantityVal=$Quantity->getValue(); + $QuantityVal=str_replace('_', '', $Quantity->getValue()); if(!is_null($QuantityVal)){ $lonicCode=$comp->getValueQuantity()->getCode()->getValue(); $dbObservation[$LonicToDbMappig[$lonicCode]]=$QuantityVal; From 3353711cdd33163734d2b00b234e2a3f243fba16 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Tue, 29 Dec 2020 16:56:02 +0200 Subject: [PATCH 07/37] chage sql of valueset - performance issue --- .../src/GenericTools/Model/ValueSetsTable.php | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/modules/GenericTools/src/GenericTools/Model/ValueSetsTable.php b/modules/GenericTools/src/GenericTools/Model/ValueSetsTable.php index 7a44ec8..8f3cb2b 100644 --- a/modules/GenericTools/src/GenericTools/Model/ValueSetsTable.php +++ b/modules/GenericTools/src/GenericTools/Model/ValueSetsTable.php @@ -22,7 +22,58 @@ public function getValueSetById($id,$where = array()) $params= array(); $params[]=$id; - $sql= + $type = $this->getValueSetType($id); + if ($type !== 'Codes') { + $sql = "SELECT + fvs.id AS vs_id, + fvs.title AS vs_title, + fvs.status AS vs_status, + fvss.system AS system, + lo.option_id AS code, + lo.title AS display + FROM + fhir_value_sets AS fvs + JOIN + fhir_value_set_systems AS fvss ON fvs.id = fvss.vs_id + LEFT JOIN + fhir_value_set_codes AS fvsc ON fvss.id = fvsc.vss_id + JOIN list_options AS lo ON fvss.system = lo.list_id + AND ((fvss.type = 'All' + ) + OR (fvss.type = 'Partial' + AND fvsc.code = lo.option_id + ) + OR (fvss.type = 'Exclude' + AND fvsc.code != lo.option_id + ) + OR (fvss.type = 'Filter' + AND fvss.filter = lo.notes + ) + OR (fvss.type = 'Codes') + ) + WHERE + fvs.id = ? "; + } else { + $sql = "SELECT + fvs.id AS vs_id, + fvs.title AS vs_title, + fvs.status AS vs_status, + fvss.system AS system, + co.code AS code, + co.code_text AS display + FROM + fhir_value_sets AS fvs + JOIN + fhir_value_set_systems AS fvss ON fvs.id = fvss.vs_id + LEFT JOIN + fhir_value_set_codes AS fvsc ON fvss.id = fvsc.vss_id + JOIN codes AS co ON fvss.system = co.code_type + WHERE + fvs.id = ? "; + } + + // put original sql in comment - cause very serious performance problems + /* $sql= " SELECT fvs.id as vs_id, fvs.title as vs_title, fvs.status as vs_status, fvss.system as system, lo.a_option_id as code, lo.a_title as display FROM {$this->tableGateway->table} AS fvs @@ -52,7 +103,7 @@ public function getValueSetById($id,$where = array()) ) "; - $sql .= " WHERE fvs.id = ? "; + $sql .= " WHERE fvs.id = ? ";*/ foreach($where as $index => $conditionSet){ @@ -70,13 +121,20 @@ public function getValueSetById($id,$where = array()) $params[]=$condition['value']; $params[]=$condition['value']; - $sql .= "AND ( lo.a_option_id " . $action . " OR lo.a_title " . $action . " ) "; + if ($type !== 'Codes') { + $sql .= "AND ( lo.option_id " . $action . " OR lo.title " . $action . " ) "; + } else { + $sql .= "AND ( co.code " . $action . " OR co.code_text " . $action . " ) "; + } } } } } - - $sql .= " ORDER BY lo.a_list_id, lo.a_seq "; + if ($type !== 'Codes') { + $sql .= " ORDER BY lo.list_id, lo.seq "; + } else { + $sql .= " ORDER BY co.code_type , co.code "; + } $statement = $this->tableGateway->adapter->createStatement($sql, $params); $return = $statement->execute(); @@ -112,4 +170,25 @@ public function getCodeTypeByValueSet($valueSet) } } + public function getValueSetType($valueSetId) + { + $params= array(); + $params[]=$valueSetId; + + $sql = "SELECT type FROM fhir_value_set_systems WHERE vs_id = ?"; + + $statement = $this->tableGateway->adapter->createStatement($sql, $params); + $return = $statement->execute(); + + $results = array(); + foreach ($return as $row) { + $results[] = $row; + } + if (!empty($results)){ + return $results[0]['type']; + }else{ + return null; + } + } + } From d8417d9a9d709ba118ef7e4f72e953ae27f3a246 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Wed, 30 Dec 2020 21:00:26 +0200 Subject: [PATCH 08/37] fix empty pdf page --- .../src/ClinikalAPI/Controller/PdfBaseController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php index bd6fe29..d13c783 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php @@ -188,8 +188,11 @@ public function createBase64Pdf($fileName,$bodyPath,$headerPath, $footerPath,$he { foreach($bodyPath as $key=>$path) { $bodyData=$bodyDataTemp[$key]; + if ($key > 0) { + $this->getPdfService()->pagebreak(); + } $this->getPdfService()->bodyBuilder($path, $bodyData); - $this->getPdfService()->pagebreak(); + } } else { From 00d1531cdae6f7839848385530d65980adbdc3f8 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Mon, 11 Jan 2021 16:46:48 +0200 Subject: [PATCH 09/37] add missing use statement --- .../Parts/Strategy/StrategyElement/Encounter/Encounter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Encounter/Encounter.php b/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Encounter/Encounter.php index caaeccd..d641283 100644 --- a/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Encounter/Encounter.php +++ b/modules/FhirAPI/src/FhirAPI/FhirRestApiBuilder/Parts/Strategy/StrategyElement/Encounter/Encounter.php @@ -18,6 +18,7 @@ use FhirAPI\FhirRestApiBuilder\Parts\Strategy\Strategy; use FhirAPI\Model\QuestionnaireResponseTable; +use GenericTools\Model\DocumentsTable; use GenericTools\Model\FormEncounterTable; use Interop\Container\ContainerInterface; From 491bd11f53eaa5538e4b32dc45433dfcd102b797 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Tue, 12 Jan 2021 14:38:09 +0200 Subject: [PATCH 10/37] fixes - EM-463 --- .../Controller/PdfBaseController.php | 32 +++++++++---------- .../Model/QuestionnaireMapTable.php | 1 + .../src/GenericTools/Model/DocumentsTable.php | 1 - .../GenericTools/Model/FormVitalsTable.php | 4 +-- .../GenericTools/Model/ListsOpenEmrTable.php | 11 +++++-- .../src/GenericTools/Service/PdfService.php | 2 +- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php index d13c783..db3d0d8 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php @@ -78,10 +78,10 @@ public function getPatientInfo($id = null) } } - public function getListsOpenEMRInfo($type=null,$pid,$outcome) + public function getListsOpenEMRInfo($type=null,$pid,$encounter,$outcome) { if (!is_null($type)) { - $info = $this->container->get('GenericTools\Model\ListsOpenEmrTable')->getListWithTheType($type,$pid,$outcome); + $info = $this->container->get('GenericTools\Model\ListsOpenEmrTable')->getListWithTheType($type,$pid,$encounter,$outcome); return $info; } else { @@ -250,13 +250,13 @@ public function getServiceTypeAndReasonCodeArray(){ } public function getSensitivities(){ - return $this->getListsOpenEMRInfo("sensitive",$this->postData['patient'],1); + return $this->getListsOpenEMRInfo("sensitive",$this->postData['patient'],$this->postData['encounter'],1); } public function getMedicalProblems(){ - return $this->getListsOpenEMRInfo("medical_problem",$this->postData['patient'],1); + return $this->getListsOpenEMRInfo("medical_problem",$this->postData['patient'],$this->postData['encounter'],1); } public function getMedicine(){ - return $this->getListsOpenEMRInfo("medication",$this->postData['patient'],1); + return $this->getListsOpenEMRInfo("medication",$this->postData['patient'],$this->postData['encounter'],1); } public function createTableJsonFromVitals($vitals){ $arrTemp = []; @@ -273,9 +273,9 @@ public function createTableJsonFromVitals($vitals){ return $arrTemp; } - public function getConstantVitals($pid,$category,$acitivity,$order) + public function getConstantVitals($encounter,$pid,$category,$acitivity,$order) { - $vitals = $this->getVitals($pid,$category,$acitivity,$order); + $vitals = $this->getVitals($encounter,$pid,$category,$acitivity,$order); foreach($vitals as $k=>$v) { if($k === 0) { @@ -284,8 +284,8 @@ public function getConstantVitals($pid,$category,$acitivity,$order) unset($vitals[$k][$key]); } else { $vitals[$k][$key][2] = (is_null($value[2]) || $value[2] == "" || $value[2] == 0 && $value[2] == "0.00") ?"-":$value[2]; - if ($key === 'weight' && $vitals[$k][$key][2] !== '-') { - $vitals[$k][$key][2] = number_format($value[2],1); + if ($vitals[$k][$key][2] !== '-') { + $vitals[$k][$key][2] = $key === 'weight' ? number_format($value[2],1) : number_format($value[2]); } } } @@ -296,9 +296,9 @@ public function getConstantVitals($pid,$category,$acitivity,$order) } return sizeof($vitals[0]) > 1 ? $this->createTableJsonFromVitals($vitals) : null; } - public function getVariantVitals($pid,$category,$acitivity,$order) + public function getVariantVitals($encounter,$pid,$category,$acitivity,$order) { - $vitals = $this->getVitals($pid,$category,$acitivity,$order); + $vitals = $this->getVitals($encounter,$pid,$category,$acitivity,$order); @@ -325,11 +325,11 @@ public function getVariantVitals($pid,$category,$acitivity,$order) unset($vitals[$key][$k]); break; case 'temperature': - $vitals[$key][$k][2] = number_format($vitals[$key][$k][2],1); + $vitals[$key][$k][2] = $vitals[$key][$k][2] !== '0.00' && $vitals[$key][$k][2] > 0 ? number_format($vitals[$key][$k][2],1) : '-'; case 'pulse': case 'respiration': case 'oxygen_saturation': - $vitals[$key][$k][2] = number_format($vitals[$key][$k][2],0); + $vitals[$key][$k][2] = $vitals[$key][$k][2] !== '0.00' && $vitals[$key][$k][2] > 0 ? number_format($vitals[$key][$k][2],0) : '-'; case 'date': $time = explode(":",$vitals[$key][$k][1]); unset($time[2]); @@ -349,7 +349,7 @@ public function getVariantVitals($pid,$category,$acitivity,$order) return $this->createTableJsonFromVitals($vitals); } - public function getVitals($pid,$category,$acitivity,$order){ + public function getVitals($encounter,$pid,$category,$acitivity,$order){ $observationList = $this->container->get('GenericTools\Model\ListsTable')->getList("loinc_org"); $observationTitleList = []; foreach($observationList as $key=>$value) @@ -357,7 +357,7 @@ public function getVitals($pid,$category,$acitivity,$order){ $notes = json_decode($value['notes']); $observationTitleList[$value['mapping']] = [xl($notes->label),xl($value['subtype'])]; } - $observations = $this->container->get('GenericTools\Model\FormVitalsTable')->getVitals($pid,$category,$acitivity,$order); + $observations = $this->container->get('GenericTools\Model\FormVitalsTable')->getVitals($encounter,$pid,$category,$acitivity,$order); $observedArr = []; foreach($observations as $keyParent=>$valuesParent) @@ -368,7 +368,7 @@ public function getVitals($pid,$category,$acitivity,$order){ $observedArr[$keyParent][$key] = array_merge($observationTitleList[$key], [$value]); } if($key==="date"){ - $observedArr[$keyParent][$key]=[xlt("Hour"), explode(" ",$value)[1]]; + $observedArr[$keyParent][$key]=[xlt("Hour"), oeFormatDateTime($value)]; } } diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php index 91f9264..66e361f 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php @@ -50,6 +50,7 @@ public function getQuestionnaireAnswer($encounter_id=null,$question_id=null){ foreach ($rs as $r) { $rsArray[] = get_object_vars($r); } + print_r($rsArray);DIE; return $rsArray; } } diff --git a/modules/GenericTools/src/GenericTools/Model/DocumentsTable.php b/modules/GenericTools/src/GenericTools/Model/DocumentsTable.php index 3d49ab1..c094edd 100644 --- a/modules/GenericTools/src/GenericTools/Model/DocumentsTable.php +++ b/modules/GenericTools/src/GenericTools/Model/DocumentsTable.php @@ -5,7 +5,6 @@ use GenericTools\Model\UtilsTraits\JoinBuilder; use Laminas\Db\Sql\Select; -use Laminas\Db\Sql\Sql; use Laminas\Db\TableGateway\TableGateway; use Laminas\Db\Sql\Expression; diff --git a/modules/GenericTools/src/GenericTools/Model/FormVitalsTable.php b/modules/GenericTools/src/GenericTools/Model/FormVitalsTable.php index 10c4c51..8da7c61 100644 --- a/modules/GenericTools/src/GenericTools/Model/FormVitalsTable.php +++ b/modules/GenericTools/src/GenericTools/Model/FormVitalsTable.php @@ -15,8 +15,8 @@ public function __construct(TableGateway $tableGateway) $this->tableGateway = $tableGateway; } - public function getVitals($pid,$category,$activity,$order){ - return $this->buildGenericSelect(['pid'=>$pid,'category'=>$category,'activity'=>$activity],$order); + public function getVitals($encounter,$pid,$category,$activity,$order){ + return $this->buildGenericSelect(['eid' => $encounter,'pid'=>$pid,'category'=>$category,'activity'=>$activity],$order); } } diff --git a/modules/GenericTools/src/GenericTools/Model/ListsOpenEmrTable.php b/modules/GenericTools/src/GenericTools/Model/ListsOpenEmrTable.php index 33e4f79..411fefb 100644 --- a/modules/GenericTools/src/GenericTools/Model/ListsOpenEmrTable.php +++ b/modules/GenericTools/src/GenericTools/Model/ListsOpenEmrTable.php @@ -69,7 +69,7 @@ public function fetchListUpToDate($listType,$endDate,$pid) } return $rsArray; } - public function getListWithTheType($type,$pid,$outcome) + public function getListWithTheType($type,$pid,$encounter,$outcome) { /* @@ -94,10 +94,17 @@ public function getListWithTheType($type,$pid,$outcome) ["ct_id","ct_key"], Select::JOIN_RIGHT ); + $this->join = $this->appendJoin( + ["ie"=>"issue_encounter"], + new Expression("ie.pid=lists.pid AND ie.list_id=lists.id"), + ['encounter'=>'encounter','resolved'=>'resolved'], + Select::JOIN_LEFT + ); + //WAIT FOR SOSH $this->joinTables(); // add new join code $this->join = $this->getJoins(); - $rs = $this->buildGenericSelect(['lists.type'=>$type,'lists.outcome'=>$outcome,"lists.pid"=>$pid]); + $rs = $this->buildGenericSelect(['lists.type'=>$type,'lists.outcome'=>$outcome,"lists.pid"=>$pid, "encounter"=>$encounter]); foreach ($rs as $r) { $rsArray[] = xl($r['code_text']); diff --git a/modules/GenericTools/src/GenericTools/Service/PdfService.php b/modules/GenericTools/src/GenericTools/Service/PdfService.php index 913a2f4..3ed92e6 100644 --- a/modules/GenericTools/src/GenericTools/Service/PdfService.php +++ b/modules/GenericTools/src/GenericTools/Service/PdfService.php @@ -255,7 +255,7 @@ public function setCustomHeaderFooter($headerPath,$footerPath,$data=array(),$sho $showDate=($showDate===true) ? 'true' : $showDate; switch ($showDate) { case "datetime": - $showDate= oeFormatDateTime(date("Y-m-d H:m"),false, false); + $showDate= oeFormatDateTime(date("Y-m-d H:i"),false, false); break; case false : $showDate= false; From deb3197f7ce674a032ba5dbf5134052dc96fd5a8 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Tue, 12 Jan 2021 15:04:46 +0200 Subject: [PATCH 11/37] fixes - EM-463 --- .../src/ClinikalAPI/Controller/PdfBaseController.php | 7 +++++++ .../src/ClinikalAPI/Model/QuestionnaireMapTable.php | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php index db3d0d8..e8b211f 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/PdfBaseController.php @@ -6,6 +6,7 @@ use FhirAPI\FhirRestApiBuilder\Parts\Strategy\StrategyElement\ServiceRequest\FhirServiceRequestMapping; use FhirAPI\FhirRestApiBuilder\Parts\Strategy\StrategyElement\ServiceRequest\ServiceRequest; use FhirAPI\Model\FhirServiceRequestTable; +use FhirAPI\Model\QuestionnaireResponseTable; use Formhandler\View\Helper\GenericTable; use GenericTools\Controller\BaseController as GenericBaseController; use GenericTools\Model\AclTables; @@ -420,4 +421,10 @@ public function getDrugForm(){ return $list; } + public function getQuestionareUpdatedUser($encounter, $questionaireName) + { + $result = $this->container->get(QuestionnaireResponseTable::class)->buildGenericSelect(['encounter' => $encounter, 'form_name' => $questionaireName]); + return !empty($result) ? $result[0]['update_by'] : null; + } + } diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php index 66e361f..91f9264 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/QuestionnaireMapTable.php @@ -50,7 +50,6 @@ public function getQuestionnaireAnswer($encounter_id=null,$question_id=null){ foreach ($rs as $r) { $rsArray[] = get_object_vars($r); } - print_r($rsArray);DIE; return $rsArray; } } From c66589f3b943b052fe65c552c6c40134fd8c550b Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Wed, 27 Jan 2021 11:14:37 +0200 Subject: [PATCH 12/37] start point --- .../FormTemplatesManagementController.php | 212 ++++++++++++++++++ .../Model/GetTemplatesServiceTable.php | 2 +- 2 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php new file mode 100644 index 0000000..d66c731 --- /dev/null +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php @@ -0,0 +1,212 @@ +container = $container; + } + + public function TempleteManagementIndexAction() + { +// if (!acl_check('modules', 'warnings_and_contraindications_management', '', 'write')) { +// $this->redirect()->toRoute('errors', array('action' => 'access-denied')); +// } + + /*$data = $this->getVacListMailsTable()->fetchAll(); + $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); + $recipient_mail = $this->getRecordsByField($data, "recipient_email"); + $data = $this->renderDataForDataTable($data, $facilities_list); + + $parameters = array( + 'data' => $data, + 'title' => xlt(self::TITLE), + 'facilities_list' => $facilities_list, + 'recipient_mail' => $recipient_mail, + 'recipientType' => Array( + "Permanent" => xlt("Permanent"), + "Variable" => xlt("Variable"), + ), + );*/ + $parameters = []; + return $this->renderView($parameters, true); + } + + public function templatesManagementAjaxAction() + { + /*if (isset($_GET['action'])) { + $recipient_email = ($this->params()->fromQuery('recipient_email') !== null) ? $this->params()->fromQuery('recipient_email') : 'all'; + $recipient_type = ($this->params()->fromQuery('recipient_type') !== null) ? $this->params()->fromQuery('recipient_type') : 'all'; + $facility_id = ($this->params()->fromQuery('facility_id') !== null) ? $this->params()->fromQuery('facility_id') : 'all'; + + $data = $this->getVacListMailsTable()->getAddresses($recipient_email, $recipient_type, $facility_id ); + } else { + $data = $this->getVacListMailsTable()->fetchAll(); + } + + $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); + + $data = $this->renderDataForDataTable($data, $facilities_list);*/ + $parms = array('data' => $data); + return $this->responseWithNoLayout($parms, true); + } + + /** + * @return \Zend\Stdlib\ResponseInterface + */ + public function checkIfTempletesExistAction() + { + /*$row_id = intval($_POST['row_id']); + $recipient_email = $_POST['recipient_email']; + $recipient_type = $_POST['recipient_type']; + $facility_id = $_POST['facility_id']; + $isEdit = $_POST['is_edit']; + + if ($isEdit == "0") { + $rez = empty($this->getVacListMailsTable()->getAllActiveNames(array( + 'recipient_email' => $recipient_email, + ))); + $isExist = ($rez) ? 0 : 1; + $data = array( + 'is_exist' => $isExist + ); + $parms = array( + 'data' => $data + ); + } + else { + $isExist = 0; + $data = array( + 'is_exist' => $isExist + ); + $parms = array( + 'data' => $data + ); + }*/ + return $this->responseWithNoLayout($parms, true); + } + + /** + * @return \Zend\Stdlib\ResponseInterface + */ + public function saveAssignTempleteAction() + { + /* $row_id = intval($_POST['row_id']); + $recipient_email = $_POST['recipient_email']; + $recipient_type = $_POST['recipient_type']; + $facility_id = $_POST['facility_id']; + $isEdit = $_POST['is_edit']; + $updateDate = date("Y-m-d"); + $updateBy = $_SESSION['authUserID']; + + if ($isEdit == 1) { + $this->getVacListMailsTable()->updateRow($row_id, $recipient_email, $recipient_type, $facility_id, $updateDate, $updateBy); + } else { + $this->getVacListMailsTable()->insertRow($recipient_email, $recipient_type, $facility_id, $updateDate, $updateBy); + } + $data = ""; + $parameters = array( + 'data' => $data + );*/ + return $this->responseWithNoLayout($parameters, true); + } + + /** + * @return \Zend\View\Model\ViewModel + */ + public function addEditEmailsVaccinesManagementAction() + { + /* $id = $this->params()->fromQuery('row_id'); + $object = $this->getVacListMailsTable()->fetchRow($id); + $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); + $list = array( + "facilities_list" => $facilities_list, + ); + + if (!empty($id)) { + $is_edit = 1; + $row_id = $id; + $date = $object['updated_date']; + $userName = $this->getUserNameById($object['updated_by']); + $form = new EmailsVaccinesAddEditForm($list); + $form->setData($object); + } else { + $is_edit = 0; + $row_id = 0; + $date = ""; + $userName = ""; + $form = new EmailsVaccinesAddEditForm($list); + }*/ + + return $this->renderView(array( + 'title' => xlt(self::TITLE), + 'form' => $form, + 'userName' => $userName, + 'date' => $date, + 'is_edit' => $is_edit, + 'row_id' => $row_id, + )); + } + + /** + * @return \Zend\Stdlib\ResponseInterface + */ + public function deleteAssignTempleteAjaxAction() + { + $request = $this->getRequest(); + if ($request->isPost()) { + $id = $request->getPost()['id']; + $status = $this->getVacListMailsTable()->deleteRow($id); + return $this->ajaxOutPut( ($status ? 'success' : 'false') ); + } + } + + /** + * @param $dataArr + * @param $facilities_list + * @return array + */ + private function renderDataForDataTable($dataArr,$facilities_list) + { + $resultAll = array(); + + $counter = 0; + foreach ($dataArr as $index => $temp_record) { + $resultAll[$counter][] = xlt($temp_record['id']); + $resultAll[$counter][] = "" . attr($temp_record['recipient_email']) . " "; + $resultAll[$counter][] = xlt($temp_record['recipient_type']); + $resultAll[$counter][] = (array_key_exists($temp_record["facility_id"], $facilities_list) ? xlt($facilities_list[$temp_record['facility_id']]) : ""); + $counter++; + } + + return $resultAll; + } + + function getRecordsByField($data, $field_name) + { + $result = false; + if (is_array($data) && strlen($field_name) > 0) { + foreach ($data as $row) { + if (array_key_exists($field_name, $row) && strlen($row[$field_name]) > 0 ) { + $result[] = $row[$field_name]; + } + } + } + return (is_array($result) ? array_unique($result) : $result); + } +} diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php index 31fc3f4..298816d 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php @@ -46,7 +46,7 @@ public function getTemplatesForForm($form_id=null,$form_field=null,$service_type $select->where($where); $select->order(array('clinikal_templates_map.seq ASC')); - $debug = $select->getSqlString(); + //$debug = $select->getSqlString(); $rs = $this->tableGateway->selectWith($select); foreach ($rs as $r) { $rsArray[] = get_object_vars($r); From 78a55a394984de3580bc357d8e946ac144b08ea3 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Wed, 27 Jan 2021 11:51:33 +0200 Subject: [PATCH 13/37] assign teplete to all reason codes PC-1399 --- .../src/ClinikalAPI/Model/GetTemplatesServiceTable.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php index 31fc3f4..ea527a1 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php @@ -15,6 +15,7 @@ class GetTemplatesServiceTable { const LEFT_JOIN = "LEFT"; + const ALL_REASON_CODE = 'ALL'; protected $tableGateway; public function __construct(TableGateway $tableGateway) { @@ -39,14 +40,18 @@ public function getTemplatesForForm($form_id=null,$form_field=null,$service_type if(!is_null($service_type)){ $where->equalTo("service_type",$service_type)->AND-> - in("reason_code",explode(",",$reason_code))->AND-> + NEST-> + in("reason_code",explode(",",$reason_code))->OR-> + equalTo("reason_code",self::ALL_REASON_CODE)-> + UNNEST->AND-> equalTo("form_field",$form_field)->AND-> equalTo("form_id",$form_id); } $select->where($where); $select->order(array('clinikal_templates_map.seq ASC')); - $debug = $select->getSqlString(); + //$debug = $select->getSqlString(); + //echo $debug;die; $rs = $this->tableGateway->selectWith($select); foreach ($rs as $r) { $rsArray[] = get_object_vars($r); From 32b6b073e3649bdc2ddc4434042e00598900d1db Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Sun, 31 Jan 2021 17:19:42 +0200 Subject: [PATCH 14/37] list page - PC-1575 PC-1576 --- modules/ClinikalAPI/Module.php | 24 +- modules/ClinikalAPI/config/module.config.php | 21 + .../sql/1_0_0-to-2_0_0_upgrade.sql | 11 + modules/ClinikalAPI/sql/install.sql | 12 + .../FormTemplatesManagementController.php | 166 +++++--- .../Model/GetTemplatesServiceTable.php | 38 ++ .../assign-templete.phtml | 380 ++++++++++++++++++ .../templates-management-index.phtml | 251 ++++++++++++ modules/ClinikalAPI/view/layout/layout.phtml | 55 +++ .../datatable}/dataTablesExtend.css | 0 .../datatable}/jquery.dataTables.min.css | 0 .../datatable}/buttons.html5.min.js | 0 .../datatable}/buttons.print.min.js | 0 .../datatable}/dataTables.bootstrap.min.js | 0 .../datatable}/dataTables.buttons.min.js | 0 .../datatable}/dataTablesExtend.js | 0 .../generictools/datatable}/datatables.min.js | 0 .../generictools/datatable}/jquery.min.js | 0 .../sql/1_0_0-to-2_0_0_upgrade.sql | 22 + modules/GenericTools/sql/install.sql | 43 ++ .../DataTableExtended/DataTableExtended.php | 21 +- .../UiComponents/Header/ClinikalHeaders.php | 1 + .../ValidateJS/ValidateJsFunctions.php | 3 +- .../src/GenericTools/Model/RegistryTable.php | 15 + modules/ReportTool/sql/install.sql | 22 +- 25 files changed, 1004 insertions(+), 81 deletions(-) create mode 100644 modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml create mode 100644 modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml create mode 100644 modules/ClinikalAPI/view/layout/layout.phtml rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/css => css/generictools/datatable}/dataTablesExtend.css (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/css => css/generictools/datatable}/jquery.dataTables.min.css (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/buttons.html5.min.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/buttons.print.min.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/dataTables.bootstrap.min.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/dataTables.buttons.min.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/dataTablesExtend.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/datatables.min.js (100%) rename modules/GenericTools/{src/GenericTools/Library/UiComponents/DataTableExtended/src/js => js/generictools/datatable}/jquery.min.js (100%) diff --git a/modules/ClinikalAPI/Module.php b/modules/ClinikalAPI/Module.php index ca7239f..cc61337 100644 --- a/modules/ClinikalAPI/Module.php +++ b/modules/ClinikalAPI/Module.php @@ -157,6 +157,28 @@ public function initApi($m) } - + /** + * load global variables foe every controllers + * @param ModuleManager $manager + */ + public function init(ModuleManager $manager) + { + $events = $manager->getEventManager(); + $sharedEvents = $events->getSharedManager(); + + $sharedEvents->attach(__NAMESPACE__, 'dispatch', function ($e) { + $controller = $e->getTarget(); + //$controller->layout()->setVariable('status', null); + $controller->layout('clinikalApi/layout/layout'); + + //global variable of language direction + $controller->layout()->setVariable('language_direction', $_SESSION['language_direction']); + + // autoloader for ui-components from clinikal folder. + /*spl_autoload_register(function ($class) { + require_once $GLOBALS['fileroot'].'/clinikal/ui-components/' . str_replace("\\", '/', $class) . '.php'; + });*/ + }, 100); + } } diff --git a/modules/ClinikalAPI/config/module.config.php b/modules/ClinikalAPI/config/module.config.php index e10050f..e3b7861 100644 --- a/modules/ClinikalAPI/config/module.config.php +++ b/modules/ClinikalAPI/config/module.config.php @@ -18,6 +18,7 @@ */ use ClinikalAPI\Controller\ManagerApi; +use ClinikalAPI\Controller\FormTemplatesManagementController; use Interop\Container\ContainerInterface; return array( @@ -29,6 +30,9 @@ ManagerApi::class => function (ContainerInterface $container) { return new ManagerApi($container); }, + FormTemplatesManagementController::class => function (ContainerInterface $container) { + return new FormTemplatesManagementController($container); + }, ], ), @@ -53,6 +57,19 @@ ), ), ), + 'templetes_management' => array( + 'type' => 'segment', + 'options' => array( + 'route' => '/templates-management[/:action]', + 'constraints' => array( + 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', + ), + 'defaults' => array( + 'controller' => FormTemplatesManagementController::class, + 'action' => 'templatesManagementIndex', + ), + ), + ), ), ), @@ -61,5 +78,9 @@ 'template_path_stack' => array( 'ClinikalAPI' => __DIR__ . '/../view', ), + 'template_map' => array( + 'clinikalApi/layout/layout' => __DIR__ . '/../view/layout/layout.phtml', + ) ), + ); diff --git a/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql b/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql index 8a631ba..d1f2120 100644 --- a/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql +++ b/modules/ClinikalAPI/sql/1_0_0-to-2_0_0_upgrade.sql @@ -90,3 +90,14 @@ -- arguments: constant_name english hebrew -- behavior: can take a long time. +#IfMissingColumn clinikal_templates_map active +ALTER TABLE `clinikal_templates_map` ADD `active` tinyint(1) NOT NULL DEFAULT 1; +#EndIf + +#IfMissingColumn clinikal_templates_map update_by +ALTER TABLE `clinikal_templates_map` ADD `update_by` int(11) NOT NULL; +#EndIf + +#IfMissingColumn clinikal_templates_map update_date +ALTER TABLE `clinikal_templates_map` ADD `update_date` datetime NOT NULL DEFAULT current_timestamp; +#EndIf diff --git a/modules/ClinikalAPI/sql/install.sql b/modules/ClinikalAPI/sql/install.sql index 09d04c1..f2a664f 100644 --- a/modules/ClinikalAPI/sql/install.sql +++ b/modules/ClinikalAPI/sql/install.sql @@ -49,6 +49,12 @@ CREATE TABLE `clinikal_templates_map` ( ALTER TABLE `clinikal_templates_map` ADD PRIMARY KEY (`form_id`,`form_field`,`service_type`,`reason_code`,`message_id`); +ALTER TABLE `clinikal_templates_map` ADD `active` tinyint(1) NOT NULL DEFAULT 1; +ALTER TABLE `clinikal_templates_map` ADD `update_by` int(11) NOT NULL; +ALTER TABLE `clinikal_templates_map` ADD `update_date` datetime NOT NULL DEFAULT current_timestamp; + + + CREATE TABLE `form_context_map` ( `form_id` INT NOT NULL, @@ -150,3 +156,9 @@ CREATE TABLE manage_templates_letters( `letter_post_json` mediumtext DEFAULT NULL, PRIMARY KEY (`id`) ); + + + +INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`, `subtype`, `edit_options`) VALUES +('lists', 'clinikal_form_fields_templates', 'Form fields that use templates', 0, 0, 0, '', '', '', 0, 0, 1, '', 1); + diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php index d66c731..cae8266 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php @@ -8,13 +8,22 @@ namespace ClinikalApi\Controller; +use GenericTools\Controller\BaseController; +use GenericTools\Model\LangLanguagesTable; +use GenericTools\Model\ListsTable; use Interop\Container\ContainerInterface; +use ClinikalAPI\Model\GetTemplatesServiceTable; +use GenericTools\Model\RegistryTable; class FormTemplatesManagementController extends BaseController { - const TITLE = "Managment of email address for serious side-effects"; - const MAILS_LIST = "moh_vac_list_mails"; + const TITLE = "templates Managment"; + private $forms; + private $fileds; + private $serviceTypes; + private $reasonCodes; + private $templates; public function __construct(ContainerInterface $container) { @@ -22,54 +31,134 @@ public function __construct(ContainerInterface $container) $this->container = $container; } - public function TempleteManagementIndexAction() + public function templatesManagementIndexAction() { + // if (!acl_check('modules', 'warnings_and_contraindications_management', '', 'write')) { // $this->redirect()->toRoute('errors', array('action' => 'access-denied')); // } + $this->loadClientSideForms(); + $this->loadServiceTypes(); + $this->loadtemplates(); - /*$data = $this->getVacListMailsTable()->fetchAll(); - $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); - $recipient_mail = $this->getRecordsByField($data, "recipient_email"); - $data = $this->renderDataForDataTable($data, $facilities_list); + $langCode = ($this->container->get(LangLanguagesTable::class)->getLangCode($_SESSION['language_choice'] ? $_SESSION['language_choice'] : $this->container->get(LangLanguagesTable::class)->getLangIdByGlobals())); + $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetch($langCode, ['active' => 1])); + //$this->die_r($data); $parameters = array( - 'data' => $data, - 'title' => xlt(self::TITLE), - 'facilities_list' => $facilities_list, - 'recipient_mail' => $recipient_mail, - 'recipientType' => Array( - "Permanent" => xlt("Permanent"), - "Variable" => xlt("Variable"), - ), - );*/ - $parameters = []; - return $this->renderView($parameters, true); + 'title' => xlt(self::TITLE), + 'data' => $data, + 'forms' => $this->forms, + 'serviceTypes' => $this->serviceTypes, + 'templates' => $this->templates + ); + $this->layout('clinikalApi/layout/layout'); + return $parameters; } - public function templatesManagementAjaxAction() + private function loadClientSideForms() { - /*if (isset($_GET['action'])) { - $recipient_email = ($this->params()->fromQuery('recipient_email') !== null) ? $this->params()->fromQuery('recipient_email') : 'all'; - $recipient_type = ($this->params()->fromQuery('recipient_type') !== null) ? $this->params()->fromQuery('recipient_type') : 'all'; - $facility_id = ($this->params()->fromQuery('facility_id') !== null) ? $this->params()->fromQuery('facility_id') : 'all'; + $this->forms = $this->container->get(RegistryTable::class)->getFormsKeyDirectoryValueName(['category' => 'React form']); + } - $data = $this->getVacListMailsTable()->getAddresses($recipient_email, $recipient_type, $facility_id ); - } else { - $data = $this->getVacListMailsTable()->fetchAll(); + private function loadFormFileds($formId = null) + { + $this->fileds = is_null($formId) + ? + $this->container->get(ListsTable::class)->getListForViewForm('clinikal_form_fields_templates', true) + : + $this->container->get(ListsTable::class)->getListForViewForm('clinikal_form_fields_templates', true, ['notes' => $formId]); + } + + private function loadServiceTypes() + { + $this->serviceTypes = $this->container->get(ListsTable::class)->getListForViewForm('clinikal_service_types', true); + } + + private function loadReasonCodes($serviceType = null) + { + $this->reasonCodes = is_null($serviceType) + ? + $this->container->get(ListsTable::class)->getListForViewForm('clinikal_reason_codes', true) + : + $this->container->get(ListsTable::class)->getListForViewForm('clinikal_reason_codes', true, ['notes' => $serviceType]); + } + + private function loadtemplates() + { + $this->templates = $this->container->get(ListsTable::class)->getListForViewForm('clinikal_templates', true); + } + + private function normalizeDataForTable($dbMapping) + { + $results = []; + foreach ($dbMapping as $item) { + $results[] = [ + $item['form'], + $item['field'], + $item['service_type'], + $item['reason_code'], + $item['template'], + (intval($item['active']) === 1) ? "" : "", + '' + ]; } + return $results; + } - $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); - $data = $this->renderDataForDataTable($data, $facilities_list);*/ + public function templatesManagementAjaxAction() + { + $queryFilters = []; + if ($this->params()->fromQuery('form_name') && $this->params()->fromQuery('form_name') !== 'all') { + $queryFilters['form_id'] = $this->params()->fromQuery('form_name'); + } + if ($this->params()->fromQuery('field_name') && $this->params()->fromQuery('field_name') !== 'all') { + $queryFilters['form_field'] = $this->params()->fromQuery('field_name'); + } + if ($this->params()->fromQuery('service_type') && $this->params()->fromQuery('service_type') !== 'all') { + $queryFilters['service_type'] = $this->params()->fromQuery('service_type'); + } + if ($this->params()->fromQuery('reason_code') && $this->params()->fromQuery('reason_code') !== 'all') { + $queryFilters['reason_code'] = $this->params()->fromQuery('reason_code'); + } + if ($this->params()->fromQuery('template') && $this->params()->fromQuery('template') !== 'all') { + $queryFilters['message_id'] = $this->params()->fromQuery('template'); + } + if (!is_null($this->params()->fromQuery('active')) && $this->params()->fromQuery('active') !== 'all' && $this->params()->fromQuery('active') !== '') { + $queryFilters['active'] = $this->params()->fromQuery('active'); + } + + $langCode = ($this->container->get(LangLanguagesTable::class)->getLangCode($_SESSION['language_choice'] ? $_SESSION['language_choice'] : $this->container->get(LangLanguagesTable::class)->getLangIdByGlobals())); + $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetch($langCode, $queryFilters)); $parms = array('data' => $data); return $this->responseWithNoLayout($parms, true); } + public function loadFiledsAction() + { + $form = $this->params()->fromQuery('filter'); + if (empty($form)) { + throw new \Exception('Missing filter parameter'); + } + $this->loadFormFileds($form); + return $this->responseWithNoLayout($this->fileds ? $this->fileds : []); + } + + public function loadReasonCodesAction() + { + $serviceType = $this->params()->fromQuery('filter'); + if (empty($serviceType)) { + throw new \Exception('Missing filter parameter'); + } + $this->loadReasonCodes($serviceType); + return $this->responseWithNoLayout($this->reasonCodes ? $this->reasonCodes : []); + } + /** * @return \Zend\Stdlib\ResponseInterface */ - public function checkIfTempletesExistAction() + public function checkIftemplatesExistAction() { /*$row_id = intval($_POST['row_id']); $recipient_email = $_POST['recipient_email']; @@ -176,26 +265,7 @@ public function deleteAssignTempleteAjaxAction() } } - /** - * @param $dataArr - * @param $facilities_list - * @return array - */ - private function renderDataForDataTable($dataArr,$facilities_list) - { - $resultAll = array(); - $counter = 0; - foreach ($dataArr as $index => $temp_record) { - $resultAll[$counter][] = xlt($temp_record['id']); - $resultAll[$counter][] = "" . attr($temp_record['recipient_email']) . " "; - $resultAll[$counter][] = xlt($temp_record['recipient_type']); - $resultAll[$counter][] = (array_key_exists($temp_record["facility_id"], $facilities_list) ? xlt($facilities_list[$temp_record['facility_id']]) : ""); - $counter++; - } - - return $resultAll; - } function getRecordsByField($data, $field_name) { diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php index ea527a1..00f4277 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php @@ -59,4 +59,42 @@ public function getTemplatesForForm($form_id=null,$form_field=null,$service_type return $rsArray; } + + /** + * @return array - all of the facilities from facility table + */ + public function fetch($langCode, $equalFilters = null) + { + $sql = " + SELECT + translateString(r.name, ?) as form, + translateString(GetOptionTitle('clinikal_form_fields_templates', ctm.form_field),?) as field, + translateString(GetOptionTitle('clinikal_service_types', ctm.service_type),?) as service_type, + translateString(GetOptionTitle('clinikal_reason_codes', ctm.reason_code),?) as reason_code, + translateString(GetOptionTitle('clinikal_templates', ctm.message_id),?) as template, + ctm.active as active + FROM clinikal_templates_map AS ctm + JOIN registry AS r ON ctm.form_id = r.directory + "; + $bindParams = [$langCode, $langCode, $langCode, $langCode, $langCode]; + + $where = []; + foreach ($equalFilters as $column => $value) { + $where[] = " ctm.$column = ? "; + $bindParams[] = $value; + } + if (!empty($equalFilters)) { + $sql .= " WHERE " . implode('AND', $where); + } + + $sql .= " ORDER BY form, field, service_type, reason_code, seq"; + + $statement = $this->tableGateway->adapter->createStatement($sql, $bindParams); + $return = $statement->execute(); + $results = array(); + foreach ($return as $row) { + $results[] = $row; + } + return $results; + } } diff --git a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml new file mode 100644 index 0000000..277bd62 --- /dev/null +++ b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml @@ -0,0 +1,380 @@ + + +
+ + titleWithButtons($is_edit? "Update manufacturer name" : "Add manufacturer name" , array(array('id' => 'save', 'title' => 'Save'), array('id' => 'go_back', 'title' => 'cancel'))); ?> + +
+
+ +
+ +
+
+ +
+
+ ' > + + + +
+ +
+ +
+
+ +
+
+ + + "> . +
+
+ + +
+
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+ ' maxlength="20"> +
+ +
+ +
+
+ +
+
+ + +
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + + + diff --git a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml new file mode 100644 index 0000000..c5037d1 --- /dev/null +++ b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml @@ -0,0 +1,251 @@ +Xl('Form'), + '1'=>Xl('field'), + '2'=>Xl('Service type'), + '3'=>Xl('Reason code'), + '4'=>Xl('Template'), + '5'=>Xl('Active'), + '6' => '' +); +$table_handler= new DataTableExtended($table_id,$table_col_names); +$headers = new ClinikalHeaders(); + +?> + + +LoadEssentialCssJs(); ?> +
+ + titleWithButtons('Templates management', array( + array('id' => 'assign_template', 'title' => 'Assign template' ), + array('id' => 'add_template', 'title' => 'add/edit template' ), + )); ?> + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+
+ + +
+ + +
+ +
+ +
+ +
+
+
+
+ echoBaseHTML(); ?> +
+
+
+
+
+ + + + diff --git a/modules/ClinikalAPI/view/layout/layout.phtml b/modules/ClinikalAPI/view/layout/layout.phtml new file mode 100644 index 0000000..7975765 --- /dev/null +++ b/modules/ClinikalAPI/view/layout/layout.phtml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + +
+
+
+ content; ?> +
+
+
+ + + diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/css/dataTablesExtend.css b/modules/GenericTools/css/generictools/datatable/dataTablesExtend.css similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/css/dataTablesExtend.css rename to modules/GenericTools/css/generictools/datatable/dataTablesExtend.css diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/css/jquery.dataTables.min.css b/modules/GenericTools/css/generictools/datatable/jquery.dataTables.min.css similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/css/jquery.dataTables.min.css rename to modules/GenericTools/css/generictools/datatable/jquery.dataTables.min.css diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/buttons.html5.min.js b/modules/GenericTools/js/generictools/datatable/buttons.html5.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/buttons.html5.min.js rename to modules/GenericTools/js/generictools/datatable/buttons.html5.min.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/buttons.print.min.js b/modules/GenericTools/js/generictools/datatable/buttons.print.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/buttons.print.min.js rename to modules/GenericTools/js/generictools/datatable/buttons.print.min.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTables.bootstrap.min.js b/modules/GenericTools/js/generictools/datatable/dataTables.bootstrap.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTables.bootstrap.min.js rename to modules/GenericTools/js/generictools/datatable/dataTables.bootstrap.min.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTables.buttons.min.js b/modules/GenericTools/js/generictools/datatable/dataTables.buttons.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTables.buttons.min.js rename to modules/GenericTools/js/generictools/datatable/dataTables.buttons.min.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTablesExtend.js b/modules/GenericTools/js/generictools/datatable/dataTablesExtend.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/dataTablesExtend.js rename to modules/GenericTools/js/generictools/datatable/dataTablesExtend.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/datatables.min.js b/modules/GenericTools/js/generictools/datatable/datatables.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/datatables.min.js rename to modules/GenericTools/js/generictools/datatable/datatables.min.js diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/jquery.min.js b/modules/GenericTools/js/generictools/datatable/jquery.min.js similarity index 100% rename from modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/src/js/jquery.min.js rename to modules/GenericTools/js/generictools/datatable/jquery.min.js diff --git a/modules/GenericTools/sql/1_0_0-to-2_0_0_upgrade.sql b/modules/GenericTools/sql/1_0_0-to-2_0_0_upgrade.sql index 8a631ba..be3226d 100644 --- a/modules/GenericTools/sql/1_0_0-to-2_0_0_upgrade.sql +++ b/modules/GenericTools/sql/1_0_0-to-2_0_0_upgrade.sql @@ -90,3 +90,25 @@ -- arguments: constant_name english hebrew -- behavior: can take a long time. + + +DROP FUNCTION IF EXISTS `translateString`; +#SpecialSql + +CREATE FUNCTION translateString(p_title varchar(255), p_lang varchar(5)) RETURNS varchar(255) READS SQL DATA +BEGIN + + DECLARE v_title varchar(255); + +select d.definition +INTO v_title +from lang_constants c + join lang_definitions d on d.cons_id = c.cons_id and lang_id= (select lang_id from lang_languages where lang_code = p_lang) +where c.constant_name = p_title; + +RETURN ifnull(v_title, p_title); + +END; +#EndSpecialSql + + diff --git a/modules/GenericTools/sql/install.sql b/modules/GenericTools/sql/install.sql index 605951e..3ec7d98 100644 --- a/modules/GenericTools/sql/install.sql +++ b/modules/GenericTools/sql/install.sql @@ -1 +1,44 @@ INSERT INTO `globals` (`gl_name`, `gl_value`) VALUES ('s3_version', '2006-03-01'); + + +DROP FUNCTION IF EXISTS `GetOptionTitle`; +#SpecialSql + +CREATE FUNCTION GetOptionTitle(p_list_id varchar(255), p_option_id varchar(100)) RETURNS varchar(255) READS SQL DATA +BEGIN + + DECLARE v_title varchar(255); + +select lo.title +INTO v_title +from `list_options` lo +where lo.list_id = p_list_id and + lo.option_id = p_option_id; + +RETURN v_title; + +END; +#EndSpecialSql + + + +DROP FUNCTION IF EXISTS `translateString`; +#SpecialSql + +CREATE FUNCTION translateString(p_title varchar(255), p_lang varchar(5)) RETURNS varchar(255) READS SQL DATA +BEGIN + + DECLARE v_title varchar(255); + +select d.definition +INTO v_title +from lang_constants c + join lang_definitions d on d.cons_id = c.cons_id and lang_id= (select lang_id from lang_languages where lang_code = p_lang) +where c.constant_name = p_title; + +RETURN ifnull(v_title, p_title); + +END; +#EndSpecialSql + + diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/DataTableExtended.php b/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/DataTableExtended.php index 89618c8..14ef09d 100644 --- a/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/DataTableExtended.php +++ b/modules/GenericTools/src/GenericTools/Library/UiComponents/DataTableExtended/DataTableExtended.php @@ -1,6 +1,6 @@ '; - $header_html.=''; + $header_html.=''; + $header_html.=''; - $header_html.=''; + $header_html.=''; - $header_html.=''; - $header_html.=''; - $header_html.=''; - $header_html.=''; + $header_html.=''; + $header_html.=''; + $header_html.=''; + $header_html.=''; - $header_html.=''; + $header_html.=''; //$header_html.=''; echo $header_html; diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php b/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php index 1bd8508..e6fbed4 100644 --- a/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php +++ b/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php @@ -5,6 +5,7 @@ * Date: 04/09/18 * Time: 08:53 */ +namespace GenericTools\Library\UiComponents\Header; class ClinikalHeaders { diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/ValidateJS/ValidateJsFunctions.php b/modules/GenericTools/src/GenericTools/Library/UiComponents/ValidateJS/ValidateJsFunctions.php index 21298b3..7f6aa79 100644 --- a/modules/GenericTools/src/GenericTools/Library/UiComponents/ValidateJS/ValidateJsFunctions.php +++ b/modules/GenericTools/src/GenericTools/Library/UiComponents/ValidateJS/ValidateJsFunctions.php @@ -5,6 +5,7 @@ * Date: 13/05/18 * Time: 12:24 */ +namespace GenericTools\Library\UiComponents\ValidateJS; class ValidateJsFunctions { @@ -54,4 +55,4 @@ static function append(){ echo $output; } -} \ No newline at end of file +} diff --git a/modules/GenericTools/src/GenericTools/Model/RegistryTable.php b/modules/GenericTools/src/GenericTools/Model/RegistryTable.php index b7c82ff..2c445d8 100644 --- a/modules/GenericTools/src/GenericTools/Model/RegistryTable.php +++ b/modules/GenericTools/src/GenericTools/Model/RegistryTable.php @@ -3,6 +3,7 @@ namespace GenericTools\Model; +use Laminas\Db\Sql\Where; use Laminas\Db\TableGateway\TableGateway; use GenericTools\Model\UtilsTraits\JoinBuilder; use Laminas\Db\Sql\Expression; @@ -44,4 +45,18 @@ private function joinTables() return $this->getJoins(); } + public function getFormsKeyDirectoryValueName($equalConditions) + { + $where = new Where(); + foreach ($equalConditions as $column => $value) { + $where->equalTo($column, $value); + } + $rs= $this->tableGateway->select($where); + $rsArray=array(); + foreach($rs as $r) { + $rsArray[$r->directory]=$r->name; + } + return $rsArray; + } + } diff --git a/modules/ReportTool/sql/install.sql b/modules/ReportTool/sql/install.sql index 0cf6930..aeca588 100644 --- a/modules/ReportTool/sql/install.sql +++ b/modules/ReportTool/sql/install.sql @@ -34,7 +34,7 @@ BEGIN DECLARE v_title varchar(255); - select d.definition + select ifnull(d.definition,v_title) INTO v_title from lang_constants c join lang_definitions d on d.cons_id = c.cons_id and lang_id= (select lang_id from lang_languages where lang_code = 'he') @@ -45,23 +45,3 @@ BEGIN END; #EndSpecialSql - -DROP FUNCTION IF EXISTS `GetOptionTitle`; -#SpecialSql - -CREATE FUNCTION GetOptionTitle(p_list_id varchar(255), p_option_id varchar(100)) RETURNS varchar(255) READS SQL DATA -BEGIN - - DECLARE v_title varchar(255); - - select lo.title - INTO v_title - from `list_options` lo - where lo.list_id = p_list_id and - lo.option_id = p_option_id; - - RETURN v_title; - -END; -#EndSpecialSql - From 7648e8d5fbc3fbe0b42363ea954ee1051c13bef8 Mon Sep 17 00:00:00 2001 From: Amiel Elboim Date: Thu, 4 Feb 2021 13:33:25 +0200 Subject: [PATCH 15/37] assign template screen --- .../FormTemplatesManagementController.php | 175 ++++--- .../ClinikalAPI/Model/GetTemplatesService.php | 2 + .../Model/GetTemplatesServiceTable.php | 38 +- .../assign-template.phtml | 485 ++++++++++++++++++ .../assign-templete.phtml | 380 -------------- .../templates-management-index.phtml | 30 +- modules/ClinikalAPI/view/layout/layout.phtml | 5 + .../Controller/BaseController.php | 7 + .../UiComponents/Header/ClinikalHeaders.php | 10 +- 9 files changed, 653 insertions(+), 479 deletions(-) create mode 100644 modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-template.phtml delete mode 100644 modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php index cae8266..d3abdf9 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Controller/FormTemplatesManagementController.php @@ -42,7 +42,7 @@ public function templatesManagementIndexAction() $this->loadtemplates(); $langCode = ($this->container->get(LangLanguagesTable::class)->getLangCode($_SESSION['language_choice'] ? $_SESSION['language_choice'] : $this->container->get(LangLanguagesTable::class)->getLangIdByGlobals())); - $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetch($langCode, ['active' => 1])); + $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetchNormalizedData($langCode, ['active' => 1])); //$this->die_r($data); $parameters = array( @@ -100,7 +100,7 @@ private function normalizeDataForTable($dbMapping) $item['reason_code'], $item['template'], (intval($item['active']) === 1) ? "" : "", - '' + '' ]; } return $results; @@ -130,14 +130,50 @@ public function templatesManagementAjaxAction() } $langCode = ($this->container->get(LangLanguagesTable::class)->getLangCode($_SESSION['language_choice'] ? $_SESSION['language_choice'] : $this->container->get(LangLanguagesTable::class)->getLangIdByGlobals())); - $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetch($langCode, $queryFilters)); + $data = $this->normalizeDataForTable($this->container->get(GetTemplatesServiceTable::class)->fetchNormalizedData($langCode, $queryFilters)); $parms = array('data' => $data); return $this->responseWithNoLayout($parms, true); } + public function assignTemplateAction() + { + $this->loadClientSideForms(); + $this->loadServiceTypes(); + $this->loadtemplates(); + + $parameters = array( + 'title' => xlt(self::TITLE), + 'forms' => $this->forms, + 'serviceTypes' => $this->serviceTypes, + 'templates' => $this->templates, + 'user' => $this->getUserNameById($this->getConnectedUserId()) + ); + + if ($this->params()->fromQuery('edit')) { + $queryFilters = []; + $queryFilters['form_id'] = $this->params()->fromQuery('form_id'); + $queryFilters['form_field'] = $this->params()->fromQuery('field_id'); + $queryFilters['service_type'] = $this->params()->fromQuery('service_type'); + $queryFilters['reason_code'] = $this->params()->fromQuery('reason_code'); + $queryFilters['message_id'] = $this->params()->fromQuery('template'); + + $result = $this->container->get(GetTemplatesServiceTable::class)->get($queryFilters)[0]; + $parameters['record'] = $result; + $this->loadFormFileds($result['form_id']); + $this->loadReasonCodes($result['service_type']); + $parameters['formFiles'] = $this->fileds; + $parameters['reasonCode'] = $this->reasonCodes; + $parameters['is_edit'] = true; + } + + $this->layout('clinikalApi/layout/layout'); + return $parameters; + + } + public function loadFiledsAction() { - $form = $this->params()->fromQuery('filter'); + $form = $this->params()->fromQuery('filter'); if (empty($form)) { throw new \Exception('Missing filter parameter'); } @@ -152,106 +188,69 @@ public function loadReasonCodesAction() throw new \Exception('Missing filter parameter'); } $this->loadReasonCodes($serviceType); - return $this->responseWithNoLayout($this->reasonCodes ? $this->reasonCodes : []); + $reasonCodes = $this->reasonCodes ? $this->reasonCodes : []; + $allReasonsOptions = [GetTemplatesServiceTable::ALL_REASON_CODE => xlt(GetTemplatesServiceTable::ALL_REASON_CODE_STRING)]; + + return $this->responseWithNoLayout(array_merge( $reasonCodes, $allReasonsOptions)); } /** * @return \Zend\Stdlib\ResponseInterface */ - public function checkIftemplatesExistAction() + public function saveAssignTemplateAction() { - /*$row_id = intval($_POST['row_id']); - $recipient_email = $_POST['recipient_email']; - $recipient_type = $_POST['recipient_type']; - $facility_id = $_POST['facility_id']; - $isEdit = $_POST['is_edit']; - - if ($isEdit == "0") { - $rez = empty($this->getVacListMailsTable()->getAllActiveNames(array( - 'recipient_email' => $recipient_email, - ))); - $isExist = ($rez) ? 0 : 1; - $data = array( - 'is_exist' => $isExist - ); - $parms = array( - 'data' => $data - ); + $data = $this->params()->fromPost('data'); + $isEdit = $this->params()->fromPost('is_edit'); + $oldData = $isEdit ? $this->params()->fromPost('old_data') : null; + + if ($this->validateData($data)) { + $isExistData = $data; + unset($isExistData['seq'], $isExistData['active']); + $isExist = !empty($this->container->get(GetTemplatesServiceTable::class)->get($isExistData)) ? true : false; + if(!$isExist && $isEdit) { + //delete old record + $this->container->get(GetTemplatesServiceTable::class)->delete($oldData); + } + if($isExist && $isEdit) { + if($this->primaryKeysNotChanged($data, $oldData)) { + $this->container->get(GetTemplatesServiceTable::class)->delete($oldData); + } else { + return $this->responseWithNoLayout('data_conflict', true, 409); + } + } + if ($isExist && !$isEdit) { + return $this->responseWithNoLayout('data_conflict', true, 409); + } + + $data['update_by'] = $this->getConnectedUserId(); + $result = $this->container->get(GetTemplatesServiceTable::class)->insert($data); + return $this->responseWithNoLayout(true, true); + } - else { - $isExist = 0; - $data = array( - 'is_exist' => $isExist - ); - $parms = array( - 'data' => $data - ); - }*/ - return $this->responseWithNoLayout($parms, true); + return $this->responseWithNoLayout(false, 500); } - /** - * @return \Zend\Stdlib\ResponseInterface - */ - public function saveAssignTempleteAction() + private function validateData($data) { - /* $row_id = intval($_POST['row_id']); - $recipient_email = $_POST['recipient_email']; - $recipient_type = $_POST['recipient_type']; - $facility_id = $_POST['facility_id']; - $isEdit = $_POST['is_edit']; - $updateDate = date("Y-m-d"); - $updateBy = $_SESSION['authUserID']; - - if ($isEdit == 1) { - $this->getVacListMailsTable()->updateRow($row_id, $recipient_email, $recipient_type, $facility_id, $updateDate, $updateBy); - } else { - $this->getVacListMailsTable()->insertRow($recipient_email, $recipient_type, $facility_id, $updateDate, $updateBy); + $requiredFileds = ['form_id','form_field','service_type','reason_code','message_id','seq','active']; + foreach ($requiredFileds as $name) { + if(!isset($data[$name]) || is_null($data[$name]) || $data[$name] == '') { + return false; + } } - $data = ""; - $parameters = array( - 'data' => $data - );*/ - return $this->responseWithNoLayout($parameters, true); + return true; } - /** - * @return \Zend\View\Model\ViewModel - */ - public function addEditEmailsVaccinesManagementAction() + private function primaryKeysNotChanged($data, $oldData) { - /* $id = $this->params()->fromQuery('row_id'); - $object = $this->getVacListMailsTable()->fetchRow($id); - $facilities_list = $this->getFacilityTable()->getListWithSomeKeyValue("facility_code", "name"); - $list = array( - "facilities_list" => $facilities_list, - ); - - if (!empty($id)) { - $is_edit = 1; - $row_id = $id; - $date = $object['updated_date']; - $userName = $this->getUserNameById($object['updated_by']); - $form = new EmailsVaccinesAddEditForm($list); - $form->setData($object); - } else { - $is_edit = 0; - $row_id = 0; - $date = ""; - $userName = ""; - $form = new EmailsVaccinesAddEditForm($list); - }*/ - - return $this->renderView(array( - 'title' => xlt(self::TITLE), - 'form' => $form, - 'userName' => $userName, - 'date' => $date, - 'is_edit' => $is_edit, - 'row_id' => $row_id, - )); + $requiredFileds = ['form_id','form_field','service_type','reason_code','message_id']; + foreach ($requiredFileds as $name) { + if($data[$name] !== $oldData[$name]) return false; + } + return true; } + /** * @return \Zend\Stdlib\ResponseInterface */ diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesService.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesService.php index 8ce41f0..2ce3d33 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesService.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesService.php @@ -18,6 +18,7 @@ class GetTemplatesService public $reason_code; public $message_id; public $order; + public $active; //lists fields for join public $option_id; @@ -37,6 +38,7 @@ public function exchangeArray($data) $this->option_id = (!empty($data['option_id'])) ? $data['option_id'] : null; $this->title = (!empty($data['title'])) ? $data['title'] : null; $this->seq = (!empty($data['seq'])) ? $data['seq'] : null; + $this->active = (!empty($data['active'])) ? $data['active'] : null; } } diff --git a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php index 00f4277..da40a5d 100644 --- a/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php +++ b/modules/ClinikalAPI/src/ClinikalAPI/Model/GetTemplatesServiceTable.php @@ -15,7 +15,8 @@ class GetTemplatesServiceTable { const LEFT_JOIN = "LEFT"; - const ALL_REASON_CODE = 'ALL'; + const ALL_REASON_CODE = 'all_reasons'; + const ALL_REASON_CODE_STRING = 'All the reason codes'; protected $tableGateway; public function __construct(TableGateway $tableGateway) { @@ -63,14 +64,19 @@ public function getTemplatesForForm($form_id=null,$form_field=null,$service_type /** * @return array - all of the facilities from facility table */ - public function fetch($langCode, $equalFilters = null) + public function fetchNormalizedData($langCode, $equalFilters = null) { $sql = " SELECT + ctm.form_id as form_id, translateString(r.name, ?) as form, + ctm.form_field as field_id, translateString(GetOptionTitle('clinikal_form_fields_templates', ctm.form_field),?) as field, + ctm.service_type as service_type_id, translateString(GetOptionTitle('clinikal_service_types', ctm.service_type),?) as service_type, - translateString(GetOptionTitle('clinikal_reason_codes', ctm.reason_code),?) as reason_code, + ctm.reason_code as reason_code_id, + translateString(ifnull(GetOptionTitle('clinikal_reason_codes', ctm.reason_code),'" . self::ALL_REASON_CODE_STRING . "'),?) as reason_code, + ctm.message_id as template_id, translateString(GetOptionTitle('clinikal_templates', ctm.message_id),?) as template, ctm.active as active FROM clinikal_templates_map AS ctm @@ -97,4 +103,30 @@ public function fetch($langCode, $equalFilters = null) } return $results; } + + public function get($equalFilters) + { + $select = $this->tableGateway->getSql()->select(); + $where = new Where(); + foreach ($equalFilters as $column => $value) { + $where->equalTo($column, $value); + } + $select->where($where); + //$debug = $select->getSqlString(); + //echo $debug;die; + $rs = $this->tableGateway->selectWith($select); + $rsArray = []; + foreach ($rs as $r) { + $rsArray[] = get_object_vars($r); + } + return $rsArray; + } + + public function insert($data) { + return $this->tableGateway->insert($data) ? true : false; + } + + public function delete($data) { + return $this->tableGateway->delete($data) ? true : false; + } } diff --git a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-template.phtml b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-template.phtml new file mode 100644 index 0000000..28c9a24 --- /dev/null +++ b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-template.phtml @@ -0,0 +1,485 @@ + + +
+ + titleWithButtons($is_edit? "Update assignment" : "Assign template" , array(array('id' => 'save', 'title' => 'Save'), array('id' => 'go_back', 'title' => 'cancel'))); ?> + +
+
+
+ + +
+
+
+
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+
+
+
+ + + +
+ +
+ + + +
+ +
+
+ +
+
+ + +
+ +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ + + +
+ + + + + diff --git a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml deleted file mode 100644 index 277bd62..0000000 --- a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/assign-templete.phtml +++ /dev/null @@ -1,380 +0,0 @@ - - -
- - titleWithButtons($is_edit? "Update manufacturer name" : "Add manufacturer name" , array(array('id' => 'save', 'title' => 'Save'), array('id' => 'go_back', 'title' => 'cancel'))); ?> - -
-
- -
- -
-
- -
-
- ' > - - - -
- -
- -
-
- -
-
- - - "> . -
-
- - -
-
-
- -
-
- -
-
- - -
-
- -
-
- -
-
- ' maxlength="20"> -
- -
- -
-
- -
-
- - -
- -
-
-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
- -
- -
- -
-
- - - - diff --git a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml index c5037d1..2116072 100644 --- a/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml +++ b/modules/ClinikalAPI/view/clinikal-api/form-templates-management/templates-management-index.phtml @@ -183,14 +183,37 @@ $headers = new ClinikalHeaders(); return data; } - function goToAddNewBatch(e,row_id) { - e.preventDefault(); + function goToAssignTemplate(e, queryParametersObj) { //console.log(document.URL); - var url= "basePath() ?>"+"/commercial-names-management/add-edit-commercial?row_id="+row_id; + var url= "basePath() ?>"+"/templates-management/assign-template"; + if (typeof queryParametersObj !== 'undefined') { + url += '?edit=1&' + queryStringParameters(queryParametersObj) + } top.restoreSession(); window.location=url; } + function queryStringParameters(obj) { + var str = []; + for (var p in obj) + if (obj.hasOwnProperty(p)) { + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + } + return str.join("&"); + } + + function gotoEdit(form, field, serviceType, reasonCode, template) { + + var recordDtails = { + form_id: form, + field_id: field, + service_type:serviceType, + reason_code: reasonCode, + template: template + } + return goToAssignTemplate(null, recordDtails); + } + $( document ).ready(function() { $('#reason_codes, #templates').select2({ @@ -244,6 +267,7 @@ $headers = new ClinikalHeaders(); $("#filter").on( "click",filterData); $("#form_name").on( "change",loadFields); $("#service_type").on( "change",loadReasonCodes); + $("#assign_template").on( "click",goToAssignTemplate); }); diff --git a/modules/ClinikalAPI/view/layout/layout.phtml b/modules/ClinikalAPI/view/layout/layout.phtml index 7975765..5229c97 100644 --- a/modules/ClinikalAPI/view/layout/layout.phtml +++ b/modules/ClinikalAPI/view/layout/layout.phtml @@ -38,6 +38,11 @@ use OpenEMR\Core\Header; width: 130px !important; } + nav .center-buttons{ + padding: 10px; + margin-right: 5px; + } + diff --git a/modules/GenericTools/src/GenericTools/Controller/BaseController.php b/modules/GenericTools/src/GenericTools/Controller/BaseController.php index 3234d20..66425f0 100644 --- a/modules/GenericTools/src/GenericTools/Controller/BaseController.php +++ b/modules/GenericTools/src/GenericTools/Controller/BaseController.php @@ -1068,4 +1068,11 @@ public function getTitleOfValueSet($value,$valueSet){ $where=array ('filter' => array (0 => array ('value' => $value, 'operator' => '=',),),); return $valueSetsTable->getValueSetById($valueSet,$where); } + + protected function getConnectedUserId() + { + return $_SESSION['authUserID']; + } + + } diff --git a/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php b/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php index e6fbed4..c3b6471 100644 --- a/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php +++ b/modules/GenericTools/src/GenericTools/Library/UiComponents/Header/ClinikalHeaders.php @@ -17,18 +17,18 @@ public function singleTitle() public function titleWithButtons($title, array $buttons = array(),array $leftButtons = array()) { $html = $this->openTags(); - $html .= ''; + $html .= ''; if (!empty($buttons)) { $html .= '
  • '; foreach ($buttons as $button) { - $html .= ''; + $html .= ''; } $html .= '
  • '; } if (!empty($leftButtons)) { $html .= '
  • '; foreach ($leftButtons as $button) { - $html .= ''; + $html .= ''; } $html .= '
  • '; } @@ -43,8 +43,8 @@ public function tabsMenu() private function openTags() { - $html = '