2 * ProductRegistrationService (JavaScript)
4 * LICENSE: This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @author Matthew Vita <matthewvita48@gmail.com>
17 * @link http://www.open-emr.org
21 function ProductRegistrationService() {
24 self.getProductStatus = function(callback) {
26 url: registrationConstants.webroot + '/interface/product_registration/product_registration_controller.php',
29 success: function(response) {
30 _genericAjaxSuccessHandler(response, callback);
32 error: function(jqXHR) {
33 _genericAjaxFailureHandler(jqXHR, callback);
38 self.submitRegistration = function(email, callback) {
40 url: registrationConstants.webroot + '/interface/product_registration/product_registration_controller.php',
46 success: function(response) {
47 _genericAjaxSuccessHandler(response, callback);
49 error: function(jqXHR) {
50 _genericAjaxFailureHandler(jqXHR, callback);
55 var _genericAjaxSuccessHandler = function(response, callback) {
57 return callback(null, response);
60 return callback(registrationTranslations.genericError, null);
63 var _genericAjaxFailureHandler = function(jqXHR, callback) {
64 if (jqXHR && jqXHR.hasOwnProperty('responseText')) {
66 var rawErrorObject = jqXHR.responseText;
67 var parsedErrorObject = JSON.parse(rawErrorObject);
69 if (parsedErrorObject && parsedErrorObject.hasOwnProperty('error')) {
70 callback(parsedErrorObject.error, null);
72 } catch (jsonParseException) {
73 callback(registrationTranslations.genericError, null);
76 callback(registrationTranslations.genericError, null);