Import a test catalog from CSV

Import a test catalog from CSV

doc-verified + verified-v3.3.0

Load a whole test catalog from CSV files, see exactly what they would do before anything is written, and settle any names the system does not recognise.

Purpose

Load or update the test catalog from CSV files instead of editing tests one at a time.

You'll end up with

Your lab units, specimens, tests, result components, panels, reference ranges, terminology codes, storage rules and reflex rules in the catalog, with the files saved alongside the configuration so the next restart loads exactly what you applied.

Who does this

An administrator or implementer setting up or updating a site. Access is set by user permissions and can be configured by your administrator.

Before you start

Your CSV files, each named after the catalog area it belongs to (tests-mysite.csv, result-components-mysite.csv), saved as UTF-8 without a byte order mark.

Where

Admin > Test Catalogue Management > Import Catalog (CSV)

Overview

The catalog has always been loadable from CSV files placed on the server, which meant a system administrator and a restart for every change. This page does the same job from the browser, in two steps. Preview runs every row of your files against the catalog as it stands and then throws the result away, so the plan you read is what would really happen rather than an estimate. Apply loads the files for real and saves them with the configuration.

Names your files use that the catalog does not recognise, such as a lab unit spelled differently from the one already configured, are not lost in a log file. They collect in a Needs your decision list on the same page, where you point each one at the right record or skip it.

Step 1. Open the import page

From the main menu choose Admin, then Test Catalogue Management, then Import Catalog (CSV).

catalogue 3.0.png
Import Catalog (CSV)

The page opens with an empty file area and, below it, the decision list. On a clean system the list reads "Nothing is waiting for a decision."

Import Catalog (CSV) page with an empty Add CSV files area, disabled Preview and Apply buttons, and an empty Needs your decision list
The import page before any files are added. Preview and Apply stay disabled until at least one file is present.

Step 2. Add your CSV files

Select Add CSV files and choose one or more files. Each file appears in the table with the catalog area it was recognised as.

The area is read from the start of the file name. A file called tests-cphl.csv is recognised as tests; one called cphl-tests.csv is not recognised at all and is refused. If a file is recognised as the wrong area, or not at all, set it yourself in the Catalog area list on that row. Remove takes a file back out.

Add every file the load depends on in the same batch. The areas are loaded in dependency order once you apply, so lab units and specimens go in before the tests that use them, and tests before the components, ranges, terminology, storage rules and reflex rules that hang off them.

Two files added, test-sections-cphl.csv and sample-types-cphl.csv, each with its catalog area, with Apply disabled and a line under the buttons asking you to preview the files first
Two files added, each showing the catalog area read from its name. Apply stays disabled, and the line under the buttons says what it is waiting for.

Step 3. Preview

Select Preview. Under What these files would do, each file gets a row counting what would be created, updated and skipped. Nothing has been written at this point.

Apply opens only after a preview. Until then the page says so under the buttons: "Preview the files first. Apply opens once the preview shows no file errors." A file that cannot be read, for example one missing a required column, is reported in the preview and keeps Apply closed. Fix the file, add it again and preview again.

What these files would do table listing two files with created, updated and skipped counts and no skipped rows
A preview of two files, with no skipped rows.

 

Step 4. Read the skipped rows

A skipped row is listed under the table with its file, its line number and the reason, so you can find it in the file and fix it.

Preview of tests-cphl-parasitology.csv with one skipped row, and below the table the file, line 2 and the reason that test section Parasitology Unit was not found
One row skipped, naming the file, the line and the reason.

 

A skip in a preview is not always a problem. Rows are judged one at a time against the catalog as it stands now, so a test whose lab unit is created by another file in the same batch is reported as skipped until you apply. Reasons that are problems, and that will not fix themselves, include a value longer than the column allows and a name that appears in the decision list below.

Step 5. Settle anything that needs your decision

Each unrecognised name appears once, with where it came from, however many rows used it. Choose the record it means from Use this record and select Use, or select Skip to leave it alone. Ticking Remember this name before you use it records the spelling, so later imports resolve it by themselves.

Needs your decision list with one unrecognised lab unit, Haematology Unit, from tests-cphl-haematology.csv line 2 (test Full Blood Count), with a Use this record list, Remember this name, and Use and Skip buttons
A lab unit the catalog does not know, waiting for a decision. Use this record lists the lab units it can be pointed at.

Preview populates this list as well as Apply, so a preview against a shared system can leave items behind for whoever looks next. Clear what you put there.

Step 6. Apply

Select Apply to load the files for real. The files are saved into the configuration tree as well, so the next restart loads exactly what you applied.

The page then shows What was loaded: one row per file, counting what was created, updated and skipped. Two files for the same catalog area keep their own rows and their own counts. Any skipped rows are listed under the table with the file, the line number and the reason, as in the preview.

What was loaded table with test-sections-cphl.csv created 1 updated 5 skipped 0 and sample-types-cphl.csv created 2 updated 4 skipped 0
What was loaded after applying two files, each with its own created, updated and skipped counts.

Names still waiting for a decision do not stop Apply. The rows that depend on them are skipped, and the names stay in the list for you to settle and apply again.

If the server cannot save the files, a red notification names the file, the directory and the reason. The preview stays on screen and What was loaded does not appear, so a failed save is never shown as a finished one.

Which catalog areas can be imported

Catalog area

What it holds

Catalog area

What it holds

test-sections

Lab units, the departments tests are grouped under.

sample-types

Specimens.

tests

The tests themselves, one row per test, with every specimen it runs on.

result-components

The separate result values a test carries, for example a PCR target and its Ct.

panels

Orderable groups of tests.

result-limits

Numeric reference ranges, by specimen, component, sex and age.

sample-handling

Storage and disposal rules.

terminology

LOINC, SNOMED, CIEL and OCL codes.

reflex-rules

Rules that add a test automatically when a result matches.

Dictionary entries and result options cannot be uploaded here. The dictionaries and test-results areas are not offered on this page and are refused if you name a file after them. They still load from files placed on the server at start-up. If your catalog adds new result options, those two files have to go in that way before the tests that use them will have usable result forms.

Tips

  • Save as UTF-8 without a byte order mark. Excel's "CSV UTF-8" export adds one, and it makes the first column name unreadable, so the file fails on its first line with a message about a missing required column. This is the most common reason a file does nothing.

  • Name files after their area. It is what lets the page sort a multi-file upload out by itself.

  • Preview before Apply. Apply opens once a preview shows no file errors. While it is closed, the line under the buttons tells you what it is waiting for.

  • Panel names are limited to 20 characters, and lab unit names to 20 as well. A longer name is rejected when the row is written. Put the full wording in the panel's display name instead, which is what users see.

  • Applying the same files again is safe. A row that matches an existing record updates it rather than creating a second one, and uploaded files are always re-read even if nothing in them changed.

  • Nothing is ever deleted by an import. Removing a row from a file does not remove the record; set it inactive instead. Panel membership and specimen links are only added.

Not yet available

  • Uploading dictionary entries or result options, as above.

  • A history of past imports on this page. Each load is recorded, but the page does not list them.

  • Blocking Apply while items are still waiting for a decision. You can apply with the list unresolved; those rows are simply skipped.

  • Downloading the skipped rows as a file.