adicionado API e DB no import_sigtap_screen.dart
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rkm/screens/home_screen.dart';
|
||||
import 'package:rkm/service/db/db_sqlite_Sigtap.dart';
|
||||
import '../../config/color_palette.dart';
|
||||
import '../../config/const_variable.dart';
|
||||
import '../../service/shared_preferences/shared_preferences_service.dart';
|
||||
import '../../service/api/api_data_import_sigtap.dart';
|
||||
import '../../service/db/db_sqlite_load.dart';
|
||||
import '../../widgets/button_default.dart';
|
||||
import '../../widgets/text_default.dart';
|
||||
|
||||
class ImportSigtapScreen extends StatefulWidget {
|
||||
@@ -14,18 +17,62 @@ class ImportSigtapScreen extends StatefulWidget {
|
||||
class _ImportSigtapScreenState extends State<ImportSigtapScreen> {
|
||||
|
||||
String mode ='';
|
||||
String urlAPI ='';
|
||||
String nameCityApi ='';
|
||||
String stage = 'Conectando ...';
|
||||
bool finish = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dataSQLite();
|
||||
recupDB();
|
||||
}
|
||||
|
||||
dataSQLite()async{
|
||||
final PrefService _preferences = PrefService();
|
||||
_preferences.readCacheModel('user', 'password', 'city', 'mode').then((list){
|
||||
recupDB()async{
|
||||
await DbSqliteLoad().intialDB().then((db)async{
|
||||
List list = await db.query('ARGS');
|
||||
urlAPI = list[0]['URLAPI'];
|
||||
mode = list[0]['MODE'];
|
||||
nameCityApi = list[0]['NAME_CITY_API'];
|
||||
}).then((value){
|
||||
setState(() {});
|
||||
importSigtap();
|
||||
});
|
||||
}
|
||||
|
||||
importSigtap()async{
|
||||
await DbSqliteSigtap().deleteSigtap().then((value)async{
|
||||
setState(() {
|
||||
mode = list[3];
|
||||
stage = "Etapa 1 de 4 - Importando informações do CONECTASUS";
|
||||
});
|
||||
await ApiDataImportSigtap().loadSIGTAP(urlAPI, mode, nameCityApi).then((valueAPI)async{
|
||||
setState(() {
|
||||
stage = "Etapa 2 de 4 - Gravando os Procedimentos no Aplicativo";
|
||||
});
|
||||
// print(value['procedimentos']);
|
||||
await DbSqliteSigtap().saveProceduresSigtapDB(valueAPI['procedimentos']).then((value)async{
|
||||
await DbSqliteSigtap().saveProceduresRegisterSigtapDB(valueAPI['procedimentosRegistros']).then((value)async{
|
||||
setState(() {
|
||||
stage = "Etapa 3 de 4 - Gravando os CIDs no Aplicativo";
|
||||
});
|
||||
await DbSqliteSigtap().saveSigtapCID(valueAPI['CID']).then((value)async{
|
||||
await DbSqliteSigtap().saveProceduresSigtapCID(valueAPI['procedimentosCID']).then((value)async{
|
||||
setState(() {
|
||||
stage = "Etapa 4 de 4 - Gravando os CIDs no Aplicativo";
|
||||
});
|
||||
await DbSqliteSigtap().saveCBOSigtap(valueAPI['CBO']).then((value)async{
|
||||
await DbSqliteSigtap().saveProceduresCBOSigtap(valueAPI['procedimentosCBO']).then((value)async{
|
||||
await DbSqliteSigtap().saveSyncSigtap(valueAPI['competencia']).then((value)async{
|
||||
setState(() {
|
||||
finish = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -40,10 +87,29 @@ class _ImportSigtapScreenState extends State<ImportSigtapScreen> {
|
||||
color: ColorPalette.appBar,
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: TextDefault(
|
||||
text: 'Etapa 1 de 4 - Teste',
|
||||
child: finish
|
||||
?Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
ButtonDefault(
|
||||
onPressed: (){
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HomeScreen()),
|
||||
);
|
||||
},
|
||||
title: 'Continuar',
|
||||
width: width*0.3,
|
||||
height: height*0.05,
|
||||
textColor: ColorPalette.white,
|
||||
background: ColorPalette.appBar,
|
||||
borderColor: ColorPalette.appBar,
|
||||
),
|
||||
],
|
||||
):TextDefault(
|
||||
text: stage,
|
||||
color: ColorPalette.white,
|
||||
fontSize: 20,
|
||||
fontSize: 15,
|
||||
fontWeigth: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -58,7 +124,12 @@ class _ImportSigtapScreenState extends State<ImportSigtapScreen> {
|
||||
),
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Column(
|
||||
child: finish?ListView(
|
||||
children: [
|
||||
Image.asset('assets/images/logo.PNG',width: width*0.25,height: height*0.1,),
|
||||
Image.asset('assets/images/sigtap-done.png',width: width*0.9,height: height*0.2,),
|
||||
],
|
||||
):Column(
|
||||
children: [
|
||||
Image.asset('assets/images/logo.PNG',width: width*0.5,),
|
||||
mode == 'homologacao'?Image.asset('assets/images/homologacao.png',width: width*0.4):Container(),
|
||||
|
||||
45
lib/screens/configurations/sigtap_json
Normal file
45
lib/screens/configurations/sigtap_json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"competencia":"202303",
|
||||
"procedimentos":[
|
||||
{
|
||||
"codProcedimento":"0101010010",
|
||||
"nome":"ATIVIDADE EDUCATIVA \/ ORIENTA\u00c7\u00c3O EM GRUPO NA ATEN\u00c7\u00c3O PRIM\u00c1RIA",
|
||||
"codGrupo":"01",
|
||||
"qtdeMax":9999,
|
||||
"idadeMin":833,
|
||||
"idadeMax":833,
|
||||
"sexo":"N"
|
||||
}
|
||||
],
|
||||
"procedimentosRegistros":[
|
||||
{
|
||||
"codProcedimento":"0101010010",
|
||||
"codRegistro":"01"
|
||||
}
|
||||
],
|
||||
"CID":[
|
||||
{
|
||||
"codCID":"A000",
|
||||
"descCID":"A00.0 Colera dev Vibrio cholerae 01 biot cholerae",
|
||||
"restSexo":"5"
|
||||
}
|
||||
],
|
||||
"procedimentosCID":[
|
||||
{
|
||||
"codProcedimento":"0201010046",
|
||||
"codCID":"C211"
|
||||
}
|
||||
],
|
||||
"CBO":[
|
||||
{
|
||||
"codCBO":"223208",
|
||||
"descCBO":"Cirurgi\u00e3o dentista - cl\u00ednico geral"
|
||||
}
|
||||
],
|
||||
"procedimentosCBO":[
|
||||
{
|
||||
"codProcedimento":"0101010010",
|
||||
"codCBO":"223208"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -181,6 +181,7 @@ class _LoadInitScreenState extends State<LoadInitScreen> {
|
||||
:Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: TextDefault(
|
||||
fontSize: 15,
|
||||
text: messageSteps,
|
||||
color: ColorPalette.white,
|
||||
maxLines: 2,
|
||||
|
||||
@@ -27,8 +27,8 @@ class _LoginLoadScreenState extends State<LoginLoadScreen> {
|
||||
String? selectCity;
|
||||
bool validatorDropDown= false;
|
||||
int contLogo = 0;
|
||||
String mode = 'homologacao';
|
||||
String urlAPI = UrlApiConst.ApiUrlHomologacao;
|
||||
String mode = 'desenvolvimento';
|
||||
String urlAPI = UrlApiConst.ApiUrlDesenvolvimento;
|
||||
bool loading = false;
|
||||
String nameCityApi = '';
|
||||
String nameCityFront = '';
|
||||
|
||||
@@ -202,6 +202,7 @@ class _SyncInitScreenState extends State<SyncInitScreen> {
|
||||
:Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: TextDefault(
|
||||
fontSize: 15,
|
||||
text: messageSteps,
|
||||
color: ColorPalette.white,
|
||||
maxLines: 2,
|
||||
|
||||
Reference in New Issue
Block a user