Esempio n. 1
0
				saveCallback: function (_newEmail) {
					doLog && console.log(LOG_TAG, 'saveCallback - ' + _newEmail);

					if (typeof _newEmail == 'string') {
						args.patientData.email = _newEmail;
					}

					// doing omit on _patientData so that payload doesn't contain local objects
					var patientPayload = _.omit(args.patientData, 'enrollments');
					patientPayload = _.omit(patientPayload, 'conditions');

					DataManager.updatePatient(patientPayload, function (_response) {
						if (_response && _response.success) {
							doLog && console.log(LOG_TAG, 'updatePatientEmail callback success: ' + JSON.stringify(_response.data.email));
						} else {
							var dialog = alertDialogHelper.createAlertDialog({
								title: L('common_alert'),
								message: _response.error,
								buttonNames: [L('common_ok')]
							});

							dialog.show();
						}
					});

					$.answerView.removeAllChildren();
					$.footerView.removeAllChildren();

					//Ensure email address is appended to response value upon repaint
					questionData.responses[1].value = L('common_email_address') + ': ' + _newEmail;
					//Ensure email box is deselected upon repaint
					questionData.responses[1].isSelected = true;
					//Ensure address box is deselected upon repaint
					questionData.responses[0].isSelected = false;
					//Assign the next button to appropriate response
					questionData.next = questionData.responses[0].next;
					//Reloads the control with the email address
					init();
				}
Esempio n. 2
0
				saveCallback: function (_newAddress, _newSecondaryAddress) {
					doLog && console.log(LOG_TAG, 'saveCallback - Address' + JSON.stringify(_newAddress));
					doLog && console.log(LOG_TAG, 'saveCallback - Secondary Address' + JSON.stringify(_newSecondaryAddress));

					args.patientData.address = _newAddress;

					var updatePayload = {
						id: args.patientData.id,
						address: args.patientData.address
					};

					if (args.patientData.secondaryAddress && !_.isEmpty(args.patientData.secondaryAddress)) {
						//ensure the correct address is being updated
						_newSecondaryAddress.id = args.patientData.secondaryAddress.id;

						DataManager.updatePatientAddress(args.patientData.id, _newSecondaryAddress, function (_addressResponse) {
							if (_addressResponse && _addressResponse.success) {
								args.patientData.secondaryAddress = _addressResponse.data;
								doLog && console.log(LOG_TAG, 'updatePatientAddress callback success: ' + JSON.stringify(_addressResponse.data));
							} else {
								doLog && console.error(LOG_TAG, 'updatePatientAddress callback failure: ' + JSON.stringify(
									_addressResponse.error.message));
							}
						});

					} else {

						DataManager.createPatientAddress(args.patientData.id, _newSecondaryAddress, function (_addressResponse) {
							if (_addressResponse && _addressResponse.success) {
								args.patientData.secondaryAddress = _addressResponse.data;
								doLog && console.log(LOG_TAG, 'createPatientAddress callback success: ' + JSON.stringify(_addressResponse.data));
							} else {
								doLog && console.error(LOG_TAG, 'createPatientAddress callback failure: ' + JSON.stringify(
									_addressResponse.error.message));
							}
						});
					}

					// doing omit on _patientData so that payload doesn't contain local objects
					var patientPayload = _.omit(args.patientData, 'enrollments');
					patientPayload = _.omit(patientPayload, 'conditions');

					DataManager.updatePatient(_.omit(args.patientData, 'enrollments'), function (_response) {
						if (_response && _response.success) {
							doLog && console.log(LOG_TAG, 'updatePatientAddress callback success: ' + JSON.stringify(_response.data.address));
						} else {
							var dialog = alertDialogHelper.createAlertDialog({
								title: L('common_alert'),
								message: _response.error,
								buttonNames: [L('common_ok')]
							});

							dialog.show();
						}
					});

					$.answerView.removeAllChildren();
					$.footerView.removeAllChildren();

					//Ensure address is appended to response value upon repaint
					questionData.responses[0].value = L('common_mailing_address') + ': ' +
						appHelper.addressFormatter(_newAddress);
					//Ensure email box is deselected upon repaint
					questionData.responses[0].isSelected = true;
					//Ensure address box is selected upon repaint
					questionData.responses[1].isSelected = false;
					//Assign the next button to appropriate response
					questionData.next = questionData.responses[1].next;
					//Reloads the control with the address
					init();
				}