6 * Top-level API and helper functions for the ESign module
8 * Copyright (C) 2013 OEMR 501c3 www.oemr.org
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
22 * @author Ken Chapple <ken@mi-squared.com>
23 * @author Medical Information Integration, LLC
24 * @link http://www.open-emr.org
27 require_once $GLOBALS['srcdir'].'/ESign/ESign.php';
28 require_once $GLOBALS['srcdir'].'/ESign/FactoryIF.php';
29 require_once $GLOBALS['srcdir'].'/ESign/ConfigurationIF.php';
30 require_once $GLOBALS['srcdir'].'/ESign/SignableIF.php';
31 require_once $GLOBALS['srcdir'].'/ESign/Form/Factory.php';
32 require_once $GLOBALS['srcdir'].'/ESign/Form/Configuration.php';
33 require_once $GLOBALS['srcdir'].'/ESign/Encounter/Factory.php';
34 require_once $GLOBALS['srcdir'].'/ESign/Encounter/Configuration.php';
38 public function lockEncounters()
40 return $GLOBALS['lock_esign_all'];
43 public function formConfigToJson()
45 $configuration = new Form_Configuration();
46 return $this->configToJson( $configuration );
49 public function createFormESign( $formId, $formDir, $encounterId )
51 $factory = new Form_Factory( $formId, $formDir, $encounterId );
52 $esign = $this->createESign( $factory );
56 public function encounterConfigToJson()
58 $configuration = new Encounter_Configuration();
59 return $this->configToJson( $configuration );
62 public function createEncounterESign( $encounterId )
64 $factory = new Encounter_Factory( $encounterId );
65 $esign = $this->createESign( $factory );
69 public function createEncounterSignable( $encounterId )
71 $signable = new Encounter_Signable( $encounterId );
75 public function createESign( FactoryIF
$factory )
77 $configuration = $factory->createConfiguration();
78 $signable = $factory->createSignable();
79 $button = $factory->createButton();
80 $log = $factory->createLog();
81 $esign = new ESign( $configuration, $signable, $button, $log );
86 * This contains the configuration for the esign javascript object
90 public function configToJson( ConfigurationIF
$configuration )
93 'baseUrl' => $configuration->getBaseUrl(),
94 'logViewAction' => $configuration->getLogViewAction(),
95 'formViewAction' => $configuration->getFormViewAction(),
96 'formSubmitAction' => $configuration->getFormSubmitAction(),
97 'module' => $configuration->getModule()
100 $json = json_encode( $params );
104 public function sign( SignableIF
$signable, $userId, $lock = false, $amendment = null )
107 $ret = $signable->sign( $userId, $lock, $amendment );
109 } catch ( \Exception
$e ) {
110 error_log( $e->getMessage() );
115 public function lock( SignableIF
$signable, $userId, $amendment = null )
117 return $this->sign( $signable, $userId, true, $amendment );