Skip to content

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.

Figure 1 shows the path of one submission, from the endpoint to the stored outcome.

Submission path: the endpoint checks preconditions, the queue holds the job, the service runs Playwright in a microVM, the outcome handler stores the resultApproval never submits./drafts/:id/submitSubmit endpointchecks preconditionspg-bossQueuebatch size oneapps/apiTenki servicevalidates, loads bundleTenki microVMworker bundlePlaywrightdisposablecrdA–crdERegistryexternal formfatal: idpac, summarybiobadamex-jobs.tsOutcome handlerPostgresDraftidpac or submitErrorpersist the outcome
Figure 1. Submission path. Solid arrows are calls or writes. The dashed arrow is the reply. The dotted frame is the disposable microVM.

POST /api/biobadamex/drafts/:id/submit requires all of these conditions:

  • a session
  • research access
  • ownership of the draft
  • the approved state
  • 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.

For each job, the service does these steps. The numbers in Figure 2 are the numbers in this list.

Sandbox sequence across the service, the Tenki microVM and the registryapps/apiServiceTenkiMicroVMcrdA–crdERegistryThe worker takes one job1 · validate the configuration2 · load the worker bundle3 · create the microVM4 · payload + credentials (process env)5 · run Playwright (Figure 3)6 · structured JSON result7 · dispose the microVM
Figure 2. Sandbox sequence. Time goes down. The dashed arrow is the reply. Figure 3 shows step 5 in detail.
  1. The service validates the configuration.
  2. The service loads the worker bundle.
  3. The service creates a disposable Tenki microVM.
  4. The service gives the payload and the credentials to the microVM through the process environment.
  5. The microVM runs Playwright. Playwright does the external flow below.
  6. The service parses the structured JSON result.
  7. The service disposes the microVM.

Playwright does these steps in the registry form. The numbers in Figure 3 are the numbers in this list.

External flow across Playwright and the registry form pages crdA to crdEmicroVMPlaywrightcrdA–crdERegistryThe microVM runs Playwright1 · log in2 · fill and save crdA3 · assigned idpac4 · visit and save crdB, crdC, crdD, crdE5 · open the summary6 · summary text6 · require the same idpac (fatal)
Figure 3. External flow. Time goes down. Dashed arrows are replies from the registry. Step 6 is a fatal check.
  1. Log in.
  2. Fill and save crdA.
  3. Read the assigned idpac.
  4. Visit and save crdB, crdC, crdD and crdE.
  5. Open the summary.
  6. 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.

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.

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
  • Success. The handler persists idpac, submittedAt, the submitted state and an audit entry.
  • Form rejection. The handler persists submitError and 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.
  • 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.
  • crdA can assign an idpac, and then a later page can fail. The failed result can hold the idpac in memory, but the handler persists only submitError. A retry can create the patient identity again.
  • The handler does not persist summaryUrl.
  • An infrastructure failure before a structured result leaves the draft approved without submitError. The UI has no durable queued/running state.