alterado de insert para insert into para adicionar todos os itens nas tabelas de uma vez
This commit is contained in:
@@ -57,161 +57,284 @@ class _LoadInitScreenState extends State<LoadInitScreen> {
|
||||
_prefService.createCacheidUsuario(idUsuario).then((value)async{
|
||||
await ApiDataLoad().loadUnidades(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 1 de 10 - Gravando as Unidades no Aplicativo";
|
||||
messageSteps = "Etapa 1 de 11 - Gravando as Unidades no Aplicativo";
|
||||
});
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveUnidadesDB(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'ID_UNIDADE': list[i]['idUnidade'],
|
||||
'NOME_UNIDADE': list[i]['nomeFantasia'],
|
||||
'CNES_UNIDADE': list[i]['nrCNES']
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.1;
|
||||
setState(() {});
|
||||
}
|
||||
await ApiDataLoad().loadProcedimentos(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
setState(() {
|
||||
messageSteps = "Etapa 2 de 10 - Gravando os Procedimentos no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveProceduresDB(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
print('finalizou save Procedures');
|
||||
await ApiDataLoad().loadProcedimentosRegistros(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
setState(() {
|
||||
messageSteps = "Etapa 3 de 10 - Gravando os Procedimentos Registros no Aplicativo";
|
||||
});
|
||||
await DbSqliteLoad().saveUnidadesDB(rows).then((value)async{
|
||||
await ApiDataLoad().loadProcedimentos(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveProceduresRegisterDB(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
print('finalizou saveProceduresRegisterDB');
|
||||
await ApiDataLoad().loadCID(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCID');
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 4 de 10 - Gravando os CIDs no Aplicativo";
|
||||
messageSteps = "Etapa 2 de 11 - Gravando os Procedimentos no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveCID(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'COD_PROC_SIGTAP' : list[i]['codProcedimento'],
|
||||
'DESC_PROC_SIGTAP' : list[i]['nome'],
|
||||
'GRUPO_PROC_SIGTAP' : list[i]['codGrupo'],
|
||||
'QTDE_MAXIMA' : list[i]['qtdeMax'],
|
||||
'IDADE_MIN' : list[i]['idadeMin'],
|
||||
'IDADE_MAX' : list[i]['idadeMax'],
|
||||
'SEXO' : list[i]['sexo'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.2;
|
||||
setState(() {});
|
||||
}
|
||||
print('finalizou saveCID');
|
||||
await ApiDataLoad().loadProcedimentosCID(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadProcedimentosCID');
|
||||
setState(() {
|
||||
messageSteps = "Etapa 5 de 10 - Gravando os Procedimentos CIDs no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveProceduresCID(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
print('finalizou saveProceduresCID');
|
||||
await ApiDataLoad().loadCBO(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCBO');
|
||||
setState(() {
|
||||
messageSteps = "Etapa 6 de 10 - Gravando os CBOs no Aplicativo";
|
||||
});
|
||||
await DbSqliteLoad().saveProceduresDB(rows).then((value)async{
|
||||
print('finalizou save Procedures');
|
||||
await ApiDataLoad().loadProcedimentosRegistros(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveCBO(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
print('finalizou saveCBO');
|
||||
await ApiDataLoad().loadProcedimentosCBO(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadProcedimentosCBO');
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 7 de 10 - Gravando os Procedimentos CBO no Aplicativo";
|
||||
messageSteps = "Etapa 3 de 11 - Gravando os Procedimentos Registros no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveProceduresCBO(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
print('finalizou saveProceduresRegisterDB');
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'COD_PROC_SIGTAP' : list[i]['codProcedimento'],
|
||||
'CODIGO_REGISTRO' : list[i]['codRegistro'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.3;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
print('finalizou saveProceduresCBO');
|
||||
await ApiDataLoad().loadCIAP(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCIAP');
|
||||
setState(() {
|
||||
messageSteps = "Etapa 8 de 10 - Gravando os CIAPs no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveCIAP(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
print('finalizou saveCIAP');
|
||||
await ApiDataLoad().loadMunicipios(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadMunicipios');
|
||||
setState(() {
|
||||
messageSteps = "Etapa 9 de 10 - Gravando os Municípios no Aplicativo";
|
||||
});
|
||||
await DbSqliteLoad().saveProceduresRegisterDB(rows).then((value)async{
|
||||
await ApiDataLoad().loadCID(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCID');
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveCity(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
await ApiDataLoad().loadEquipes(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadEquipes');
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 10 de 10 - Gravando as Equipes no Aplicativo";
|
||||
messageSteps = "Etapa 4 de 11 - Gravando os CIDs no Aplicativo";
|
||||
});
|
||||
List list = value;
|
||||
for(int i=0;list.length > i;i++){
|
||||
await DbSqliteLoad().saveTeam(value,i).then((value)async{
|
||||
int cont = list.length!=0?list.length:0;
|
||||
countProg = i/cont;
|
||||
setState(() {});
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'CODIGO_CID' : list[i]['codCID'],
|
||||
'DESCRICAO_CID' : list[i]['descCID'],
|
||||
'RESTRICAO_SEXO' : list[i]['restSexo'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.4;
|
||||
setState(() {});
|
||||
}
|
||||
print('finalizou saveTeam');
|
||||
await ApiDataLoad().loadEquipeComponentes(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadEquipeComponentes');
|
||||
await DbSqliteLoad().saveTeamComponents(value).then((value)async{
|
||||
print('finalizou saveTeamComponents');
|
||||
setState(() {
|
||||
finish = true;
|
||||
});
|
||||
await DbSqliteLoad().saveCID(rows).then((value)async{
|
||||
print('finalizou saveCID');
|
||||
await ApiDataLoad().loadProcedimentosCID(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadProcedimentosCID');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 5 de 11 - Gravando os Procedimentos CIDs no Aplicativo";
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'COD_PROC_SIGTAP' : list[i]['codProcedimento'],
|
||||
'CODIGO_CID' : list[i]['codCID'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.5;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveProceduresCID(rows).then((value)async{
|
||||
print('finalizou saveProceduresCID');
|
||||
await ApiDataLoad().loadCBO(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCBO');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 6 de 11 - Gravando os CBOs no Aplicativo";
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'CODIGO_CBO' : list[i]['codCBO'],
|
||||
'DESCRICAO_CBO' : list[i]['descCBO'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.6;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveCBO(rows).then((value)async{
|
||||
print('finalizou saveCBO');
|
||||
await ApiDataLoad().loadProcedimentosCBO(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadProcedimentosCBO');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length !=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 7 de 11 - Gravando os Procedimentos CBO no Aplicativo";
|
||||
});
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Map<String, dynamic> row = {
|
||||
'COD_PROC_SIGTAP' : value[i]['codProcedimento'],
|
||||
'CODIGO_CBO' : value[i]['codCBO'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.7;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveProceduresCBO(rows).then((value)async{
|
||||
print('finalizou saveProceduresCBO');
|
||||
await ApiDataLoad().loadCIAP(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadCIAP');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length != 0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 8 de 11 - Gravando os CIAPs no Aplicativo";
|
||||
});
|
||||
for(int i=0;list.length > i;i++){
|
||||
Map<String, dynamic> row = {
|
||||
'CODIGO_CIAP' : list[i]['codCIAP'],
|
||||
'DESC_CIAP' : list[i]['descCIAP'],
|
||||
'TIPO_CIAP' : list[i]['tipoCIAP'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.8;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveCIAP(rows).then((value)async{
|
||||
print('finalizou saveCIAP');
|
||||
await ApiDataLoad().loadMunicipios(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadMunicipios');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length!=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 9 de 11 - Gravando os Municípios no Aplicativo";
|
||||
});
|
||||
for(int i=0;list.length > i;i++){
|
||||
Map<String, dynamic> row = {
|
||||
'ID_MUNICIPIO' : list[i]['idMunicipio'],
|
||||
'CODIGO_IBGE' : list[i]['codIBGE'],
|
||||
'NO_MUNICIPIO' : list[i]['nomeMunicipio'],
|
||||
'UF_ESTADO' : list[i]['UF'],
|
||||
'ID_PAIS' : list[i]['idPais'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.9;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveCity(rows).then((value)async{
|
||||
await ApiDataLoad().loadEquipes(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadEquipes');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length!=0){
|
||||
setState(() {
|
||||
messageSteps = "Etapa 10 de 11 - Gravando as Equipes no Aplicativo";
|
||||
});
|
||||
for(int i=0;list.length > i;i++){
|
||||
Map<String, dynamic> row = {
|
||||
'ID_EQUIPE' : list[i]['idEquipe'],
|
||||
'ID_UNIDADE' : list[i]['idUnidade'],
|
||||
'INE' : list[i]['INE'],
|
||||
'ID_ATB_AREA' : list[i]['idAtbArea'],
|
||||
'AREA' : list[i]['area'],
|
||||
'ID_ATB_MICROAREA': list[i]['idAtbMicroarea'],
|
||||
'MICROAREA' : list[i]['microarea'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.92;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveTeam(rows).then((value)async{
|
||||
countProg = 0.95;
|
||||
setState(() {});
|
||||
print('finalizou saveTeam');
|
||||
await ApiDataLoad().loadEquipeComponentes(urlAPI,mode,nameCityApi,user).then((value)async{
|
||||
print('loadEquipeComponentes');
|
||||
List list = value;
|
||||
List<Map<String, dynamic>> rows = [];
|
||||
if(list.length!=0) {
|
||||
setState(() {
|
||||
messageSteps ="Etapa 11 de 11 - Gravando os Profissionais das Equipes no Aplicativo";
|
||||
});
|
||||
for(int i=0;list.length > i;i++){
|
||||
Map<String, dynamic> row = {
|
||||
'ID_EQUIPE' : list[i]['idEquipe'],
|
||||
'ID_PROFISSIONAL' : list[i]['idProfissional'],
|
||||
'ATIVO' : list[i]['ativo'],
|
||||
};
|
||||
rows.add(row);
|
||||
countProg = 0.97;
|
||||
setState(() {});
|
||||
}
|
||||
await DbSqliteLoad().saveTeamComponents(rows).then((value)async{
|
||||
print('finalizou saveTeamComponents');
|
||||
setState(() {
|
||||
countProg = 1;
|
||||
finish = true;
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Profissionais Equipes não carregadas, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Equipes não carregadas, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Municípios não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'CIAPs não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Procedimentos CBOs não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'CBOs não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Procedimentos CIDs não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'CIDs não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Procedimentos Registros não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Procedimentos não carregados, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
}else{
|
||||
AlertDialogDefault().alert(context, 'Error', 'Unidades não carregada, tente novamente!', 'Voltar');
|
||||
AlertDialogDefault().alert(context, 'Error', 'Unidades não carregadas, tente novamente!', 'Voltar');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user