sincronização com o atendimento dominiciliar
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user