Registry submission
Submission is separate from approval. Approval never starts a submission. Submission stays disabled without explicit configuration.
| Term | Meaning |
|---|---|
| Draft | The record of one note in the monorepo. Only an approved draft can go to submission. |
| Submission | The write of one approved draft to the external registry form. |
| Job | One queue item in pg-boss. It holds one submission. |
| MicroVM | A disposable Tenki virtual machine. It runs Playwright for one job. |
| Control map | The versioned map from record fields to the controls of the registry form. |
idpac |
The patient identifier that the registry assigns when it saves crdA. |
| Read-back | A check that reads the registry after the write. |
Submission path
Section titled “Submission path”Figure 1 shows the path of one submission, from the endpoint to the stored outcome.
Preconditions
Section titled “Preconditions”POST /api/biobadamex/drafts/:id/submit requires all of these conditions:
- a session
- research access
- ownership of the draft
- the
approvedstate - resolved required fields
BIOBADAMEX_REGISTRY_SUBMIT_ENABLED=1- comorbidity confirmation, when the draft needs it
- a valid payload with a map version
An admin can read the draft of another clinician for audit. An admin cannot submit that draft. A draft without an owner cannot go to submission.
The API puts a job in the queue. The job holds the draft id, the approved record and the map version. The registry submission uses a batch size of one per worker. It has no specific retry policy. Several app instances need extra coordination to guarantee one global external session.
Sandbox
Section titled “Sandbox”For each job, the service does these steps. The numbers in Figure 2 are the numbers in this list.
- The service validates the configuration.
- The service loads the worker bundle.
- The service creates a disposable Tenki microVM.
- The service gives the payload and the credentials to the microVM through the process environment.
- The microVM runs Playwright. Playwright does the external flow below.
- The service parses the structured JSON result.
- The service disposes the microVM.
External flow
Section titled “External flow”Playwright does these steps in the registry form. The numbers in Figure 3 are the numbers in this list.
- Log in.
- Fill and save
crdA. - Read the assigned
idpac. - Visit and save
crdB,crdC,crdDandcrdE. - Open the summary.
- Require the text of the same
idpac.
The idpac check and the summary check are fatal. Many single fields are best effort. Playwright logs and skips a missing control or an option that does not match. The result succeeded confirms the patient and the summary. It does not confirm parity field by field.
External map
Section titled “External map”The control map has a version. A selector change requires a new REGISTRY_MAP_VERSION and a new validation. The map has these known gaps:
- controls that the map does not model
- radio ambiguities (radios not confirmed with different values)
- BASDAI ambiguity
- biologic brands that wait for validation
- detail and date fields that the map does not cover
Do not describe the map as total coverage of the form.
Biologic treatments
Section titled “Biologic treatments”crdE accepts episodes with a role. Only the role previous goes into the prior treatments block. The worker rejects these cases:
- an unknown role with an identified drug
- a conflict between the brand and the substance
- duplicate episodes that would overwrite the same control (and its dates)
- drugs without a confirmed mapping
Outcomes
Section titled “Outcomes”- Success. The handler persists
idpac,submittedAt, thesubmittedstate and an audit entry. - Form rejection. The handler persists
submitErrorand writes an audit entry. It does not repeat the same submission. - Infrastructure failure. The service throws an error. The queue has no specific retry policy for registry submission.
- The current read-back confirms the summary. It does not confirm each field.
- Bounded read contracts exist. The submit flow of this commit does not mount them.
Idempotency and state risks
Section titled “Idempotency and state risks”- The endpoint drops the job id. It uses no singleton per draft. Two requests before the first outcome can put two external writes in the queue.
crdAcan assign anidpac, and then a later page can fail. The failed result can hold theidpacin memory, but the handler persists onlysubmitError. A retry can create the patient identity again.- The handler does not persist
summaryUrl. - An infrastructure failure before a structured result leaves the draft
approvedwithoutsubmitError. The UI has no durablequeued/runningstate.