Patient Registration field validation

I have added a dropdown (concept) in the registration form as “Patient Type”.

The dropdown must have any of the following value

  • general
  • insurance
  • other

I am trying to add custom validation so that the dropdown has to be selected in order to save the registration. This is what I have below in the fieldValidation.js

"patientType": {
        method: function (name, value) {
            return value.length > 0;

Below code is the HTML I get for that field from the browser

<select id="patientType" ng-model="targetModel[].conceptUuid" ng-options="a.conceptId as a.description for a in ::attribute.answers" ng-disabled="::isReadOnly(" ng-required="false" ng-change="appendConceptNameToModel(attribute); handleUpdate(" class="ng-pristine ng-valid ng-valid-required ng-touched"><option value="" selected="selected"></option><option label="Umum" value="string:c2107f30-3f10-11e4-adec-0800271c1b75">Umum</option><option label="Asuransi" value="string:c211442b-3f10-11e4-adec-0800271c1b75">Asuransi</option><option label="BPJS" value="string:c2123edc-3f10-11e4-adec-0800271c1b75">BPJS</option></select>

Can anyone check why my validation is not working ?

Hi @abiieez, please confirm if your field name and the fieldValidation keyname are same. If you are comfortable can you try debugging javascript? I mean Chrome devtools->Inspect->Source->open fieldvalidation.js file and put a debug point.

I tried to put breakpoint but it doesnt seem to stop at it.

The field name are the same

Hi, Can you debug patientCommonController at handleUpdate() method to see what is the attribute name coming as shown in below screenshot?

I am not able to find the controllers folder.

Any idea why?

Hi i thought you have linked your bahmniapps code to vagrant only then you can see the actual files. Otherwise you will see the minified js file for every app. In the screen short you sent there is registration.min.xxxxxx.js file.

  1. Open that file and click on {} symbol below to format which will formatted version of same registration min js file.
  2. Find(CMD+F / CNTRL+F) “patientCommonController” word. once you find that u can scroll down to find handleUpdate method. Continue to debug.

I can find the handleUpdate method after following your steps. However the break point doesnt seem to work on the formatted / pretty-print js file. Am I missing something ?

Hi, I am able to find it. find the screenshorts below. Can you try again? Goto line number 6276

yes you were right, I had to select the drop down to make it trigger handle update. The value in the debug is “patientType”

Can you move forward and check what are values of Bahmni.Registration.AttributesConditions.rules and ruleFunction?

undefined for both values.

Looks like it is broken. Will check and let you know.