I-TECH-UW / ci-hie-demo

Mozilla Public License 2.0
0 stars 10 forks source link

Update default Sigdep3 database to pre-populate the `fhir_patient_identifier_system` table #11

Open pmanko opened 1 year ago

pmanko commented 1 year ago

The mappings in this table are required for proper communication with the Client Registry, as they provide system values to outgoing Identifier objects.

One option is to add the rows directly to the loaded database. This could work, but managing large SQL files is not ideal.

Another option is to run an initializer script on Sigdep3 bootup or setup, perhaps integrated into the Dockerfile.

We will need to solve the problem of initializing the DB more broadly anyways, as we start development on some SIGDEP3 features and create a docker-based SIGDEP3 release directly from the source code.

My thinking is that for now, it might be easiest to add the two rows directly to the initial database by adding an initializing script like the following to the /configs/sigdep3/db/ folder. This folder is mapped to the docker-entrypoint-initdb.d in the mysql container and gets loaded on initialization.

When we setup the new SIGDEP3 project, we can update this approach if we decide on another way of rolling out the initial database, concepts, settings, etc.

Here's the script that should be updated with system url values for every identifier type that might be assigned to some patient. We don't want identifiers going out w/o the system field set, as this can cause issues with OpenCR:


use openmrs;
INSERT INTO `fhir_patient_identifier_system` (
        `fhir_patient_identifier_system_id`,
        `patient_identifier_type_id`,
        `url`,
        `name`,
        `description`,
        `creator`,
        `date_created`,
        `retired`,
        `retired_by`,
        `date_retired`,
        `retire_reason`,
        `changed_by`,
        `date_changed`,
        `uuid`
    )
VALUES (
        '1',
        '3',
        'http://clientregistry.org/artnumber',
        'ART Number',
        'ART Number',
        1,
        '2013-12-27 00:00:00',
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        'd5efc10e-bf9c-4813-96ef-2969cec85cbb'
    );

INSERT INTO `fhir_patient_identifier_system` (
        `fhir_patient_identifier_system_id`,
        `patient_identifier_type_id`,
        `url`,
        `name`,
        `description`,
        `creator`,
        `date_created`,
        `retired`,
        `retired_by`,
        `date_retired`,
        `retire_reason`,
        `changed_by`,
        `date_changed`,
        `uuid`
    )
VALUES (
        '2',
        '6',
        'http://cote.divore/ext/identifier/UPI',
        'UPI',
        'UPI',
        1,
        '2013-12-27 00:00:00',
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        'b4a56d59-42b2-4a4a-86cc-0fb3188bca11'
    );

These are the identifier types that we have defined in the sigdep3 db with their ID:

1: OpenMRS Identification Number,Unique number used in OpenMRS 2: Old Identification Number,Number given out prior to the OpenMRS system (No check digit) 3: Nomenclature de PEC VIH,Code etablissement(4)/Code site(2)/Année(2)/ Numero d'ordre(5) 4: Nomenclature de CD,Codification de dépistage en vigueur 5: Nomenclature de PTME,codification PTME en vigueur 6: UPI,Unique Patients Identification

@HerbertYiga @ccwhite333 @mozzy11 let me know what you think!

pmanko commented 1 year ago

Updated Insert:

use openmrs;
INSERT INTO `fhir_patient_identifier_system` (
        `fhir_patient_identifier_system_id`,
        `patient_identifier_type_id`,
        `url`,
        `name`,
        `description`,
        `creator`,
        `date_created`,
        `retired`,
        `retired_by`,
        `date_retired`,
        `retire_reason`,
        `changed_by`,
        `date_changed`,
        `uuid`
    )
VALUES (
        '1',
        '3',
        'http://clientregistry.org/artnumber',
        'ART Number',
        'ART Number',
        1,
        '2013-12-27 00:00:00',
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        'd5efc10e-bf9c-4813-96ef-2969cec85cbb'
    ),
    (
        '2',
        '6',
        'http://cote.divore/ext/identifier/UPI',
        'UPI',
        'UPI',
        1,
        '2013-12-27 00:00:00',
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        'b4a56d59-42b2-4a4a-86cc-0fb3188bca11'
    ),
    (
        '3',
        '1',
        'http://tap-cdi.openelis.org/ext/identifier/openmrs-id',
        'UPI',
        'UPI',
        1,
        '2013-12-27 00:00:00',
        0,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL,
        '17b7af60-bc69-4c1c-867e-762219f2ab19'
    );
HerbertYiga commented 1 year ago

@pmanko let me get to this tomorrow

HerbertYiga commented 1 year ago

Well i think for now lets first move by an initializer script,fixing this here https://github.com/I-TECH-UW/ci-hie-demo/pull/13