You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(api): add prescription REST API endpoints with tests (openemr#10837)
Fixesopenemr#10833
Related to openemr#10834
#### Short description of what this resolves:
Add REST API endpoints for prescriptions:
- `POST /api/prescription` - Create a new prescription
- `GET /api/prescription` - List all prescriptions
- `GET /api/prescription/:uuid` - Get a single prescription by UUID
- `DELETE /api/prescription/:id` - Soft-delete (sets `active = 0`)
The GET endpoints migrate from the deprecated `handleProcessingResult`
(array return) to `createProcessingResultResponse` (PSR-7
`ResponseInterface`), fixing HTTP status codes that were previously
ignored by the Symfony kernel's `ViewRendererListener`.
The `getOne` service method bypasses `FhirSearchWhereClauseBuilder` and
filters by UUID directly, since `_id` is not a valid column in the UNION
subquery used by `PrescriptionService`.
The DELETE endpoint uses soft delete to preserve medical records for
audit compliance, consistent with the `prescriptions` table's existing
`active` column.
Also fixes MySQL strict mode error in `interface/eRx_xml.php` by
removing `enddate = ''` comparisons that fail when comparing DATETIME to
empty string.
#### Tests:
- `testPost` - Create prescription via API
- `testGetOne` - Retrieve single prescription by UUID
- `testGetOneNotFound` - Verify 400 for invalid UUID
- `testGetAll` - List all prescriptions, verify created records appear
- `testRoundTrip` - Create → Read → Delete → Verify status=stopped
- `testDelete` - Soft-delete and verify response
- `testDeleteNonExistent` - Delete non-existent ID returns 200
#### Additional changes:
- Updates `SystemLoggerAwareTrait::setSystemLogger()` to accept PSR-3
`LoggerInterface` in addition to `SystemLogger`, enabling use of
`NullLogger` in tests
- Updates `FhirConditionService` and `FhirOrganizationService` method
signatures to match
- Uses `NullLogger` in `ApiTestClient` to suppress logging noise during
tests
---
**Original contribution by @IvanJov** from PR openemr#6106. This PR rebases and
fixes that work to use soft deletes, adds GET endpoints and
comprehensive API tests, and addresses baseline issues.
Co-authored-by: Ivan Googla <ivan.jo.dev@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
'message' => '#^Method OpenEMR\\\\Tests\\\\Fixtures\\\\FixtureManager\\:\\:getNextPid\\(\\) has invalid return type OpenEMR\\\\Tests\\\\Fixtures\\\\the\\.$#',
'message' => '#^Method OpenEMR\\\\Tests\\\\Fixtures\\\\FixtureManager\\:\\:getSingleEntry\\(\\) has invalid return type OpenEMR\\\\Tests\\\\Fixtures\\\\random\\.$#',
'message' => '#^Method OpenEMR\\\\Tests\\\\Fixtures\\\\FixtureManager\\:\\:getSinglePatientFixture\\(\\) has invalid return type OpenEMR\\\\Tests\\\\Fixtures\\\\a\\.$#',
'message' => '#^Method OpenEMR\\\\Tests\\\\Fixtures\\\\FixtureManager\\:\\:getUnregisteredUuid\\(\\) has invalid return type OpenEMR\\\\Tests\\\\Fixtures\\\\uuid4\\.$#',
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'OpenEMR\\\\\\\\Validators\\\\\\\\BaseValidator\' and OpenEMR\\\\Tests\\\\Isolated\\\\Validators\\\\CoverageValidatorStub will always evaluate to true\\.$#',
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'OpenEMR\\\\\\\\Validators\\\\\\\\ProcessingResult\' and true will always evaluate to false\\.$#',
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNull\\(\\) with OpenEMR\\\\FHIR\\\\R4\\\\FHIRElement\\\\FHIRReference and \'Problems/health…\' will always evaluate to false\\.$#',
'message' => '#^Method OpenEMR\\\\RestControllers\\\\PrescriptionRestController\\:\\:getAll\\(\\) has parameter \\$search with no type specified\\.$#',
0 commit comments