Program Stages Not Loading in Tabular Data Entry

Dear All,
We are running ver 2.39.1.1 and have started to experience this issue where the program stages for some TEIs do not load and throw this error in the browser console

angular.js:11655 TypeError: Cannot read properties of null (reading ‘code’)
at Object.getName (dhis2.angular.services.js:453:44)
at Object.formatDataValue (dhis2.angular.services.js:510:44)
at services.js:2473:43
at Object.r [as forEach] (angular.js:323:11)
at Object.processEvent (services.js:2466:21)
at dataentry-controller.js:1028:49
at Object.r [as forEach] (angular.js:323:11)
at $scope.getEvents (dataentry-controller.js:1001:21)
at dataentry-controller.js:954:28
at angular.js:13248:27

We noticed that this happens for both patients owned by the org unit and patients who were transferred fully by another org unit.

What we also noticed was that on changing to timeline data entry, the data entry forms open and we are able to enter data and schedule a follow-up visit but that data does not save and no new entries are made on the timeline.
Does anyone have any idea what could be going on here?

@dhis2-tracker @dhis2-backend

Hi @ifeanyiokoye

Sorry to hear your are facing this issue. The first clue from the error code is “code” do these organization units and other metadata have “code” if not could you please test and add code in the metadata?

After that please test using Guest mode (not incognito, Guest - which is different).

Thanks!

@Gassim The organization units have code. The code is part of the autogenerated Program ID for each patient.
Also, note that this is affecting a few patients, and not everyone enrolled.
Thanks

Thank you for the info!

May I ask how this code is autogenerated? Is the Program ID a data element (or a TE attribute) that is filled using a program rule? Is it possible that for these patients there is an issue generating the value?

Does this issue happen to a user with ALL authority?

Thanks!

Yes, I am the system admin and I have exactly the same experience.

1 Like

Dear @Gassim,
How are you today?
Do you have any further guidance on this issue?
Thank you.

1 Like

Thanks! As much detailed information would help uncover the underlaying causes to this issue, please.

Hopefully we can get a close look at these details I requested above…

Would be great if we can figure out the difference between the patients who are affected and those who aren’t. What metadata or anything that these affected patients have (or not have) that other patients who are not affected doesn’t (or does)?

Thanks!

Dear @Gassim, I have looked through all the data elements and ensured that code has been added to the few data elements without code.
I have also tested this in Guest mode on Chrome but the issue still persists.
I clicked on the link in the error on the console and this line in the code below was where the error was pointing to: if (keyString === options[i].code) {

getName: function getName(options, key) {
if (options) {
// for comparison with the option values, which are always represented as strings
var keyString = String(key);

                // is key a code?
                for (var i = 0; i < options.length; i++) {
                    if (keyString === options[i].code) {
                        return options[i].displayName;
                    }
                }
                // is key a name?
                for (var i = 0; i < options.length; i++) {
                    if (keyString === options[i].displayName) {
                        return key;
                    }
                }
                // not a part of the option set
                return null;
            }

            return key;
        }

It appears something else may be going on.

Any insights on this.

Thanks

1 Like

I’m asking for further support on this from the tracker team. I will get back to you as soon as I have some info. Thanks!

1 Like

Thank you.

1 Like

I get it! :slight_smile:

Some of the elements in the array options must be empty for some reason. Which probably means something is wrong with your metadata, becuase options is here an option set, and those should normally not contain empty elements (as far as I know).

It’s not hard at all to add a guard against this scenario in the code, and probably a lot easier than it would be for you to fix the metadata. Also others might benefit from it. But I wonder, does me making a code fix mean there will be a long delay before you get access to it because it has to go through the release system? If so it might be more interesting to figure out what the problematic option sets are and how to fix them.

2 Likes

Thanks, Tony for this insight. Something else to consider: why does it only affect a few TEIs and not everyone?

1 Like

Thanks, Tony for this insight. Something else to consider: why does it only affect a few TEIs and not everyone?

It’s because they have selected different values from the option set. A value far down the list of options is more likely to trigger the issue.

1 Like

Right. So, what do you advise we do? @superskip

Thank you.

1 Like

@ifeanyiokoye I suggest you create a TEI for testing and try a few values in the option sets to verify that this is indeed what’s causing the error. After that the natural continuation would be to figure out which option sets are faulty and from what point in the list, but unless you have a clue about how to fix the metadata there is probably no reason to do this. On my part I’ll just add the guard I mentioned.

1 Like

@ifeanyiokoye I’ve implemented the fix I had in mind. Great if you could check if it solved the problem; the latest 2.39 version of Tracker Capture can be downloaded here, and installed through the App management app. (I need your assistance for the testing because I don’t know how to reproduce the error you got. It’s not vital that you do this test though, the fix will still come out in the next release.)

1 Like

Hi Tony. I think we may have multifactorial issues. I do not think some apps are updating on our instance and I do not know why. After updating the Tracker Capture app, what version should it read?

Is this correct?

Yes, that’s correct :sweat_smile: You may find it useful to know that the name and version can be modified by editing “manifest.webapp” (located in the zip-file).

1 Like

Hello Tony @superskip,
The update did not resolve it. I have started checking all the Option Sets one after the other and found this error with one of them:

This option set has data in it. How do I resolve this?

I have also found this issue with some category option combos which is preventing any updates being made to them.

Thanks

Just an update on this. Found 2 Option Sets with this error.