Skip to content
Recipes

CSV roster to FHIR

Pick up a CSV patient roster from an SFTP folder and create a FHIR Patient for each row, without duplicates when the roster is sent again.

On this page

Health plans, employers and partner organizations often share patient or member lists as CSV files on an SFTP server, refreshed daily or weekly. This recipe picks up each new file, runs the workflow once per row, and creates a FHIR Patient for each row unless the server already has one with that identifier. Then it moves the file to a processed folder.

Source and destination

The engine polls the SFTP folder itself. Each CSV row becomes one run, and each run sends one conditional create to the FHIR server.

flowchart LR
    A[SFTP folder] -->|roster.csv| B[SFTP pickup trigger]
    B -->|one run per row| C[Data map]
    C -->|Patient, If-None-Exist| D[FHIR R4 server]
  • Source: a CSV file with a header row in an SFTP folder.
  • Destination: any FHIR R4 server a FHIR REST profile can reach.
  • Result: one Patient per row. A row whose identifier the server already holds creates nothing new.

What it uses

The trigger picks up roster-*.csv once a minute, runs once per row, and moves each file when its rows are recorded:

json
{
  "type": "sftp",
  "sftpProfileId": "partner-sftp",
  "remotePath": "/incoming",
  "pollInterval": 60000,
  "filenamePattern": "roster-*.csv",
  "afterProcessing": "move",
  "processedPath": "/incoming/processed",
  "errorPath": "/incoming/errors",
  "batch": { "mode": "rows", "csv": { "header": true, "trim": true } }
}

Each run's input carries the row under row, keyed by the header names. For a roster with the columns mrn, first_name, last_name, dob and gender, the Data Map is:

SourceTarget path
$.row.mrnidentifier[0].value
$.row.first_namename[0].given[0]
$.row.last_namename[0].family
$.row.dobbirthDate
$.row.gendergender

Add a date-format op on birthDate if the roster writes dates as MM/DD/YYYY, and a lookupValues table on gender if it uses codes such as M and F. The send step's config names the resource type and turns on the duplicate check:

json
{ "resourceType": "Patient", "ifNoneExist": "identifier" }

With ifNoneExist set to identifier, the create sends the Patient's first identifier as an If-None-Exist header, so a roster sent again does not create a second Patient. See FHIR REST for conditional create.

A test file needs only synthetic rows:

text
mrn,first_name,last_name,dob,gender
TP-0001,Alex,TESTPATIENT,1980-04-12,female
TP-0002,Sam,TESTPATIENT,1975-09-30,male

Status

Available on this release for Patient. Coverage is not part of this recipe.

A file that does not parse, or has more rows than maxRows, runs nothing and moves to errorPath. Pickup is at least once, which is why the create is conditional. See Duplicates and crashes.

Reference