Skip to content

Commit

Permalink
progressing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapolas Kaselis committed Oct 24, 2017
1 parent 03d7d07 commit 31653fe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
9 changes: 0 additions & 9 deletions src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ function run(
}
}
});


var CONSENT_PATIENT_STATE = 'patient.consents';
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
if (!isPublicState(toState) && toState.name !== CONSENT_PATIENT_STATE && toState.name.indexOf('patient.') === 0) {
console.log('ok');
}
});

}

run.$inject = [
Expand Down
7 changes: 3 additions & 4 deletions src/app/patients/consents/consent-model.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
function patientConsentModelFactory(Model, store) {
function patientConsentModelFactory(Model) {
function PatientConsentModel(modelName, data) {
Model.call(this, modelName, data);

}

PatientConsentModel.prototype = Object.create(Model.prototype);
Expand All @@ -10,11 +9,11 @@ function patientConsentModelFactory(Model, store) {
var myDate = new Date(patient.dateOfBirth);
myDate.setFullYear(myDate.getFullYear() + 16);
return myDate.toISOString();
}
};

return PatientConsentModel;
}

patientConsentModelFactory.$inject = ['Model', 'store'];
patientConsentModelFactory.$inject = ['Model'];

export default patientConsentModelFactory;
18 changes: 9 additions & 9 deletions src/app/patients/consents/consents-component.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ function patientConsentsControllerFactory(
self.load(firstPromise([
store.findMany('patient-consents', {patient: $scope.patient.id}).then(function(patientConsents) {
$scope.patientConsents = patientConsents;
$scope.consentedCodes = {}
_.each(patientConsents, function(patientConsent) {
$scope.consentedCodes[patientConsent.consent.code] = true;
});
$scope.consentedCodes = {};
// _.each(patientConsents, function(patientConsent) {
// $scope.consentedCodes[patientConsent.consent.code] = true;
// });

}),
store.findMany('consents', {patient: $scope.patient.id}).then(function(consents) {
Expand All @@ -52,15 +52,15 @@ function patientConsentsControllerFactory(
var item = store.create('patient-consents', {patient: $scope.patient.id});
item.signedOnDate = new Date().toISOString();
item.consents = {};
_.each($scope.patientConsents, function(patientConsent) {
item.consents[patientConsent.id] = true;
})
// _.each($scope.patientConsents, function(patientConsent) {
// item.consents[patientConsent.id] = true;
// });
self.edit(item);
};
}

$scope.isChecked = function(code) {
return $scope.consentedCodes[code] === true;
}
};

}

Expand Down
9 changes: 9 additions & 0 deletions src/app/patients/patient-detail.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
function PatientDetailController(
$scope,
$state,
patient,
session,
hasPermissionForPatient,
Expand All @@ -23,10 +24,18 @@ function PatientDetailController(
// No demographics
return patient.getName(false);
}, titleService.setTitle);

var PATIENT_CONSENT_STATE = 'patient.consents';
$scope.$on('$stateChangeSuccess', function() {
if (!patient.consented) {
$state.go(PATIENT_CONSENT_STATE);
}
});
}

PatientDetailController.$inject = [
'$scope',
'$state',
'patient',
'session',
'hasPermissionForPatient',
Expand Down

0 comments on commit 31653fe

Please sign in to comment.