We need to generate additional patient identifier only if a certain condition is met. If the condition is not met, we don’t want the identifier to be generated or if generated the identifier should be null or empty string. For us the identifier is being generated, but, we are getting the below error: “PatientIdentifier.error.nullOrBlank”. Can we stop the identifier from being generated or even of generated, can it be null or empty string. Can we meet our requirement in any way?
I’ll let others speak on the potential ways to conditionally generate an identifier, but I know that a null or blank identifier would be invalid and not allowed.
- Just create a new ‘Patient Identifier Type’. (say: myCustomIdentifier) NOTE: Do not link this ‘Identifier Type’ to a identifier source.
- Go to advanced settings and add the uuid of the identifier type in property ‘bahmni.extraPatientIdentifierTypes’
- Go to registration screen - you can still see the new identifier type (myCustomIdentifier) in ‘additional identifier’ section.
- Create a patient, and your ‘myCustomIdentifier’ will not get populated automatically.
Now, if you want an identifier to be created based on condition, there is no out-of-box way. (Ideally, it should respect that since there is no ‘auto-generated-option’ defined for default Bahmni Identifier Type)
- using an advice/intercepter on patientService.save(), programatically create an identifier for myCustomIdentifier, when the criterions are satisfied. This is the way we used in Bangladesh, where a UHID gets created by an MPI and when synced the we just assign the UHID as additional “health id” identifier in the hospital instance.
- Define your own custom identifier source and link up your identifier type with this identifier source. NOTE: I am not sure what patient context gets shared with the IdgenSource as such. Maybe others like @mksd or @darius can show some light here.
Thank you Angshu.
I haven’t looked at the code, but offhand I believe it’s up to the Bahmni application to pass whatever patient context we have to idgen, and we may need to add this. (And, we can add anything we need to as well.)
I had a conversation with the implementation and looks like they want to set the identifier value based on value of few observations captured in registration second page. @pramidat Can you please elaborate the use case? As in when do you want to generate the identifier value, where will this be used, so that we can discuss if patient identifier is the way to implement this.
I think the question is not really about “Identifier type”. Its about ID-Gen sources. As I explained earlier, one can achieve that programatically after defining an identifier type and not associating with an ID-Gen Source.
I think, if you must use ID-Gen source, its about when do you decide to create an additional identifier using that source, during a patient edit or some other event (like saving an obs).
Doing it programatically works. (We have done that in Bangladesh and in few other cases).
The scenario is to generate a unique identifier only when the patient qualifies for a particular medical condition, else not generate this identifier.
More Details: When the patient qualifies for this medical condition, the identifier must be generated appending values from mandatory fields on registration and suffixing a sequentially incremented numeral to it. The numeral must be reset at the end of every calendar year.