Skip to content

Conversation

@alebmorais
Copy link
Owner

No description provided.

alebmorais and others added 17 commits October 2, 2025 13:42
Organized sections and added more file patterns to ignore.
Implementa cliente desktop para Windows com interface de automação médica, reconhecimento de voz e navegação por categorias.
Implement Medical Automation Server with SQLite and HTTP API
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: alebmorais <196795598+alebmorais@users.noreply.github.com>
@alebmorais alebmorais merged commit 9085d4f into SelfPace Oct 4, 2025
5 checks passed
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @alebmorais, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant enhancements to the medical automation system, primarily by modernizing the Windows desktop client's user interface through pywebview integration and implementing a resilient offline mode. It also refines the backend server's database handling and user interface, and substantially expands the medical phrase library with new, detailed protocols for various neurological conditions. These changes aim to improve the system's usability, reliability, and clinical utility.

Highlights

  • Modernized Windows Client UI: The Windows desktop client (ClienteWindows) has been significantly updated to support a modern web-based user interface using pywebview. This allows the client to display the web interface hosted on the Raspberry Pi directly within the application.
  • Robust Offline/Fallback Mechanism: A comprehensive fallback system has been implemented in the Windows client. If pywebview is not available or the Raspberry Pi server is unreachable, the client will display a simple Tkinter-based offline screen with instructions and a retry option, ensuring usability even without a connection.
  • Enhanced Medical Phrase Database: The SQL_2 database script has been expanded with numerous new medical phrases, particularly focusing on detailed protocols for Ischemic Stroke (AVCi), Hemorrhagic Stroke (AVCh), Cerebral Venous Thrombosis (TVC), and various other neurological conditions like Meningitis, NMO, Multiple Sclerosis, and Myasthenia Gravis.
  • Improved Server Functionality and UI: A new server implementation (ServidorCode2) has been introduced, featuring more robust database path resolution and a new, interactive HTML interface for managing medical phrases. The server startup messages have also been clarified for better user guidance.
  • New .gitignore and Removed SQL_json.json: A .gitignore file has been added to manage version control exclusions, and the SQL_json.json file has been removed, indicating a shift in how database structures or data might be managed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement by integrating pywebview to render the web UI directly in the Windows client, with a fallback to the legacy Tkinter UI. The server code is also refactored for better robustness, including automatic database discovery and creation. The documentation and .gitignore have been updated accordingly.

My review has identified a critical syntax error in the new ClienteWindows2.py file that will prevent it from running. Additionally, there are some data consistency and style issues in the SQL_2 file that should be addressed to ensure predictable behavior and maintainability. Overall, these are great changes that modernize the application.

