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