Retired concepts are being validated like normal concepts

Hi everyone

While testing on a new OpenMrs environments a strange new behavior was found for retired concepts.

It boils down to, every retired concept being validated for unnecessary fields:

  • Name;
  • Data type;
  • Data class;
  • Members;
  • Answers.

This is an issue for openmrs-module-initializer version 2.4.0-SNAPSHOT but not for version 2.3.0

This leads to many problems, for example:

  • Retired concepts throwing’s errors when member or answers are present (very common on new environments since usually member or answers are only created after the retirement file is executed)
  • Concepts with retired data types throwing’s errors because the data type no longer exists

After doing a little bit of digging I think the issue might be related with the development done on [#193] Expanded concept mappings capabilities. by mseaton · Pull Request #196 · mekomsolutions/openmrs-module-initializer · GitHub

Any idea regarding this @ibacher, @mksd, @dkayiwa, @mseaton, @bistenes

Did you mean when answers/members are not present?

Datatype (as well as concepts referenced as answers/members) are foreign key constraints in the database, so cannot be violated.

In other words, the database will throw a foreign key constraint violation if you try to delete a retired concept that is referenced by any existing data and will not allow the datatype to be set or changed to something that isn’t defined in the concept_datatype.

It’s possible a change introduced a bug where retired concepts aren’t retried if dependencies (answers/members or datatype) are missing on the first pass… but there isn’t an option to create concepts (even retired) if database constraints are not met.

Hi @burke

Regarding the first remark:

What we noticed with the last update is that member / answers are being validated for retired concepts.

I will give the following example:

  • Imagine that I want to start a new (clean) environment without any information
  • In this environment I already have a file for retired concepts (just so I can maintain backwards compatibility), and this file as expected is the first one to be executed
  • In this file I have a concept, containing 3 answers
  • None of the answers is retired;
  • Since the retired file is the first to be executed, any answer that isn´t a CIEL will be missing.
  • And this will cause this “retired” concept to be flagged 3 time for having “unregistered concepts”

Regarding the second remark:

Not 100% certain, but for older version of initializer, if we had a clean environment no retired concept would be created. Allowing us to bypass every datatype conflict (for retired concepts).

This is no longer the case, and even with a clean environment, we are now finding error message regarding the datatype, for concepts that are not supposed to be inserted (database).