Skip to content

Intake and extraction

This page describes how a note enters the system, how the system protects it and how the system turns it into a draft.

Term Meaning
Intake The entry of a note into the system.
Original The bytes of the file that the clinician uploaded.
Inventory The list of stored files of one clinician.
De-identification The step that removes identifiers from the note before the model call.
Dead letter The destination of a job that used all its attempts.
Input Persistence of the original Extraction timing
Pasted text in the console It makes no original-file row. Immediate. The API queues the note when it receives it.
PDF, Word or text file in the console Encrypted original in R2 and a metadata row. On demand, from the inventory.
Service-key batch One encrypted original for each note. Storage only. The clinician extracts later.
RheumAI “submit for review” It makes no upload row. The server extracts again and makes a held draft.
Dedicated clinician agent It uses only the uploads of the configured clinician. On demand, with an agent key.
WhatsApp study-channel document Encrypted original in R2. Immediate, when the channel, the consent and the clinician are configured.

The batch response proves storage, not extraction. Each note returns its own result. One invalid note does not stop the other notes in the batch.

A file goes through these steps. The numbers in Figure 1 are the numbers in this list.

Sequence of one file between the console, the API, R2 and PostgreSQL: validate, extract text, encrypt, store and extract on demandReactConsoleapps/apiAPIobjectsR2DBPostgreSQLThe clinician uploads a file1 · upload the file1 · validate the file2 · extract the text3 · encrypt with AES-256-GCM4 · ciphertext4 · metadata5 · state and derived name6 · request extraction6 · check the scope6 · get the original
Figure 1. File intake. Time goes down. Solid arrows are calls or writes. The dashed arrow is a reply.
  1. Validate. The API validates the format, the filename and the size. The API does this before it decodes the full file.
  2. Extract the text. The API extracts the text locally. For PDF it uses unpdf. For Word it uses the document parser. Plain text is decoded directly.
  3. Encrypt. The API encrypts the original bytes with AES-256-GCM.
  4. Store. The API stores the ciphertext in R2. The API stores the metadata in PostgreSQL.
  5. Show in the inventory. The inventory shows the state and a derived name. The inventory does not show the note body.
  6. Request the extraction. The API checks the scope before it gets or decrypts the file.

The current limit for the original file is 20 MiB. The API cleans filenames. Thus a filename cannot contain control characters or path separators.

The extraction worker does these steps. The numbers in Figure 2 are the numbers in this list.

Sequence of one extraction job between pg-boss, the worker, the model and PostgreSQLqueuepg-bossapps/apiWorkerregistro-extractionModelDBPostgreSQLpg-boss gives a job1 · extraction job1 · get the note text2 · de-identify3 · call the model3 · JSON reply4 · parse the JSON5 · nulls to unknown6 · validate the schema7 · calculate DAS-288 · missing fields by disease9 · review_pending draft
Figure 2. Extraction job. Time goes down. Solid arrows are calls or writes. The dashed arrow is a reply.
  1. Get the text. The worker gets the note text.
  2. De-identify. The worker applies best-effort de-identification.
  3. Call the model. The worker calls the configured registro-extraction model.
  4. Parse. The worker parses the JSON reply.
  5. Convert the nulls. The worker changes each null value to unknown.
  6. Validate. The worker validates the record against the schema.
  7. Calculate DAS-28. The worker calculates DAS-28.
  8. Calculate the missing fields. The worker calculates the missing fields for the disease.
  9. Make the draft. The worker makes a review_pending draft with the encrypted source and the attribution.
  • The model does not set the tri-state semantics.
  • The system keeps a real zero as zero.
  • false means only an explicit negation. The exception is the comorbidities that the clinician confirms at submission.
  • The system compares the reported DAS-28. The system calculates the authoritative value from the components when possible.
  • A biologic episode keeps the role, the drug, the dates and the stop reason separate.
  • A requested biologic episode with no date of its own can use the request date or the note date. Current and previous episodes do not use this rule.

De-identification removes generic identifiers. It also removes patient-name tokens when it finds them. De-identification is not a compliance guarantee. An unlabelled name can stay in the note. Clinical dates, sex, the center and the clinician can stay because they are part of the record.

The clinical extraction job payload can contain plaintext note text in PostgreSQL. The study path encrypts its note before the queue. The clinical path does not have that protection yet.

  • Extraction permits five attempts with backoff.
  • After the last attempt, a dead letter makes a failure that the app shows. The dead letter does not store the note text.
  • The clinician can extract a failed or rejected note again.
  • A pending or approved draft prevents a duplicate extraction.
  • A failure between the R2 write and the metadata insert can leave an orphan encrypted object.
  • A queue failure after the upload is stored gives a partial success. The source exists, but no job exists.
  • The system can make the draft and then fail at the audit step. Then a retry can make a second draft. The insert has no idempotency key for each attempt.
  • A pasted note that goes to the dead letter has no recoverable original in the inventory.
  • Source completion fills only unknown scalar fields. It does not merge episode arrays. It has no clinician UI.