Validation across multiple enrolments

Dear DHIS2 Team,

Dear Community,

We are using DHIS2 for an international programme for the surveillance of pathogens on neonatal wards in hospitals.

We have the following problem and are hoping for your help.

We need to validate entries across multiple enrolments and issue warning messages when rules are violated. So far we have not found a way to perform such a validation.

Example:

When an enrolment is entered, we want to check whether there is already an enrolment for the ‘Tracked Entity Instance’ with the same ‘Admission Date’ or with an admission date in the immediate vicinity (±3 days) (also for enrolments that have already been ‘completed’). If this is the case, a warning should be issued.

These messages should be issued ad hoc to give the user immediate feedback.

Up to now, we have handled this via external tool chains that generate error reports, which we can then use to inform users and request corrections. However, this is not a very viable option. We would like to prevent the input in advance.

Does anyone have any ideas on how we can solve this?

Many thanks and best regards from Berlin

Sebastian Wolff

Charité University Medicine Berlin

1 Like

Hi @Wolffseb

Welcome to the DHIS2 Community of Practice! :tada:

Thank you for your post with the details about the use case.

While this has been triaged to @dhis2-tracker , I’d like to propose if using the automatically generated Text Pattern sequence option help solve even if part of the problem (duplicate enrollment)?

A Tracked Entity Instance (TEI) attribute can be unique in the entire system or in the Organization Unit (OU) and automatically generated using a sequence. This sequence could make use of CURRENT_DATE(format) (hoping this would be the admission date)?

Something such as the example mentioned in the docs:
ORG_UNIT_CODE(...) + "-" + CURRENT_DATE(yyyyww) + "-" + SEQUENTIAL(#####)

This should make the enrollment unique and will stop duplicate enrollment if it’s in the same admission date.

Hello and thank you very much for the warm welcome and the quick reply.

We already use a unique key for the TEI (a kind of patient number as a TEA). Unfortunately, the data is not necessarily recorded on the same day as the admission. This is often only done afterwards. And it may well be that several recordings are made for an org unit on the same day. But for different patients. So this solution doesn’t seem entirely practicable for our use case.

Our problem is that another enrolment is performed for an existing TEI. So instead of continuing to use existing enrolments or correcting existing ones, new enrolments are inserted for the patient - with identical data. So it would only help us if the Admission Date was unique for a programme for a TEI with a patient number. Or a validation rule. Of course, we try to train users comprehensively, but due to the wide geographical distribution of users, this is not always easy. We therefore try to make the system as robust as possible against incorrect entries.

Best regards

Sebastian

1 Like

Hi @Wolffseb , welcome to the community!

I have discussed your issue with the core tracker team, and I think there are a few separate routes you could explore.

First, should it be allowed for a patient (TEI) to have multiple enrollments in your system? If this is a neonatal care surveillance, how rare would it be in practice for an infant to have multiple enrollments due to multiple hospital admissions? If this is an edge case, you may consider checking off
Only enroll once (per tracked entity instance lifetime)
in program configuration.

For those edge cases where a “new” patient has been found through Search to be previously enrolled, then a new TEI/patient ID could be generated. As an attribute, you can add a free text note where end users link it to the previous TEI’s patient ID, so the TEI can be merged in your research dataset later.

IF, multiple enrollments could and should be routinely collected per patient, then you can look into the other options below.

Second, consider adapting @Gassim 's solution above for your workflow.
a) Make a new Tracked Entity Attribute of value type text, called “Unique Enrollment ID”. Make it unique to the system and assign it to the program.
b) Create a program rule that auto-assigns the enrollment date combined with the manually-entered patient number to the “Unique Enrollment ID”.
Condition: d2:hasValue(V{enrollment_date} && d2:hasValue(A{patient_number})
Expression to evaluate and assign:
d2:concatenate(V{enrollment_date},"-", A{patient_number})
[there may be a warning thrown creating this action on some versions, but you can ignore it]

Now when a user tries to enroll the same TEI a second time on the same day, the “Unique Enrollment ID” would throw an error.

Third, if you are using Capture app, you could consider a Capture Form Field plugin, which uses an API request to find any “matching” enrollments and show a warning to the user before they create a new one. This will allow you to show a warning / block duplicate entries altogether in the web app that meet more complex conditions (e.g. Admission date ±3 days) Here are relevant docs to get you started with plugins.

I see you already have built some custom DHIS2 apps, but are using the Tracker Capture app, which has been superseded by Capture and does not have plugin support. So, if you are going to stick with Tracker Capture app, I recommend Point 1 or 2 above, or continuing with current scripts.

Prost from a Charité alumnus in Oslo :slight_smile: :beers: :bear:

2 Likes