Optional Patient identifier cannot be deleted

Hello!, Currently am working on this ticket here, After configurations done in registrationapp.json as seen below

{
    "id": "foobar.registrationapp.registerPatient",
    "instanceOf": "registrationapp.registerPatient",
    "label": "Create a new patient",
    "description": "Create a new Patient Record",
    "extensions": [           
        {
            "id": "foobar.registrationapp.registerPatient.homepageLink",
            "extensionPointId": "org.openmrs.referenceapplication.homepageLink",
            "type": "link",
            "label": "referenceapplication.app.registerPatient.label",
            "url": "registrationapp/registerPatient.page?appId=foobar.registrationapp.registerPatient",
            "icon": "icon-user",
            "order": 1,
            "requiredPrivilege": "App: registrationapp.registerPatient"
        },
        {
            "id": "application.registrationapp.summary.editPatientLink",
            "extensionPointId": "patientDashboard.overallActions",
            "type": "link",
            "label": "referenceapplication.app.editRegistrationInfo.label",
            "url": "registrationapp/registrationSummary.page?patientId={{patient.uuid}}&appId=foobar.registrationapp.registerPatient",
            "icon": "icon-pencil",
            "order": 25,
            "requiredPrivilege": "App: registrationapp.registerPatient"
        }
    ],
    "config": {
        "afterCreatedUrl": "/coreapps/clinicianfacing/patient.page?patientId={{patientId}}",
        "sections": [
            {
                "id": "contactInfo",
                "label": "registrationapp.patient.contactInfo.label",
                "questions": [
                    {
                        "legend": "Person.address",
                        "fields": [
                            {
                                "type": "personAddress",
                                "label": "registrationapp.patient.address.question",
                                "widget": {
                                    "providerName": "uicommons",
                                    "fragmentId": "field/personAddress"
                                }
                            }
                        ]
                    },
                        {
                            "id" : "identificationNumber",
                            "legend" : "Number Identifier",
                            "fields" : [
                                {
                                    "type" : "patientIdentifier",
                                    "label" : "Identifier",
                                    "formFieldName" : "identificationNumber",
                                    "uuid" : "PASTE_THE_SAVED_UUID",
                                    "widget" : {
                                        "providerName" : "uicommons",
                                        "fragmentId" : "field/text"
                                    }
                                }
                            ]
                        }
                ]
            }
        ]
    }
} 

When trying to add an identifier parameter value , an identifier can be saved and reflected on the patient dashboard page but trying to delete identifier value and save an empty identifier field , the system redirects the exact identifier that was saved ,which is a bug ,the system should return empty value on the ui

What i have done so far here is the draft Pr the challenge so fur is that, the object(identifier parameter value ) cannot be persisted to the database , it seem to be reflected and saved on the ui only
Other thought which am still looking into is that this lines

 PatientIdentifier identifier = new PatientIdentifier(parameterValue, identifierType, null);
PatientIdentifierValidator.validateIdentifier(identifier);

validates only identifiers , it doesn’t check whether the identifier field is empty or null. The workaround should be able to validate field.getFormFieldName() , in that when the identifier is deleted and identifier field is empty, the system should not return the identifier value or empty string

Any help will be much appreciated cc @ibacher @mksd @mozzy

Seems there is a workaround done in webservices .rest here https://github.com/openmrs/openmrs-module-webservices.rest/blob/master/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java#L112. in this context the instance returns the added identifier which is our bug and i think it has same idealogy

Just void the existing identifier with an else for this condition: https://github.com/openmrs/openmrs-module-registrationapp/blob/1.20.0/omod/src/main/java/org/openmrs/module/registrationapp/form/RegisterPatientFormBuilder.java#L268-L294

1 Like

Thanks @dkayiwa will look into that, Is voiding/deleting the existing identifier a good idea, or we can hide the existing identifier from populating on the ui, any suggestion on this