git-svn-id: https://svn.coded.pt/svn/SIPRP@1972 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
João Maurício 11 years ago
parent 6242a7d54e
commit 13a2fcd041

@ -17,10 +17,8 @@
' <li><a href="#section10">Absentismo</a></li>' +
' <li><a href="#section11">Esquema Vacinal</a></li>' +
' <li><a href="#section12">Conclusões/Resumo</a></li>' +
//' <li><a href="#section13"> Propostas de Solução</a></li>' +
' <li><a href="#section14">Observações</a></li>' +
' <li><a href="#section15">Parecer/Reavaliação</a></li>' +
//' <li><a href="#section16">Reavaliação</a></li>' +
' <li><a href="#section15">Parecer/Reavaliação</a></li>' +
' <li><a href="#section17">Data do Exame</a></li>' +
'</ul> ' +
'</div>'
@ -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){

@ -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);
}
});

@ -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);
}
});

@ -1,407 +1,341 @@
evoapp.controller('Form4Controller', function($rootScope, $scope, $timeout, $compile, $injector, $filter, globals)
{
$scope.globals = globals;
var scrollspyItems = $(
'<div id="scrollspyItems"> ' +
'<ul class="nav nav-pills nav-stacked m-t-5 m-b-5"> ' +
' <li><a href="#section1">Identifica&ccedil;&atilde;o</a></li>' +
' <li><a href="#section2">Actividade</a></li>' +
' <li><a href="#section3">Antecedentes Ocupacionais</a></li>' +
' <li><a href="#section4">Antecedentes Pessoais</a></li>' +
' <li><a href="#section5">Hábitos</a></li>' +
' <li><a href="#section6">Antecedentes Familiares</a></li>' +
' <li><a href="#section7">Exame Objectivo</a></li>' +
' <li><a href="#section8">Doenças Activas</a></li>' +
' <li><a href="#section9">Classificação Individual de Saúde</a></li>' +
' <li><a href="#section10">Absentismo</a></li>' +
' <li><a href="#section11">Esquema Vacinal</a></li>' +
' <li><a href="#section12">Conclusões/Resumo</a></li>' +
//' <li><a href="#section13"> Propostas de Solução</a></li>' +
' <li><a href="#section14">Observações</a></li>' +
' <li><a href="#section15">Parecer/Reavaliação</a></li>' +
//' <li><a href="#section16">Reavaliação</a></li>' +
' <li><a href="#section17">Data do Exame</a></li>' +
'</ul> ' +
'</div>'
);
$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 = $(
'<div id="scrollspyItems"> ' +
'<ul class="nav nav-pills nav-stacked m-t-5 m-b-5"> ' +
' <li><a href="#section1">Identifica&ccedil;&atilde;o</a></li>' +
' <li><a href="#section2">Actividade</a></li>' +
' <li><a href="#section3">Antecedentes Ocupacionais</a></li>' +
' <li><a href="#section4">Antecedentes Pessoais</a></li>' +
' <li><a href="#section5">Hábitos</a></li>' +
' <li><a href="#section6">Antecedentes Familiares</a></li>' +
' <li><a href="#section7">Exame Objectivo</a></li>' +
' <li><a href="#section8">Doenças Activas</a></li>' +
' <li><a href="#section9">Classificação Individual de Saúde</a></li>' +
' <li><a href="#section10">Absentismo</a></li>' +
' <li><a href="#section11">Esquema Vacinal</a></li>' +
' <li><a href="#section12">Conclusões/Resumo</a></li>' +
' <li><a href="#section14">Observações</a></li>' +
' <li><a href="#section15">Parecer/Reavaliação</a></li>' +
' <li><a href="#section17">Data do Exame</a></li>' +
'</ul> ' +
'</div>'
);
$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');
}
});
});
});

@ -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){

@ -177,7 +177,7 @@
<div class="col-md-8 p-l-none">
<div ng-show="editing.ficha.tipo_ficha_id == 7" class="row">
<!--<div class="col-lg-12 p-l-none">
<div class="col-lg-12 p-l-none">
<div class="checkbox">
<label>
<input ng-model="editing.ficha.motivo_id" name="rb_ocasional_motivo" ng-value="200" type="radio"/>
@ -228,7 +228,7 @@
</div>
</div>
</div>
</div> -->
</div>
</div>
</div>

Loading…
Cancel
Save