Comment on lines +922 to +924
except Exception as e:
except Exception as e:
print(f"Erro inesperado ao iniciar cliente: {type(e).__name__} - {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This file has a duplicated except Exception as e: clause, which is a Python syntax error and will cause the script to fail at startup. Please remove the redundant line and fix the block.

Suggested change
except Exception as e:
except Exception as e:
print(f"Erro inesperado ao iniciar cliente: {type(e).__name__} - {e}")
except Exception as e:
print(f"Erro inesperado ao iniciar cliente: {type(e).__name__} - {e}")

('Questionário cefaleia', 'Por favor responder os seguintes questionamentos:\n\n- quando iniciou a cefaleia?\n- no inicio da dor, em quanto tempo ela atingiu o pico maximo?\n- se caracteriza por ser latejante? em aperto? choque? facada?\n- a dor de cabeça é inedita? mudou o padrão?\n- tem irradiação?\n- qual intensidade de 0 a 10?\n- tem fatores desencadeantes?\n- piora com luz?barulho? aos esforços?\n- tem nausea ou vomito associado?\n- tem sintomas visais ou dormencias asociados?\n- teve febre ou outro sintoma sistemico?\n- sofreu tce recente?\n- tem comorbidades?\n-tem história de cefaleia prévia?', 'Atendimento Gerais', 'Cefaleia', 3),
('Exame neurológico', 'Como é o exame neurológico básico?\n- glasgow\n- alteração de linguagem?\n- confusão mental?\n- pupilas?\n- desvio ocular ou estrabismo novo?\n- nistagmo?\n- desvio de rima labial?\n- assimetria de força em algum lado do corpo? Se sim qual e em qual grau?\n-Sensibilidade para dor e toque?\n-Sensibilidade profunda? (posicional, palestésica)\n-reflexos?\n-Romberg?\n- ataxia?\n-está deambulando, mesmo que com ajuda ? Como é a marcha?\n- sinais de irritação meníngea?', 'Atendimento Gerais', 'Cefaleia', 4),
('Exame imagem', 'Por favor, paciente já realizou exame de imagem? Se sim, qual resultado?', 'Atendimento Gerais', 'Cefaleia', 5),
('Sinais de alarme', 'Sintomas sistêmicos, incluindo febre\nHistória de Neoplasia \nDéficit ou disfunção neurológica (incluindo diminuição da consciência)\nO início da dor de cabeça é repentino ou abrupto\nIdade avançada (após 50 anos)\nMudança de padrão ou início recente de dor de cabeça\nDor de cabeça posicional\nPrecipitado por espirros, tosse ou exercício\nPapiledema\nCefaleia progressiva e apresentações atípicas\nGravidez ou puerpério\nDor ocular com características autônomicas\nInício pós-traumático da dor de cabeça\nPatologia do sistema imunológico, como HIV\nUso excessivo de analgésico ou novo medicamento no início da dor de cabeça', 'Atendimentos Gerais', 'Cefaleia', 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a couple of data consistency issues with this new entry:

  1. The category is specified as 'Atendimentos Gerais' (plural), while other entries for the same theme use 'Atendimento Gerais' (singular). This will result in a new, separate category being created, which is likely not the intention. Please change it to 'Atendimento Gerais'.
  2. The ordem is set to 1, which conflicts with the existing 'Analgesia feita' entry in the same subcategory ('Cefaleia'). Having duplicate ordem values can lead to non-deterministic ordering of items in the UI. Please assign a unique ordem value for this new entry within its subcategory (e.g., 6).

('TeleAVC dados projeto', 'Por gentileza, essas informações são importantes para a coleta de dados do projeto. Quando possível, após a tomada de conduta de emergência, compartilhar, pode ser escrito, por áudio ou ligação:\n-Número do CPF ou RG do paciente:\n-Origem do paciente (demanda espontânea, SAMU, UPA…):\n-Nome do contato de emergência/familiar responsável:\n-Telefone do contato de emergência/familiar responsável:\n-O paciente ou responsável legal consentiu no compartilhamento de seus dados pessoais e telefone para contato em 90 dias após esse atendimento, pela equipe do Projeto TeleAVC?\n-Data e horário da chegada do paciente no hospital satélite:\n-Data e horário do início do atendimento médico no hospital satélite:\n-Desfecho do caso (por exemplo, horário do bolus do trombolítico, se indicado)', 'Atendimentos TeleAVC', 'Atendimento Inicial', 2),
('TeleAVC validação final', 'Pessoal, abaixo deixo alguns dados que, como mencionei com vocês, serão importantes para validação do atendimento e projeto, quando possível, me envie por gentileza.Pode ser escrito, por áudio ou ligação: Obrigada e estou a disposição!\n-Número do CPF ou RG do paciente:\n-Origem do paciente (demanda espontânea, SAMU, UPA…):\n-Nome do contato de emergência/familiar responsável:\n-Telefone do contato de emergência/familiar responsável:\n-O paciente ou responsável legal consentiu no compartilhamento de seus dados pessoais e telefone para contato em 90 dias após esse atendimento, pela equipe do Projeto TeleAVC?\n-Data e horário da chegada do paciente no hospital satélite:\n-Data e horário do início do atendimento médico no hospital satélite:\n-Desfecho do caso: Internação e manejo de AVCi conservador', 'Atendimentos TeleAVC', 'Atendimento Inicial', 3);

INSERT INTO frases (nome, conteudo, categoria_principal, subcategoria, ordem) VALUES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the existing data and for minor performance benefits, it's better to use a single INSERT statement with multiple value tuples, rather than multiple INSERT statements. The inserts at the top of the file follow this pattern. Please consider grouping the new VALUES clauses from this and subsequent INSERT statements (e.g., on lines 97 and 113) into a single one.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +299 to +303
return response.status_code < 500
with urllib_request.urlopen(self.pi_url, timeout=timeout) as response:
return 200 <= getattr(response, "status", 200) < 500
except (requests.exceptions.RequestException, urllib_request.URLError):
return False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard optional requests module in exception tuple

is_pi_reachable is designed to work even when the requests package is missing, but the except clause still references requests.exceptions.RequestException. On systems without the dependency, requests is set to None and importing the module raises AttributeError while building the exception tuple, preventing the client from starting at all. The handler should only mention requests.exceptions when the library is available or catch a broader exception when using urllib.

Useful? React with 👍 / 👎.

Comment on lines +319 to +323
response = requests.get(self.pi_url, timeout=timeout)
return response.status_code < 500
with urllib_request.urlopen(self.pi_url, timeout=timeout) as response:
return 200 <= getattr(response, "status", 200) < 500
except (requests.exceptions.RequestException, urllib_request.URLError):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid referencing missing requests dependency in fallback client

ClienteWindows2 repeats the same pattern: the except (requests.exceptions.RequestException, ...) clause is evaluated even when REQUESTS_AVAILABLE is false and requests is set to None, causing an immediate crash with AttributeError instead of falling back to the urllib branch. Guard the reference or build the exception tuple dynamically so that the script runs without the optional dependency.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants