Skip to content

Analysing errors

Vivek Singh edited this page Apr 14, 2023 · 11 revisions

Scenarios

If there is a community member in Avni, but the same person is not present in Bahmni

  • If you are looking at this community member from the Avni database (and not the app) then please make sure that the individual is not voided before analyzing further.
  • Get the uuid of the individual from the database (query below). Use this uuid to find if there are any errors for this individual in the integration system via the user interface.

If there is a patient in Bahmni, but the corresponding person/patient not present in Avni

  • Get the uuid of the patient from the database (query below). Use this uuid to find if there are any errors for this individual in the integration system via the user interface.

If there is an encounter in Bahmni, but the corresponding encounter is not present in Avni

  • Get the uuid of the encounter from the database (query below). Use this uuid to find if there are any errors for this individual in the integration system via the user interface.

Useful queries

[Avni] Get individual's uuid by giving individual identifier

select uuid from individual where individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' = '03042906'

[OpenMRS] Get patient's uuid by giving patient identifier

select p2.uuid from patient_identifier join patient p on patient_identifier.patient_id = p.patient_id join person p2 on p.patient_id = p2.person_id where identifier = 'TRI03070505';

[OpenMRS] Get encounter's uuids by giving patient identifier

select e.uuid, concept_name.name, et.name, e.date_created, e.date_changed from patient_identifier join patient p on patient_identifier.patient_id = p.patient_id join person p2 on p.patient_id = p2.person_id join encounter e on e.patient_id = p.patient_id join encounter_type et on et.encounter_type_id = e.encounter_type join obs on obs.encounter_id = e.encounter_id join concept on obs.concept_id = concept.concept_id join concept_name on concept.concept_id = concept_name.concept_id where identifier = 'TRI03110304' and et.name not like '%[Avni]%' and concept_name.concept_name_type = 'FULLY_SPECIFIED' and obs.obs_group_id is null and obs.voided = false and e.voided = false;

Queries to use to find the same entity in one system in another system.

For data originating in Avni

If you know the encounter uuid in OpenMRS and want to get the encounter in Avni

  1. First get the avni encounter uuid from OpenMRS

select concept_name.name, obs.value_text from obs join encounter on obs.encounter_id = encounter.encounter_id join concept on obs.concept_id = concept.concept_id join concept_name on concept.concept_id = concept_name.concept_id where encounter.uuid = 'PUT OPENMRS ENCOUNTER UUID HERE' and concept_name_type = 'FULLY_SPECIFIED' and concept_name.name = 'Avni Entity UUID [Avni]';

  1. Get the encounter/program-encounter/enrolment from avni using the uuid you got from above query
  • select * from encounter where uuid = 'UUID YOU GOT IN 1';
  • select * from program_encounter where uuid = 'UUID YOU GOT IN 1';
  • select * from program_enrolment where uuid = 'UUID YOU GOT IN 1';

If you know the encounter/program-encounter/enrolment uuid in Avni and want to get the encounter in Bahmni

Run following in OpenMRS DB

select encounter.uuid from obs join encounter on obs.encounter_id = encounter.encounter_id join concept on obs.concept_id = concept.concept_id join concept_name on concept.concept_id = concept_name.concept_id where concept_name_type = 'FULLY_SPECIFIED' and concept_name.name = 'Avni Entity UUID [Avni]' and obs.value_text = 'PUT AVNI UUID HERE';

For data originating in Bahmni

If you know the encounter uuid in OpenMRS and want to get the encounter/program-encounter/enrolment in Avni (run following in Avni)

  • select * from program_encounter where observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' = 'PUT OPENMRS ENCOUNTER UUID HERE';
  • select * from encounter where observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' = 'PUT OPENMRS ENCOUNTER UUID HERE';
  • select * from program_enrolment where observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' = 'PUT OPENMRS ENCOUNTER UUID HERE';

If you know the encounter/program-encounter/enrolment uuid in Avni and want to get the encounter in OpenMRS (run following in OpenMRS)

  • select observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' from program_encounter where uuid = 'PUT AVNI UUID HERE';
  • select observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' from encounter where uuid = 'PUT AVNI UUID HERE';
  • select observations->>'1d8348c8-1ac2-4c0c-bcf0-bcd94869e8ed' from program_enrolment where uuid = 'PUT AVNI UUID HERE';

Explanation of different types of errors and action required to fix them

Avni to Bahmni

NoPatientWithId

This error is recorded when child entity types is either of enrolment, general/program encounter. If the individual sync previously failed then you will see this error.

PatientIdChanged

This is likely to be a rare error. Suppose the previous Individual was synced to Bahmni successfully. But after this sync in Avni, the user modified the identifier value.

SubjectIdNull

The individual in Avni has no identifier.

SubjectIdChanged

For the individual in Avni (matched by Sangam number), there is already a record in Bahmni but from a different individual in Avni. This can happen when a previous individual in avni was voided after it was synced to Bahmni.

Bahmni to Avni

NotACommunityMember

  • A patient could not be processed and an error was created for it.
  • During error record reprocessing, the identifier has been changed such that the patient is not a community member anymore.
  • These records are not reprocessed after the above happens.

NoSubjectWithId

There is no individual in Avni with the same identifier.

SubjectIdChanged

  • A patient was processed successfully and saved to Avni.
  • The same patient record was updated in Avni in such a way that its identifier was changed.

MultipleSubjectsWithId

There are more than one non-voided individuals in Avni for the same identifier.

Error Processing (in both directions)

EntityIsDeleted

  • An any entity could not be processed and error was created for that entity.
  • During error record reprocessing the sync process tried to look up this entity in the source system but cannot find it anymore.
  • These records are not reprocessed after the above happens.

General

If there is an error for emoji characters when saving data in OpenMRS

  • The error message will be like "Incorrect string value: '\xF0\x9F\x91\x8D'"
  • It can be fixed by fixing the data in avni which supports emoji but openmrs/mysql doesn't