diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js
index 9953889f..3a7fbd81 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form1/Form1Controller.js
@@ -17,10 +17,8 @@
'
Absentismo' +
' Esquema Vacinal' +
' Conclusões/Resumo' +
- //' Propostas de Solução' +
' Observações' +
- ' Parecer/Reavaliação' +
- //' Reavaliação' +
+ ' Parecer/Reavaliação' +
' Data do Exame' +
' ' +
''
@@ -32,13 +30,6 @@
$scope.habilitacoes = new globals.dataService.store();
$scope.estadosCivis = new globals.dataService.store();
-
- $scope.storeDadosFicha = new globals.dataService.store({
- model: null,
- actions: {
- get: 'getDadosFichaFromBD'
- }
- });
$scope.storeFichasClinicas = new globals.dataService.store({
model: null,
@@ -50,72 +41,36 @@
});
$scope.add = function(selected){
-
+
$scope.editForm.$reset();
- $scope.editing = angular.copy(selected);
-
- $scope.editing.antecentesOcupacionaisActividadesAnteriores = [];
- $scope.editing.antecentesOcupacionaisAcidentesTrabalho = [];
- $scope.editing.antecentesOcupacionaisDoencasProfissionais = [];
- $scope.editing.antecentesOcupacionaisActividadesAnteriores = [];
-
- //TODO: rever estes modelos - 3 novas grelhas
- $scope.editing.antecedentesPessoaisCirurgias = [];
- $scope.editing.antecedentesPessoaisFracturas = [];
- $scope.editing.antecedentesPessoaisInternamentos = [];
-
- $scope.editing.actividade = {
- posto_representa_risco_saude: false
- };
-
- $scope.editing.antecentesOcupacionais = {
- exposto_factores_risco: false,
- acidentes_trabalho: false,
- doencas_profissionais: false,
- doencas_relacionadas_com_trabalho: false
- };
-
- //TODO: remaining fields!!!
- $scope.editing.exameObjectivo = {
- boca_nariz_normal: true,
- pele_mucosas_normal: true,
- acuidade_auditiva_normal: true,
- adenopatias_normal: true,
- pescoco_normal: true,
- torax_normal: true,
- auscultacao_cardiaca_normal: true,
- auscultacao_pulmonar_normal: true,
- mama_normal: true,
- abdomen_normal: true,
- coluna_vertebral_normal: true,
- membros_normal: true,
- exame_neurologico_normal: true
- };
-
- $scope.editing.classificacaoIndividualSaude = {
- sem_problemas_saude: true
- };
-
- $scope.editing.conclusoesResumo = {
- inapto_radio: 1,
- reavaliacao_radio: 1
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: null,
+ trabalhadorID: selected.ficha.trabalhador_id,
+ tipoFichaID: selected.ficha.tipo_ficha_id
};
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- scrollspyItems: scrollspyItems,
- afterrender: function(){
-
- $('body').scrollspy({
- target: '#scrollspyItems'
- });
- },
- documentclick: function(){
- $scope.openModalDocumentos();
- }
- });
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
+
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ scrollspyItems: scrollspyItems,
+ afterrender: function(){
+
+ $('body').scrollspy({
+ target: '#scrollspyItems'
+ });
+ },
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
+ });
};
$scope.edit = function(selected){
@@ -123,33 +78,31 @@
$scope.editForm.$reset();
$scope.storeFichasClinicas.extraParams = {
- fichaID: selected.id
+ fichaID: selected.id,
+ trabalhadorID: null,
+ tipoFichaID: null
};
$scope.storeFichasClinicas.get(function(response, status, headers, config, items){
-
- $scope.selected = items;
+
+ $scope.selected = items.fichaData;
$scope.editing = angular.copy($scope.selected);
- $timeout(function () {
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- scrollspyItems: scrollspyItems,
- afterrender: function(){
-
- $('body').scrollspy({
- target: '#scrollspyItems'
- });
- },
- documentclick: function(){
-
- $scope.openModalDocumentos();
- }
- });
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ scrollspyItems: scrollspyItems,
+ afterrender: function(){
+
+ $('body').scrollspy({
+ target: '#scrollspyItems'
+ });
+ },
+ documentclick: function(){
- }, 0);
+ $scope.openModalDocumentos();
+ }
+ });
});
};
@@ -169,15 +122,8 @@
$scope.editing.ficha.data_conclusao = null;
}
- //var isNewRecord = $scope.editing.ficha.id == null;
-
$scope.storeFichasClinicas.upsert($scope.selected, $scope.editing, function(response, selected, editing){
- //if(isNewRecord && response.success)
- //{
- // $scope.isNewRecord = true;
- //}
-
if(response.success && complete)
{
globals.plugins.hideFloatingSideMenu();
@@ -344,27 +290,15 @@
});
};
- $scope.$watch('editing.ficha.tipo_ficha_id', function(tipo_ficha_id, oldVal){
-
- if(tipo_ficha_id){
+ $scope.$watch('storeFichasClinicas.items', function(newVal, oldVal){
+
+ if(newVal.fieldsData){
- $scope.storeDadosFicha.extraParams = {
- tipoFichaID: tipo_ficha_id
- };
+ $scope.habilitacoes.items = [];
+ $scope.habilitacoes.loadData(newVal.fieldsData.habilitacoes);
- $scope.storeDadosFicha.get(function(response, status, headers, config, items){
-
- if(response.data){
-
- if(response.data.habilitacoes){
- $scope.habilitacoes.loadData(response.data.habilitacoes);
- }
-
- if(response.data.estadosCivis){
- $scope.estadosCivis.loadData(response.data.estadosCivis);
- }
- }
- });
+ $scope.estadosCivis.items = [];
+ $scope.estadosCivis.loadData(newVal.fieldsData.estadosCivis);
}
});
@@ -389,11 +323,6 @@
$scope.editing.classificacaoIndividualSaude.sem_problemas_saude = false;
}
};
-
- $scope.test = function(){
-
- alert('888');
- };
$scope.$on('afterrender', function(event, args){
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form2/Form2Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form2/Form2Controller.js
index 9d28e7aa..bfeca140 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form2/Form2Controller.js
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form2/Form2Controller.js
@@ -7,13 +7,6 @@
$scope.calculatedAge = 0;
$scope.motivos = new globals.dataService.store();
-
- $scope.storeDadosFicha = new globals.dataService.store({
- model: null,
- actions: {
- get: 'getDadosFichaFromBD'
- }
- });
$scope.storeFichasClinicas = new globals.dataService.store({
model: null,
@@ -25,46 +18,60 @@
});
$scope.add = function(selected){
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- documentclick: function(){
-
- $scope.openModalDocumentos();
- }
- });
-
+
$scope.editForm.$reset();
- $scope.editing = angular.copy(selected);
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: null,
+ trabalhadorID: selected.ficha.trabalhador_id,
+ tipoFichaID: selected.ficha.tipo_ficha_id
+ };
+
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
+
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
+ });
};
- $scope.edit = function(selected){
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- documentclick: function(){
+ $scope.edit = function(selected){
+
+ $scope.editForm.$reset();
- $scope.openModalDocumentos();
- }
- });
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: selected.id,
+ trabalhadorID: null,
+ tipoFichaID: null
+ };
- $timeout(function () {
-
- $scope.editForm.$reset();
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
- $scope.storeFichasClinicas.extraParams = {
- fichaID: selected.id
- };
+ $scope.editing = angular.copy($scope.selected);
+
+ $timeout(function () {
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ documentclick: function(){
- $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
-
- $scope.selected = items;
+ $scope.openModalDocumentos();
+ }
+ });
- $scope.editing = angular.copy($scope.selected);
- });
+ }, 0);
- }, 0);
+ });
};
$scope.save = function(complete){
@@ -154,26 +161,13 @@
//$scope.modalDocumentos.hide();
});
};
-
- $scope.$watch('editing.ficha.tipo_ficha_id', function(tipo_ficha_id, oldVal){
+
+ $scope.$watch('storeFichasClinicas.items', function(newVal, oldVal){
- if(tipo_ficha_id){
-
- $scope.motivos.items = [];
+ if(newVal.fieldsData){
- $scope.storeDadosFicha.extraParams = {
- tipoFichaID: tipo_ficha_id
- };
-
- $scope.storeDadosFicha.get(function(response, status, headers, config, items){
-
- if(response.data){
-
- if(response.data.motivos){
- $scope.motivos.loadData(response.data.motivos);
- }
- }
- });
+ $scope.motivos.items = [];
+ $scope.motivos.loadData(newVal.fieldsData.motivos);
}
});
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form3/Form3Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form3/Form3Controller.js
index e0d092a4..d46f9143 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form3/Form3Controller.js
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form3/Form3Controller.js
@@ -6,14 +6,7 @@
$scope.calculatedAge = 0;
- $scope.motivos = new globals.dataService.store();
-
- $scope.storeDadosFicha = new globals.dataService.store({
- model: null,
- actions: {
- get: 'getDadosFichaFromBD'
- }
- });
+ $scope.motivos = new globals.dataService.store();
$scope.storeFichasClinicas = new globals.dataService.store({
model: null,
@@ -25,51 +18,56 @@
});
$scope.add = function(selected){
-
+
$scope.editForm.$reset();
- $scope.editing = angular.copy(selected);
-
- $scope.editing.conclusoesResumo = {
- inapto_radio: 1,
- reavaliacao_radio: 1
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: null,
+ trabalhadorID: selected.ficha.trabalhador_id,
+ tipoFichaID: selected.ficha.tipo_ficha_id
};
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- documentclick: function(){
- $scope.openModalDocumentos();
- }
- });
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
+
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
+ });
};
$scope.edit = function(selected){
- $timeout(function () {
-
- $scope.editForm.$reset();
+ $scope.editForm.$reset();
- $scope.storeFichasClinicas.extraParams = {
- fichaID: selected.id
- };
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: selected.id,
+ trabalhadorID: null,
+ tipoFichaID: null
+ };
- $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
-
- $scope.selected = items;
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
- $scope.editing = angular.copy($scope.selected);
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- documentclick: function(){
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ documentclick: function(){
- $scope.openModalDocumentos();
- }
- });
- });
+ $scope.openModalDocumentos();
+ }
+ });
- }, 0);
+ });
};
$scope.save = function(complete){
@@ -160,23 +158,12 @@
});
};
- $scope.$watch('editing.ficha.tipo_ficha_id', function(tipo_ficha_id, oldVal){
+ $scope.$watch('storeFichasClinicas.items', function(newVal, oldVal){
- if(tipo_ficha_id){
+ if(newVal.fieldsData){
- $scope.storeDadosFicha.extraParams = {
- tipoFichaID: tipo_ficha_id
- };
-
- $scope.storeDadosFicha.get(function(response, status, headers, config, items){
-
- if(response.data){
-
- if(response.data.motivos){
- $scope.motivos.loadData(response.data.motivos);
- }
- }
- });
+ $scope.motivos.items = [];
+ $scope.motivos.loadData(newVal.fieldsData.motivos);
}
});
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form4/Form4Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form4/Form4Controller.js
index 33e343c7..6b47da4f 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form4/Form4Controller.js
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form4/Form4Controller.js
@@ -1,407 +1,341 @@
-evoapp.controller('Form4Controller', function($rootScope, $scope, $timeout, $compile, $injector, $filter, globals)
-{
- $scope.globals = globals;
-
- var scrollspyItems = $(
- ''
- );
-
- $scope.descricao = null;
-
- $scope.calculatedAge = 0;
-
- $scope.habilitacoes = new globals.dataService.store();
- $scope.estadosCivis = new globals.dataService.store();
-
- $scope.storeDadosFicha = new globals.dataService.store({
- model: null,
- actions: {
- get: 'getDadosFichaFromBD'
- }
- });
-
- $scope.storeFichasClinicas = new globals.dataService.store({
- model: null,
- actions: {
- get: 'getFicha',
- upsert: 'sendFicha',
- destroy: 'sendFicha'
- }
- });
-
- $scope.add = function(selected){
-
- $scope.editForm.$reset();
-
- $scope.editing = angular.copy(selected);
-
- $scope.editing.antecentesOcupacionaisActividadesAnteriores = [];
- $scope.editing.antecentesOcupacionaisAcidentesTrabalho = [];
- $scope.editing.antecentesOcupacionaisDoencasProfissionais = [];
- $scope.editing.antecentesOcupacionaisActividadesAnteriores = [];
-
- //TODO: rever estes modelos - 3 novas grelhas
- $scope.editing.antecedentesPessoaisCirurgias = [];
- $scope.editing.antecedentesPessoaisFracturas = [];
- $scope.editing.antecedentesPessoaisInternamentos = [];
-
- $scope.editing.actividade = {
- posto_representa_risco_saude: false
- };
-
- $scope.editing.antecentesOcupacionais = {
- exposto_factores_risco: false,
- acidentes_trabalho: false,
- doencas_profissionais: false,
- doencas_relacionadas_com_trabalho: false
- };
-
- //TODO: remaining fields!!!
- $scope.editing.exameObjectivo = {
- boca_nariz_normal: true,
- pele_mucosas_normal: true,
- acuidade_auditiva_normal: true,
- adenopatias_normal: true,
- pescoco_normal: true,
- torax_normal: true,
- auscultacao_cardiaca_normal: true,
- auscultacao_pulmonar_normal: true,
- mama_normal: true,
- abdomen_normal: true,
- coluna_vertebral_normal: true,
- membros_normal: true,
- exame_neurologico_normal: true
- };
-
- $scope.editing.classificacaoIndividualSaude = {
- sem_problemas_saude: true
- };
-
- $scope.editing.conclusoesResumo = {
- inapto_radio: 1,
- reavaliacao_radio: 1
- };
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- scrollspyItems: scrollspyItems,
- afterrender: function(){
-
- $('body').scrollspy({
- target: '#scrollspyItems'
- });
- },
- documentclick: function(){
-
- $scope.openModalDocumentos();
- }
- });
- };
-
- $scope.edit = function(selected){
-
- $scope.editForm.$reset();
-
- $scope.storeFichasClinicas.extraParams = {
- fichaID: selected.id
- };
-
- $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
-
- $scope.selected = items;
-
- $scope.editing = angular.copy($scope.selected);
-
- $timeout(function () {
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha Clinica',
- scrollspyItems: scrollspyItems,
- afterrender: function(){
-
- $('body').scrollspy({
- target: '#scrollspyItems'
- });
- },
- documentclick: function(){
-
- $scope.openModalDocumentos();
- }
- });
-
- }, 0);
-
- });
- };
-
- $scope.save = function(complete){
-
- var isValid = $scope.editForm.$isValid();
-
- if(isValid)
- {
- if(complete)
- {
- $scope.editing.ficha.data_conclusao = new Date();
- }
- else
- {
- $scope.editing.ficha.data_conclusao = null;
- }
-
- //var isNewRecord = $scope.editing.ficha.id == null;
-
- $scope.storeFichasClinicas.upsert($scope.selected, $scope.editing, function(response, selected, editing){
-
- //if(isNewRecord && response.success)
- //{
- // $scope.isNewRecord = true;
- //}
-
- if(response.success && complete)
- {
- globals.plugins.hideFloatingSideMenu();
-
- $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
-
- angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
- });
- }
- });
- }
- };
-
- $scope.gridAddItem = function(item, array, arrayName, el){
-
- if(!angular.isArray(array))
- {
- $scope.editing[arrayName] = new Array();
- array = $scope.editing[arrayName];
- }
-
- array.push(item);
-
- $timeout(function () {
-
- if(el != undefined)
- {
- var table = $(el.target).closest('table');
- if(table.length > 0)
- {
- var inputs = $(table[0]).find('input[data-required="true"]');
-
- $.each(inputs, function(index, el) {
-
- var input = $(el);
-
- //activate field validation
- $scope.editForm.$removeConstraints(input, false);
- });
- }
- }
- });
- };
-
- $scope.gridRemoveItem = function(index, array, el){
-
- if(angular.isArray(array))
- {
- if(el != undefined)
- {
- var table = $(el.target).closest('table');
- if(table.length > 0)
- {
- var trs = $(table[0]).find('tr[class="ng-scope"]');
-
- if(trs.length > 0 && trs[index] != undefined)
- {
- var tr = $(trs[index]);
-
- var inputs = tr.find('input[data-required="true"]');
-
- $.each(inputs, function(index, el) {
-
- var input = $(el);
-
- //disable field validation
- $scope.editForm.$removeConstraints(input, true);
- });
- }
- }
- }
-
- array.splice(index, 1);
- }
- };
-
- $scope.gridClearItems = function(tableId, arrayName){
-
- if(angular.isArray($scope.editing[arrayName]))
- {
- $scope.editing[arrayName] = new Array();
-
- var table = $scope.domEl.find('#' + tableId);
-
- if(table.length > 0){
-
- var trs = $(table[0]).find('tr[class="ng-scope"]');
-
- $.each(trs, function(index, trEl) {
-
- var inputs = $(trEl).find('input[data-required="true"]');
-
- $.each(inputs, function(index, inputEl) {
-
- var input = $(inputEl);
-
- //disable field validation
- $scope.editForm.$removeConstraints(input, true);
- });
- });
- }
-
- $scope.editing[arrayName] = new Array();
- }
- };
-
- $scope.cancel = function(){
-
- globals.message.custom({
- title: null,
- message: 'Pretende anular as alterações à ficha ou gravar para edição posterior?',
- buttons: {
- cancelar: {
- label: 'Cancelar',
- className: 'btn-default',
- callback: function() {
- //cancelar diálogo
- }
- },
- anular: {
- label: 'Anular',
- className: 'btn-danger',
- callback: function() {
-
- globals.plugins.hideFloatingSideMenu();
-
- $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
-
- angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
- });
- }
- },
- gravar: {
- label: 'Gravar',
- className: 'btn-success',
- callback: function() {
-
- $scope.save(false);
-
- globals.plugins.hideFloatingSideMenu();
-
- $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
-
- angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
- });
-
- }
- }
- }
- });
- };
-
- $scope.openModalDocumentos = function(){
-
- $scope.modalDocumentos.show({
-
- });
-
- $scope.modalDocumentos.viewController.list();
-
- $scope.modalDocumentos.viewController.$on('onAfterEdit', function(event, args) {
-
- //$scope.modalDocumentos.hide();
- });
- };
-
- $scope.$watch('editing.ficha.tipo_ficha_id', function(tipo_ficha_id, oldVal){
-
- if(tipo_ficha_id){
-
- $scope.storeDadosFicha.extraParams = {
- tipoFichaID: tipo_ficha_id
- };
-
- $scope.storeDadosFicha.get(function(response, status, headers, config, items){
-
- if(response.data){
-
- if(response.data.habilitacoes){
- $scope.habilitacoes.loadData(response.data.habilitacoes);
- }
-
- if(response.data.estadosCivis){
- $scope.estadosCivis.loadData(response.data.estadosCivis);
- }
- }
- });
- }
- });
-
- $scope.classificacaoIndividualSaude = function(selected){
-
- if (selected && $scope.editing.classificacaoIndividualSaude.sem_problemas_saude)
- {
- $scope.editing.classificacaoIndividualSaude.alteracao_temporaria_saude = false;
- $scope.editing.classificacaoIndividualSaude.doenca_cronica_sem_interferencia = false;
- $scope.editing.classificacaoIndividualSaude.doenca_cronica_com_interferencia = false;
- $scope.editing.classificacaoIndividualSaude.doenca_profissional = false;
- $scope.editing.classificacaoIndividualSaude.incapacidade_parcial = false;
- $scope.editing.classificacaoIndividualSaude.incapacidade_total = false;
- $scope.editing.classificacaoIndividualSaude.parecer_em_estudo = false;
- }
-
- if(selected && !$scope.editing.classificacaoIndividualSaude.sem_problemas_saude){
- $scope.editing.classificacaoIndividualSaude.sem_problemas_saude = true;
- }
-
- if(!selected){
- $scope.editing.classificacaoIndividualSaude.sem_problemas_saude = false;
- }
- };
-
- $scope.$on('afterrender', function(event, args){
-
- //listeners
- $scope.$watch('editing.ficha.trabalhador_data_nascimento', function(newVal, oldVal){
-
- if(newVal != null && newVal != oldVal)
- {
- var a = moment(new Date());
- var b = moment(newVal);
- $scope.calculatedAge = a.diff(b, 'years');
- }
- });
-
- });
+evoapp.controller('Form4Controller', function($rootScope, $scope, $timeout, $compile, $injector, $filter, globals)
+{
+ $scope.globals = globals;
+
+ var scrollspyItems = $(
+ ''
+ );
+
+ $scope.descricao = null;
+
+ $scope.calculatedAge = 0;
+
+ $scope.habilitacoes = new globals.dataService.store();
+ $scope.estadosCivis = new globals.dataService.store();
+
+ $scope.storeFichasClinicas = new globals.dataService.store({
+ model: null,
+ actions: {
+ get: 'getFicha',
+ upsert: 'sendFicha',
+ destroy: 'sendFicha'
+ }
+ });
+
+ $scope.add = function(selected){
+
+ $scope.editForm.$reset();
+
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: null,
+ trabalhadorID: selected.ficha.trabalhador_id,
+ tipoFichaID: selected.ficha.tipo_ficha_id
+ };
+
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
+
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ scrollspyItems: scrollspyItems,
+ afterrender: function(){
+
+ $('body').scrollspy({
+ target: '#scrollspyItems'
+ });
+ },
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
+ });
+ };
+
+ $scope.edit = function(selected){
+
+ $scope.editForm.$reset();
+
+ $scope.storeFichasClinicas.extraParams = {
+ fichaID: selected.id,
+ trabalhadorID: null,
+ tipoFichaID: null
+ };
+
+ $scope.storeFichasClinicas.get(function(response, status, headers, config, items){
+
+ $scope.selected = items.fichaData;
+
+ $scope.editing = angular.copy($scope.selected);
+
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha Clinica',
+ scrollspyItems: scrollspyItems,
+ afterrender: function(){
+
+ $('body').scrollspy({
+ target: '#scrollspyItems'
+ });
+ },
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
+
+ });
+ };
+
+ $scope.save = function(complete){
+
+ var isValid = $scope.editForm.$isValid();
+
+ if(isValid)
+ {
+ if(complete)
+ {
+ $scope.editing.ficha.data_conclusao = new Date();
+ }
+ else
+ {
+ $scope.editing.ficha.data_conclusao = null;
+ }
+
+ $scope.storeFichasClinicas.upsert($scope.selected, $scope.editing, function(response, selected, editing){
+
+ if(response.success && complete)
+ {
+ globals.plugins.hideFloatingSideMenu();
+
+ $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
+
+ angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
+ });
+ }
+ });
+ }
+ };
+
+ $scope.gridAddItem = function(item, array, arrayName, el){
+
+ if(!angular.isArray(array))
+ {
+ $scope.editing[arrayName] = new Array();
+ array = $scope.editing[arrayName];
+ }
+
+ array.push(item);
+
+ $timeout(function () {
+
+ if(el != undefined)
+ {
+ var table = $(el.target).closest('table');
+ if(table.length > 0)
+ {
+ var inputs = $(table[0]).find('input[data-required="true"]');
+
+ $.each(inputs, function(index, el) {
+
+ var input = $(el);
+
+ //activate field validation
+ $scope.editForm.$removeConstraints(input, false);
+ });
+ }
+ }
+ });
+ };
+
+ $scope.gridRemoveItem = function(index, array, el){
+
+ if(angular.isArray(array))
+ {
+ if(el != undefined)
+ {
+ var table = $(el.target).closest('table');
+ if(table.length > 0)
+ {
+ var trs = $(table[0]).find('tr[class="ng-scope"]');
+
+ if(trs.length > 0 && trs[index] != undefined)
+ {
+ var tr = $(trs[index]);
+
+ var inputs = tr.find('input[data-required="true"]');
+
+ $.each(inputs, function(index, el) {
+
+ var input = $(el);
+
+ //disable field validation
+ $scope.editForm.$removeConstraints(input, true);
+ });
+ }
+ }
+ }
+
+ array.splice(index, 1);
+ }
+ };
+
+ $scope.gridClearItems = function(tableId, arrayName){
+
+ if(angular.isArray($scope.editing[arrayName]))
+ {
+ $scope.editing[arrayName] = new Array();
+
+ var table = $scope.domEl.find('#' + tableId);
+
+ if(table.length > 0){
+
+ var trs = $(table[0]).find('tr[class="ng-scope"]');
+
+ $.each(trs, function(index, trEl) {
+
+ var inputs = $(trEl).find('input[data-required="true"]');
+
+ $.each(inputs, function(index, inputEl) {
+
+ var input = $(inputEl);
+
+ //disable field validation
+ $scope.editForm.$removeConstraints(input, true);
+ });
+ });
+ }
+
+ $scope.editing[arrayName] = new Array();
+ }
+ };
+
+ $scope.cancel = function(){
+
+ globals.message.custom({
+ title: null,
+ message: 'Pretende anular as alterações à ficha ou gravar para edição posterior?',
+ buttons: {
+ cancelar: {
+ label: 'Cancelar',
+ className: 'btn-default',
+ callback: function() {
+ //cancelar diálogo
+ }
+ },
+ anular: {
+ label: 'Anular',
+ className: 'btn-danger',
+ callback: function() {
+
+ globals.plugins.hideFloatingSideMenu();
+
+ $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
+
+ angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
+ });
+ }
+ },
+ gravar: {
+ label: 'Gravar',
+ className: 'btn-success',
+ callback: function() {
+
+ $scope.save(false);
+
+ globals.plugins.hideFloatingSideMenu();
+
+ $scope.$parent.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
+
+ angular.element(scope.comboTrabalhadores.domEl).triggerHandler('change');
+ });
+
+ }
+ }
+ }
+ });
+ };
+
+ $scope.openModalDocumentos = function(){
+
+ $scope.modalDocumentos.show({
+
+ });
+
+ $scope.modalDocumentos.viewController.list();
+
+ $scope.modalDocumentos.viewController.$on('onAfterEdit', function(event, args) {
+
+ //$scope.modalDocumentos.hide();
+ });
+ };
+
+ $scope.$watch('storeFichasClinicas.items', function(newVal, oldVal){
+
+ if(newVal.fieldsData){
+
+ $scope.habilitacoes.items = [];
+ $scope.habilitacoes.loadData(newVal.fieldsData.habilitacoes);
+
+ $scope.estadosCivis.items = [];
+ $scope.estadosCivis.loadData(newVal.fieldsData.estadosCivis);
+ }
+ });
+
+ $scope.classificacaoIndividualSaude = function(selected){
+
+ if (selected && $scope.editing.classificacaoIndividualSaude.sem_problemas_saude)
+ {
+ $scope.editing.classificacaoIndividualSaude.alteracao_temporaria_saude = false;
+ $scope.editing.classificacaoIndividualSaude.doenca_cronica_sem_interferencia = false;
+ $scope.editing.classificacaoIndividualSaude.doenca_cronica_com_interferencia = false;
+ $scope.editing.classificacaoIndividualSaude.doenca_profissional = false;
+ $scope.editing.classificacaoIndividualSaude.incapacidade_parcial = false;
+ $scope.editing.classificacaoIndividualSaude.incapacidade_total = false;
+ $scope.editing.classificacaoIndividualSaude.parecer_em_estudo = false;
+ }
+
+ if(selected && !$scope.editing.classificacaoIndividualSaude.sem_problemas_saude){
+ $scope.editing.classificacaoIndividualSaude.sem_problemas_saude = true;
+ }
+
+ if(!selected){
+ $scope.editing.classificacaoIndividualSaude.sem_problemas_saude = false;
+ }
+ };
+
+ $scope.$on('afterrender', function(event, args){
+
+ //listeners
+ $scope.$watch('editing.ficha.trabalhador_data_nascimento', function(newVal, oldVal){
+
+ if(newVal != null && newVal != oldVal)
+ {
+ var a = moment(new Date());
+ var b = moment(newVal);
+ $scope.calculatedAge = a.diff(b, 'years');
+ }
+ });
+
+ });
});
\ No newline at end of file
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5Controller.js b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5Controller.js
index 0e54ff25..0b88ff42 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5Controller.js
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5Controller.js
@@ -24,27 +24,23 @@
$scope.storeFichasClinicas.get(function(response, status, headers, config, items){
- $scope.selected = items;
+ $scope.selected = items.fichaData;
$scope.editing = angular.copy($scope.selected);
- $timeout(function () {
-
- globals.plugins.buildFloatingSideMenu({
- title: 'Ficha de Aptidão',
- documentclick: function(){
-
- $scope.openModalDocumentos();
- }
- });
-
- }, 0);
+ globals.plugins.buildFloatingSideMenu({
+ title: 'Ficha de Aptidão',
+ documentclick: function(){
+
+ $scope.openModalDocumentos();
+ }
+ });
});
};
$scope.edit = function(selected){
-
+
};
$scope.save = function(complete){
diff --git a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5View.html b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5View.html
index 109db8e1..f3b55008 100644
--- a/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5View.html
+++ b/trunk/SiprpWebFichasClinicas/WebContent/static/html/app/Form5/Form5View.html
@@ -177,7 +177,7 @@