sincronização com o atendimento dominiciliar

This commit is contained in:
Reginaldo
2023-05-08 12:41:22 -03:00
parent 532d186d5b
commit 5c7ff19477
10 changed files with 207 additions and 28 deletions

View File

@@ -116,13 +116,13 @@ class _SincDataScreenState extends State<SincDataScreen> {
// print(tableFICHAS_COMPLEMENTARES);
await DBQuerys().atendimentosDomiciliares().then((response)async{
tableATENDIMENTOS_DOMICILIARES = response;
// print(tableATENDIMENTOS_DOMICILIARES);
print(tableATENDIMENTOS_DOMICILIARES);
await DBQuerys().atendDomCompl().then((response)async{
tableATENDS_DOM_COMPL = response;
// print(tableATENDS_DOM_COMPL);
print(tableATENDS_DOM_COMPL);
await DBQuerys().atendDomProcsFicha().then((response)async{
tableATENDS_DOM_PROC = response;
// print(tableATENDS_DOM_PROC);
print(tableATENDS_DOM_PROC);
await DBQuerys().atendDomProcsSigtap().then((response)async{
tableATENDS_DOM_SIGTAP = response;
// print(tableATENDS_DOM_SIGTAP);

View File

@@ -145,11 +145,10 @@ class _HomeScreenState extends State<HomeScreen> {
await DBQuerys().buscaCidadao(showResults[index]['NOME_CIDADAO']).then((list){
Navigator.push(
context,
MaterialPageRoute(builder:
(context) => RegisterCitizenScreen(listData: list,)),
MaterialPageRoute(builder:(context) => RegisterCitizenScreen(listData: list,)),
);
});
}
},
);
}
)

View File

@@ -816,6 +816,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10),
decoration: BoxDecoration(
color: date.isEmpty?ColorPalette.disable:ColorPalette.white,
border: Border.all(color: ColorPalette.white),
borderRadius: BorderRadius.all(
Radius.circular(5.0)
@@ -1463,7 +1464,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: TextDefault(text: 'SEM NÚMERO',fontSize: 15,),
child: TextDefault(text: 'SEM NÚMERO',fontSize: 15,color: Colors.black,),
)
],
),
@@ -1823,6 +1824,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10),
decoration: BoxDecoration(
color: RGDateController.text.isEmpty?ColorPalette.disable:ColorPalette.white,
border: Border.all(color: ColorPalette.white),
borderRadius: BorderRadius.all(
Radius.circular(5.0)
@@ -1933,6 +1935,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10),
decoration: BoxDecoration(
color: dateCertificateController.text.isEmpty?ColorPalette.disable:ColorPalette.white,
border: Border.all(color: ColorPalette.white),
borderRadius: BorderRadius.all(
Radius.circular(5.0)
@@ -2113,6 +2116,7 @@ class _RegisterCitizenScreenState extends State<RegisterCitizenScreen> {
margin: EdgeInsets.symmetric(horizontal: 15,vertical: 5),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10),
decoration: BoxDecoration(
color: dateDeathController.text.isEmpty?ColorPalette.disable:ColorPalette.white,
border: Border.all(color: ColorPalette.white),
borderRadius: BorderRadius.all(
Radius.circular(5.0)

View File

@@ -12,17 +12,20 @@ import '../../models/drop_down_data_string_model.dart';
import '../../service/api/api_data_import_sigtap.dart';
import '../../service/db/db_querys.dart';
import '../../service/db/db_sqlite_load.dart';
import '../../service/db/db_sqlite_sync.dart';
import '../../service/shared_preferences/shared_preferences_service.dart';
import '../../widgets/button_default.dart';
import '../../widgets/check_box_subtitle.dart';
import '../../widgets/dropdown_with_subtitle.dart';
import '../../widgets/error_default.dart';
import '../../widgets/input_with_subtitle.dart';
import '../../widgets/onbackbutton.dart';
import '../../widgets/text_default.dart';
import '../../widgets/title_containers.dart';
class ServiceHomeScreen extends StatefulWidget {
const ServiceHomeScreen({Key? key}) : super(key: key);
String name;
ServiceHomeScreen({required this.name});
@override
State<ServiceHomeScreen> createState() => _ServiceHomeScreenState();
@@ -39,7 +42,13 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
String dateDB='';
String idUsuario='';
String idUnidade='';
String? nameCityApi;
String? mode;
String? urlAPI;
String CD_USUARIO_SUS = '';
String INE_PROFISSIONAL = '';
int ID_CIDADAO=0;
int ID_PROFISSIONAL=0;
int LOCAL_ATENDIMENTO_COD=0;
int TIPO_ATENDIMENTO_COD=0;
@@ -47,9 +56,10 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
int TURNO_COD=0;
int CIAP_COD=0;
int CONDUTA_COD=0;
int ID_EQUIPE=0;
String CID_COD='';
String? selectCBO;
String? CBO_PROFISSIONAL;
String? CIAP;
String? CID;
String? CBO_RESP_CADASTRO;
@@ -59,9 +69,6 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
String? MODALIDADE;
String? TURNO;
String? CONDUTA;
String? nameCityApi;
String? mode;
String? urlAPI;
List<CheckModel> serviceHomeModel = [];
List<CheckModel> serviceProcModel = [];
@@ -79,6 +86,8 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
List listProc = [];
bool CNS_VALIDO = false;
bool mandatory = false;
bool showCheckError = false;
escolherprazoInicio(BuildContext context) async {
var pickDate = await showDatePicker(
@@ -185,9 +194,81 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
setState(() {});
}
checkSave()async{
// adicionar depois e usar um usuário real
// CBO_RESP_CADASTRO
//ok
if(date.isEmpty || dateDB.isEmpty || LOCAL_ATENDIMENTO_COD==0 || TIPO_ATENDIMENTO_COD ==0 || MODALIDADE_COD == 0 || TURNO_COD == 0
){
print('erro');
setState(() {
showCheckError = true;
mandatory = true;
});
}else{
print('passou');
setState(() {
mandatory = false;
showCheckError = false;
saveServiceHome();
});
}
}
saveServiceHome()async{
Map<String, dynamic> row = {
'ID_CIDADAO' : ID_CIDADAO,
'CD_USUARIO_SUS' : CD_USUARIO_SUS,
'ID_PROFISSIONAL' : int.parse(idUsuario),
'CBO_PROFISSIONAL' : CBO_PROFISSIONAL,
'INE_PROFISSIONAL' : INE_PROFISSIONAL,
'CNES_UNIDADE' : CNES_UNIDADE.text,
'ID_UNIDADE' : int.parse(idUnidade),
'ID_EQUIPE' : ID_EQUIPE,
'DATA' : dateDB,
'LOCAL_ATENDIMENTO' : LOCAL_ATENDIMENTO_COD,
'TIPO_ATENDIMENTO' : TIPO_ATENDIMENTO_COD,
'MODALIDADE' : MODALIDADE_COD,
'TURNO' : TURNO_COD,
'CIAP' : CIAP_COD,
'CID' : CID_COD,
'CONDUTA' : CONDUTA_COD,
'SINCRONIZADO' : 'N',
};
await DbSqliteSync().insertAtendimentoDomiciliar(row).then((value){
for(int i = 0;serviceHomeModel.length>i;i++){
if(serviceHomeModel[i].check){
DbSqliteSync().insertCondicoesAvaliadas(value,i+1);
}
}
for(int i = 0;serviceProcModel.length>i;i++){
if(serviceProcModel[i].check){
DbSqliteSync().insertProcedimentosDomiciliares(value,i+1);
}
}
AlertDialogDefault().alert(
context,
'Aviso',
'Atendimento Domiciliar salvo com sucesso!',
'OK'
);
});
}
dadosCidadao()async{
await DBQuerys().buscaCidadao(widget.name).then((list){
ID_CIDADAO = list[0]['ID_CIDADAO'];
CD_USUARIO_SUS = list[0]['CD_USUARIO_SUS'];
});
List list = await DBQuerys().buscaDadosProfissional(idUnidade,idUsuario);
INE_PROFISSIONAL = list[0]['INE'];
ID_EQUIPE = list[0]['ID_EQUIPE'];
}
@override
void initState() {
super.initState();
dadosCidadao();
getUser();
loadLists();
}
@@ -251,16 +332,17 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
widthSubtitle: width*0.7,
subtitle: 'CBO',
hintDropdown: 'CBO',
select: selectCBO,
select: CBO_PROFISSIONAL,
widthDropdown: width*0.7,
widthContainerDropdown: width*0.6,
onChanged: (value){
setState(() {
selectCBO = value!;
CBO_PROFISSIONAL = value!;
});
},
colorBorder: ColorPalette.white,
),
CBO_PROFISSIONAL == null && mandatory?ErrorDefault():Container(),
DropdownWithSubtitle(
list: listINEPROF,
widthSubtitle: width*0.3,
@@ -292,10 +374,9 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
margin: EdgeInsets.symmetric(horizontal: 10),
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 10),
decoration: BoxDecoration(
color: date.isEmpty?ColorPalette.disable:ColorPalette.white,
border: Border.all(color: ColorPalette.white),
borderRadius: BorderRadius.all(
Radius.circular(5.0) // <--- border radius here
),
borderRadius: BorderRadius.all(Radius.circular(5.0)),
),
width: width*0.7,
child: TextDefault(
@@ -305,6 +386,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
),
),
),
date.isEmpty&& mandatory?ErrorDefault():Container(),
DropdownWithSubtitle(
list: listServicePlace,
widthSubtitle: width*0.2,
@@ -324,6 +406,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
},
colorBorder: ColorPalette.white,
),
LOCAL_ATENDIMENTO_COD ==0 && mandatory?ErrorDefault():Container(),
DropdownWithSubtitle(
list: typeService,
widthSubtitle: width*0.2,
@@ -343,6 +426,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
},
colorBorder: ColorPalette.white,
),
TIPO_ATENDIMENTO_COD ==0 && mandatory?ErrorDefault():Container(),
DropdownWithSubtitle(
list: typeModelService,
widthSubtitle: width*0.2,
@@ -362,6 +446,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
},
colorBorder: ColorPalette.white,
),
MODALIDADE_COD ==0 && mandatory?ErrorDefault():Container(),
DropdownWithSubtitle(
list: typeTurnService,
widthSubtitle: width*0.2,
@@ -381,6 +466,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
},
colorBorder: ColorPalette.white,
),
TURNO_COD ==0 && mandatory?ErrorDefault():Container(),
],
)
],
@@ -562,7 +648,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
IconButton(
icon: Icon(Icons.add_circle,color: ColorPalette.blackButton),
onPressed: (){
AlertDialogDefault().otherProc(context, 'Outros Procedimentos', 'Adicionar Procedimento', selectCBO, selectCBO, 'add',PROCEDIMENTOS_SIGTAP,listProc);
AlertDialogDefault().otherProc(context, 'Outros Procedimentos', 'Adicionar Procedimento', CBO_PROFISSIONAL, CBO_PROFISSIONAL, 'add',PROCEDIMENTOS_SIGTAP,listProc);
},
)
],
@@ -623,6 +709,41 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
]
)
),
CNS_VALIDO?Card(
margin: EdgeInsets.all(10),
child: Container(
padding: const EdgeInsets.all(8.0),
width: width,
height: heigth*0.1,
child: Row(
children: [
Icon(Icons.warning,color: ColorPalette.red,),
Container(
width: width*0.9,
child: TextDefault(
text: 'CNS do Profissional inválido. Este cadastro não será exportado para o e-SUS.',
fontSize: 15,
maxLines: 2,
color: ColorPalette.red,
),
),
],
),
),
):Container(),
showCheckError?Card(
margin: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.all(10),
child: Row(
children: [
Icon(Icons.warning,color: Colors.red,),
TextDefault(text: 'Existem campos obrigatórios não preenchidos.',color: ColorPalette.red,fontSize: 15,)
],
),
),
color: ColorPalette.white,
):Container(),
Card(
margin: EdgeInsets.all(10),
child: Padding(
@@ -630,7 +751,7 @@ class _ServiceHomeScreenState extends State<ServiceHomeScreen> {
child: Column(
children: [
ButtonDefault(
onPressed: (){},
onPressed: ()=>checkSave(),
title: 'Salvar',
borderColor: ColorPalette.appBar,
background: ColorPalette.appBar,