Skip to content

v6.58-beta - #661

Merged
marceloarocha merged 18 commits into
masterfrom
develop
Aug 29, 2026
Merged

v6.58-beta#661
marceloarocha merged 18 commits into
masterfrom
develop

Conversation

@marceloarocha

Copy link
Copy Markdown
Collaborator

No description provided.

claude and others added 18 commits August 27, 2026 09:23
Two features had little or no test coverage. Both are now exercised, using
the style that fits each one.

Regulation solicitation workflow (unit tests, 38 cases)

The whole regulation domain was untested: reg_solicitation_service was at
18%, reg_solicitation_attribute_service at 33% and reg_prioritization_service
at 42%. The regulation tables live in a separate DDL file that neither CI nor
`make test-setup` loads, so these are unit tests with a mocked db session and
patched repository calls. Real SQLAlchemy model instances are used as rows, so
column mapping and the services' attribute writes are exercised for real.

Covered: solicitation read with its movement history (including the synthetic
initial event and null-safe joins), stage movements with every side effect
(schedule/transport date parsing from the dd/mm/yyyy hh:mm mask, type and risk
updates, both undo actions), batch moves, manual creation of a solicitation
plus its admission record, the attribute soft delete, and the prioritization
queue (window-function count, age derivation). Two tests pin the
READ_REGULATION / WRITE_REGULATION gate.

Names proxy (integration tests, 43 cases)

routes/names.py was at 36% and name_service's public API was untested — only
the strategy classes had unit tests. These are integration tests: they
authenticate for real, go through the routes and read the real schema_config
row, with only the outbound boundary (aws / requests) patched, so no test
reaches DynamoDB or an external host.

Covered: the route-level search-term allow-list (accepting accents,
apostrophes and hyphens; rejecting the characters that would reach an upstream
URL), the degradation behaviour every patient list depends on (an unresolvable
lookup yields the "Paciente <id>" placeholder rather than an error page),
auth-token signing and verification, strategy selection from the tenant
configuration (DynamoDB, internal JWT, getname-proxy), HTML escaping of
externally supplied names, and batch-lookup chunking and ordering.

Resulting coverage: the three regulation services 100%, routes/names.py 100%,
name_service 57% -> 74%. Suite goes from 1788 to 1869 tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYV594ibCoXhT1GQhjZwxs
test: cover the regulation solicitation workflow and the names proxy
This reverts commit e4c9819.
Adds integration coverage for two features that had none.

GET /reports/prescription/history: the service and both repository
queries were untested. The new tests pin the three synthetic "custom"
events (origin creation, arrival, processing), the fact that they are
suppressed for aggregated prescriptions, that the arrival date ignores
Materiais items, that prescricao_audit rows written by an unknown user
still render, and the merged ordering by date. Service and repository
go from 31%/33% to 100%.

POST /drugs/unit-conversion/<drug> and POST /drugs/process-scores/<drug>:
the write half of the unit-conversion feature. The new tests cover the
save being applied to every segment, medatributos being created from the
substance reference when missing, the default measure unit being created
when the substance names one the schema does not have, the fallback to
"un", the upsert on re-save, the rejected payloads (empty list, zero
factor, non-numeric factor, unknown drug), the permission gate, and that
the save never reaches Lambda while process-scores sends the expected
payload. unit_conversion_service goes from 49% to 91%.

Both modules clean up after themselves: ids use the reserved >= 90000 /
>= 100000 ranges wiped by clean_test_artifacts, and the measure units
the save creates are removed by the module fixture.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012aounHgxMPaoZmScdtHU2z
The shared "Secret & sensitive data scan" check is red on develop: gitleaks
matches generic-api-key against the invented HS256 keys added with the names
proxy tests, blocking every PR that targets develop.

They are literals invented for that file, never a credential, so the fix is
the suppression the check asks for -- an inline gitleaks:allow on each,
with a comment saying why. Verified with gitleaks 8.30.1 (the version CI
pins): one finding on origin/develop before, none after.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012aounHgxMPaoZmScdtHU2z
test: cover prescription history report and unit conversion save
Adds coverage for two features that had none. Tests only, no production
code changes.

1. GET /reports/drug-attributes/history (and the legacy
   /reports/antimicrobial/history alias): the attribute allowlist that
   guards the interpolated column name, the mapping of each key to its
   column, the widening to the patient's previous admissions, and the
   400/401 paths.

2. The support knowledge-base search: unit tests for
   services/vector_search_service.search with both AWS boundaries mocked,
   and integration tests for POST /support/related-articles covering the
   config it hands to the search and how vector hits fold into articles.

Coverage: reports_drug_attributes_service 33% -> 100%,
vector_search_service 58% -> 100%, support_service 64% -> 73%.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EJss7x7K8zLo826yX6T5BR
The custom report list already exposes inactive reports to anyone holding
READ_CUSTOM_REPORTS (ADMIN and CURATOR), but _validate_report only let
WRITE_CUSTOM_REPORTS — which only ADMIN holds — past the "report is not
active" check. A curator therefore saw an inactive report listed and got a
400 when opening or processing it.

Accept READ_CUSTOM_REPORTS for the active check as well, so listing and
opening agree. The reports_config "ignore CUSTOM" check still applies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SDgKP7zcPKfozqqW38Nhs8
READ_CUSTOM_REPORTS now also opens inactive custom reports, so assert that
only ADMIN and CURATOR hold it and that the ordinary READ_REPORTS roles do
not. A future role edit that grants the permission fails these tests instead
of silently widening access.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SDgKP7zcPKfozqqW38Nhs8

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The changes in this PR introduce a well-designed onlyLatestExpireDate feature for protocols and enhance the TRAINING role permissions. The implementation correctly restricts protocol alerts to drugs prescribed on the current prescription date when enabled, includes comprehensive test coverage, and maintains backward compatibility with existing configs. The code follows established patterns and includes clear documentation. No critical issues were found that would block merge.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@marceloarocha
marceloarocha merged commit 72d4bdb into master Aug 29, 2026
14 checks passed
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