# Importing external patient demographics

To facilitate cooperation with other software running alongside GNUmed the client offers a modular interface for importing patient demographics. This interface is activated from various places in the client:

- at client startup
- when hitting `<F-2>` from within the patient search field
- when selecting the option Load external patient from the Patient menu

If several external patients are available a picklist is shown. Again, if several GNUmed patients seem to match the just selected external patient another picklist is shown. If the selected external patient does not yet exist in GNUmed it is newly created. After a patient has been selected or created it is made the currently active patient.

Some external patient demographics sources can be auto-detected while others must be configured to work.

Currently supported sources:

- German KVK (Krankenversichertenkarte)
- any application using the German xDT standard
  - softwarespezifische Konfigurationsanleitungen
- Australian PracSoft-to-MDW2 file link

Supports:

- multiple source file copies i.e. one on the legacy server machine, and one on the legacy client machine
- GNUmed parses both, and provides the user with a combined list in the dropdown
- a practical limit, to avoid slowing down GNUmed, of around 50 patients (machine-dependent).
- carrying a legacy machine uniqueID for the patient including its use as the GNUmed external_id; the legacy/external source importer can even attach a unique source ID for sources which do not provide one.

Does not currently support:

- batch-importing the source file into GNUmed (but we would only need to batch-call the import method).

## Configurable Sources

### German: Import einer xDT-Datei

Viele deutsche Arztprogramme unterstützen den Export von Patientenstammdaten im BDT- oder GDT-Format. GNUmed kann dieses Format einlesen und den Patienten suchen und aktivieren, sowie nötigenfalls neu anlegen.

Zur Aktivierung dieser Schnittstelle muß die xDT-Datei in der Konfigurationsdatei `gnumed.conf` angegeben werden. Als Fallbeispiel unter MS/Windows:

Das Praxisprogramm DoktorenFreud schreibt auf Knopfdruck den aktuellen Patienten in die Datei `c:\Programme\DoktorenFreud\tmp\patient.gdt` und ruft dann die Batch-Datei `c:\Programme\DoktorenFreud\Knöpfe\extern.bat` auf. Man konfiguriert also in der Datei `gnumed.conf` folgendes:

    [workplace]
    ...
    XDT profiles = $XDT profiles$
    DoktorenFreud
    $XDT profiles$
    ...

    [XDT profile DoktorenFreud]
    source = DoktorenFreud
    filename = c:\Programme\DoktorenFreud\tmp\patient.gdt
    DOB format = %m%d%Y

Details zur Angabe des Datumsformates finden sich im Python Handbuch, Die so konfigurierte externe Patientenquelle vom XDT-Typ kann dann folgendermaßen genutzt werden:

#### Übergabe beim Programmstart von GNUmed

Wenn GNUmed gestartet wird, sucht es nach der Datei `c:\Programme\DoktorenFreud\tmp\patient.gdt` und aktiviert den darin enthaltenen Patienten. Falls nötig wird dieser neu angelegt. Dieser Start von GNUmed kann z.B. vom Programm DoktorenFreud in der Batch-Datei `extern.bat` ausgelöst werden.

#### Übergabe an ein laufendes GNUmed

In DoktorenFreud wird der Patient als GDT-Datei exportiert. Im parallel laufenden GNUmed wird im Patientensuchfeld `<F-2>` gedrückt. Aus der erscheinenden Liste wird die Patienten-Quelle DoktorenFreud ausgewählt. Der Patient wird importiert.

### Australia: PracSoft

Even if MDW2 isn't installed you can still configure PracSoft to write patient demographics to the `PATIENTS.IN` file. Then add a section [AU PracSoft PATIENTS.IN] to your configuraton file. In that section specify the filename and source options. From then on patients in the PracSoft file should be offered for selection from the external sources.

## Auto-detected Sources

### Germany: MCS/Isynet

This software writes the currently activated patient to a file `:\Winacs\TEMP\BDT*.tmp` which is searched for on all accessible drives and parsed if found.

### Australia: PracSoft

This software can be configured to emit patient demographics changes to a file `PATIENTS.IN`. If Medical Director (Windows) v2 is also installed PracSoft is usually configured to store that file in `:\MDW2\`. If the file is detected on any accessible drive it is parsed for patients.

## More information

For technical details regarding implementation of the patient demographics interface see the source code. There will eventually be some information in the Developer Guide. If you send us a specification of how your software can export the current patient we will be happy to add it to our interface.