Proposal: A Data Importer for Migrations (CSV → OpenEMR)

There’s no built-in way to import patient data into OpenEMR, so migrations rely on custom SQL files, usually written by a vendor.

Every migration has to reinvent the wheel: generating pid/pubpid/UUIDs, filling the linked tables, and translating sex/race/ethnicity/language codes to list_options. Because the SQL bypasses OpenEMR’s own code, it also skips validation, duplicate checks and the audit log, and the scripts break when the schema changes.

This keeps coming up here: at least 15 threads since 2012 ask how to import patients from CSV or Excel. The usual answer is to load patient_data with phpMyAdmin and then run sql_upgrade.php to fill in the missing UUIDs.

Core already imports C-CDA and FHIR documents, code sets, fee schedules, the lab compendium and holidays, but nothing imports tabular patient, insurance or appointment data. I couldn’t find a maintained open-source tool that does it either.

I’d like to propose a shared importer that does that work once, properly.

Version 1 scope

  • CSV only, imported with a console command: bin/console openemr:import patient file.csv --profile=legacy.yaml --dry-run
  • Insurance companies, patients and patient policies
  • Writes through PatientService / InsuranceService, not raw SQL, so UUIDs, validation, events and audit logging work as normal
  • Reusable YAML mapping profiles (column mapping and code translation), shareable per legacy system
  • Dry run that reports every bad row and changes nothing
  • Re-runnable without duplicates (old system IDs are tracked), and each run can be undone

Not in v1: past encounters, notes, claims/billing, and a web screen.

Security: no shell commands and no raw SQL. If a web screen comes later, it would be a module that is off by default, with its own permission, required dry runs and strict upload handling. The full design note compares this with the recently removed backup.php.

Questions for the community

  1. What do you import today, and from which systems?
  2. Do migration consultants already have tools this should work with or replace?
  3. Write through the services directly, or through FHIR resources?
  4. Core console command, or a module from the start?
  5. Who would help maintain it and its tests?

David

1 Like

We have both C-CDA and FHIR importing. Most used currently is CCDA and can batch import up to 100 docs at a time. Most EHRs support CCDA export

1 Like

Thanks Jerry, good point. C-CDA should be the main path for clinical data, and I don’t want to duplicate it. Looking at the C-CDA import code, the gaps I see are mostly administrative:

  • Insurance details: the C-CDA payer section has no policy number, group or subscriber, so policies come in without them.
  • Past & Future appointments: not in a C-CDA at all, and usually the first thing a practice needs on go-live day.
  • Old chart numbers, assigned provider, and data from systems that can’t export C-CDA (billing and practice-management systems, spreadsheets, non-certified systems).

So I’d scope this to complement C-CDA: patients’ administrative data, insurance policies and appointments from CSV, matched to patients the C-CDA import already created. Does that match the gaps you see? And is there anything in the C-CDA import’s patient matching or batch handling the CSV side should reuse rather than rebuild?