Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tarun,Supriya,Ramu, Prajakta, Venky | BAH-1389 | MOBN-1748 | MOBN-1784 | Registration Module] Make local language field mandatory and add UI Validation to extra Patient Identifiers #489

Merged
merged 3 commits into from Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion ui/app/i18n/registration/locale_en.json
Expand Up @@ -117,5 +117,8 @@
"REGISTRATION_MESSAGE": "Thank you for registering. Please note your Patient Registration Details : #patientId, #name, #gender, #age years",
"REGISTRATION_TO_CLINICAL": "Save and go to Dashboard",
"FILE_UPLOAD_MUST_BE_IMAGE": "File uploaded must be an image",
"FILE_UPLOAD_MUST_BE_LESS_THAN": "File size should be less than"
"FILE_UPLOAD_MUST_BE_LESS_THAN": "File size should be less than",
"PATIENT_ATTRIBUTE_GIVEN_NAME_LOCAL": "First Name in Arabic",
"PATIENT_ATTRIBUTE_FAMILY_NAME_LOCAL": "Last Name in Arabic",
"PATIENT_ATTRIBUTE_MIDDLE_NAME_LOCAL": "Middle Name in Arabic"
}
12 changes: 11 additions & 1 deletion ui/app/registration/controllers/patientCommonController.js
Expand Up @@ -26,7 +26,7 @@ angular.module('bahmni.registration')

$scope.getExtButtons = function (identifierType) {
var extensionPoint = getExtensionPoint(identifierType);
if (extensionPoint.extensionParams !== null && extensionPoint.extensionParams.buttons !== null) {
if (extensionPoint != null && extensionPoint.extensionParams !== null && extensionPoint.extensionParams.buttons !== null) {
return extensionPoint.extensionParams.buttons;
}
return null;
Expand Down Expand Up @@ -210,6 +210,16 @@ angular.module('bahmni.registration')
}
});

$scope.localLanguageNameIsRequired = function (nameType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is advisable anymore i.e using person attribute. OMRS already has a name model where names in different locale can be added. I would have advised that.

Also, just because the person attribute is marked as required does not mean that value must be provided - I would have thought you enable this by some sort of configuration (which I think we already have).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we couldn’t see any option make the field has mandatory in the back-end so we have added this

personAttributes = _.keyBy($rootScope.patientConfiguration.attributeTypes, function (attribute) {
return attribute.name;
});
if (_.isEmpty(nameType)) {
return personAttributes.givenNameLocal.required || personAttributes.middleNameLocal.required || personAttributes.familyNameLocal.required;
}
return nameType && personAttributes[nameType] && personAttributes[nameType].required;
};

$scope.confirmationPrompt = function (event, toState) {
if (dontSaveButtonClicked === false) {
if (event) {
Expand Down
13 changes: 13 additions & 0 deletions ui/app/registration/directives/extraPatientIdentifiers.js
@@ -0,0 +1,13 @@
'use strict';

angular.module('bahmni.registration')
.directive('extraPatientIdentifiers', function () {
return {
templateUrl: 'views/patientIdentifier.html',
scope: {
fieldValidation: '=',
patient: '='
},
restrict: 'E'
};
});
1 change: 1 addition & 0 deletions ui/app/registration/index.html
Expand Up @@ -203,6 +203,7 @@
<!--<script src="watchers.js"></script>-->

<script src="../common/ui-helper/directives/fallbackSrc.js"></script>
<script src="directives/extraPatientIdentifiers.js"></script>
<script src="directives/addressFields.js"></script>
<script src="directives/topDownAddressFields.js"></script>
<script src="directives/printOptions.js"></script>
Expand Down
84 changes: 84 additions & 0 deletions ui/app/registration/views/patientIdentifier.html
@@ -0,0 +1,84 @@
<section ng-controller="PatientCommonController">
<div ng-if="patient.uuid != undefined">
<article ng-repeat="identifier in patient.extraIdentifiers" class="form-field existing-patient">
<div class="field-attribute">
<label class="control-label" for="patientID">{{:: getTranslatedPatientControls(identifier.identifierType.name)}}
<span ng-show=":: identifier.identifierType.required && !identifier.hasIdentifierSources()"
class="asterick">*</span>
</label>
</div>
<div class="field-value">
<input type="text" ng-model="identifier.identifier" disabled
ng-if="identifier.hasIdentifierSources()"/>

<input type="text" id="{{identifier.identifierType.name}}" ng-model="identifier.registrationNumber"
ng-if="!identifier.hasIdentifierSources()"
non-blank="identifier.identifierType.required && !identifier.hasIdentifierSources()"
pattern-validate ng-change="identifier.generate()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-2">
<div class="extension-btn" ng-show="showIdentifierVerificationButton(identifier.identifierType.name,identifier.registrationNumber)">
<span ng-repeat="extButton in getExtButtons(identifier.identifierType.name)">
<span> {{:: extButton.link}} </span>
<button type="button"
ng-click="openIdentifierPopup(identifier.identifierType.name, extButton.action)">{{:: extButton.display}}
</button>
</span>
</div>
</div>
</article>
</div>
<div ng-if="patient.uuid == undefined">
<article ng-repeat="identifier in patient.extraIdentifiers"
class="form-field existing-patient">
<div class="field-attribute">
<label class="control-label" for="patientID">{{:: getTranslatedPatientControls(identifier.identifierType.name)}}
<span ng-show="::identifier.identifierType.required && !identifier.hasIdentifierSources()"
class="asterick">*</span>
</label>
</div>
<div ng-show="::(identifier.hasIdentifierSources() && !identifier.hasIdentifierSourceWithEmptyPrefix())"
class="field-value" id="patientID">
<select id="identifierPrefix" ng-model="identifier.selectedIdentifierSource"
ng-options="identifierSource.prefix for identifierSource in ::identifier.identifierType.identifierSources"
ng-change="patient.generateIdentifier(identifier)"
required>
</select>
</div>
<div class="field-value" ng-if="!identifier.hasIdentifierSources()">
<input type="text" id="{{identifier.identifierType.name}}" ng-model="identifier.registrationNumber"
non-blank="identifier.isIdentifierRequired()" pattern-validate
ng-change="identifier.generate()" focus-on="identifier.hasOldIdentifier"
ng-show="identifier.hasOldIdentifier || !identifier.hasIdentifierSources()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-1">
<div class="extension-btn" ng-show="showIdentifierVerificationButton(identifier.identifierType.name,identifier.registrationNumber)">
<span ng-repeat="extButton in getExtButtons(identifier.identifierType.name)">
<span> {{:: extButton.link}} </span>
<button type="button"
ng-click="openIdentifierPopup(identifier.identifierType.name, extButton.action)">{{:: extButton.display}}
</button>
</span>
</div>
</div>

<div class="field-value field-value-has-identifier" ng-show="::identifier.hasIdentifierSources()">
<input type="text" id="{{identifier.identifierType.name}}" ng-model="identifier.registrationNumber"
non-blank="identifier.isIdentifierRequired()" pattern-validate
ng-change="identifier.generate()" focus-on="identifier.hasOldIdentifier"
ng-show="identifier.hasOldIdentifier || !identifier.hasIdentifierSources()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-1">

<div class="fl">
<div class="field-attribute hasOldIdentifier-field-attribute">
<label for="hasOldIdentifier" ng-show="::showEnterID" class="control-label">{{::'REGISTRATION_LABEL_ENTER_ID' |
translate}}</label>
</div>
<div class="field-value">
<input class="input-label-inline" ng-show="::showEnterID" type="checkbox"
id="hasOldIdentifier" ng-model="identifier.hasOldIdentifier"
ng-change="identifier.clearRegistrationNumber()">
</div>
</div>
</div>
</article>
</div>
</section>
101 changes: 9 additions & 92 deletions ui/app/registration/views/patientcommon.html
Expand Up @@ -3,21 +3,21 @@
<section>
<article class="form-field patient-name-wrapper" ng-if="::patientConfiguration.local()['showNameField']">
<div class="field-attribute">
<label for="patientName">{{::getTranslatedPatientControls(patientConfiguration.local()['labelForNameField'])}}</label>
<label for="patientName">{{::getTranslatedPatientControls(patientConfiguration.local()['labelForNameField'])}}<span class="asterick" ng-show="localLanguageNameIsRequired()">*</span></label>
</div>
<div class="field-value" id="patientNameLocal">
<span ng-repeat="nameField in patientNameDisplayOrder">
<input type="text" id="givenNameLocal" ng-model="patient.givenNameLocal" pattern-validate
placeholder="{{::getTranslatedPatientControls(patientConfiguration.local()['placeholderForGivenName'])}}" focus-me="true"
ng-if="nameField === 'firstName'">
placeholder="{{::'PATIENT_ATTRIBUTE_GIVEN_NAME_LOCAL' | translate}}" focus-me="true"
ng-if="nameField === 'firstName'" ng-required={{localLanguageNameIsRequired('givenNameLocal')}}>
<input ng-show="::showMiddleName" type="text" id="middleNameLocal"
ng-model="patient.middleNameLocal"
pattern-validate
placeholder="{{::getTranslatedPatientControls(patientConfiguration.local()['placeholderForMiddleName'])}}"
ng-if="nameField === 'middleName'">
placeholder="{{::'PATIENT_ATTRIBUTE_MIDDLE_NAME_LOCAL' | translate}}"
ng-if="nameField === 'middleName'" ng-required={{localLanguageNameIsRequired('middleNameLocal')}}>
<input type="text" ng-show="::showLastName" id="familyNameLocal" ng-model="patient.familyNameLocal" pattern-validate
placeholder="{{::getTranslatedPatientControls(patientConfiguration.local()['placeholderForFamilyName'])}}"
ng-if="nameField === 'lastName'">
placeholder="{{::'PATIENT_ATTRIBUTE_FAMILY_NAME_LOCAL' | translate}}"
ng-if="nameField === 'lastName'" ng-required={{localLanguageNameIsRequired('familyNameLocal')}}>
</span>
</div>
</article>
Expand Down Expand Up @@ -152,90 +152,7 @@

<section>
<!--edit patient flow-->
<section>
<div ng-if="patient.uuid != undefined">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these code sections removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, We have refactored this code to validate Additional identifier

<article ng-repeat="identifier in patient.extraIdentifiers" class="form-field existing-patient">
<div class="field-attribute">
<label class="control-label" for="patientID">{{:: getTranslatedPatientControls(identifier.identifierType.name)}}
<span ng-show=":: identifier.identifierType.required && !identifier.hasIdentifierSources()"
class="asterick">*</span>
</label>
</div>
<div class="field-value">
<input type="text" ng-model="identifier.identifier" disabled
ng-if="identifier.hasIdentifierSources()"/>

<input type="text" id="registrationNumber" ng-model="identifier.registrationNumber"
ng-if="!identifier.hasIdentifierSources()"
non-blank="identifier.identifierType.required && !identifier.hasIdentifierSources()"
pattern-validate ng-change="identifier.generate()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-2">
<div class="extension-btn" ng-show="showIdentifierVerificationButton(identifier.identifierType.name,identifier.registrationNumber)">
<span ng-repeat="extButton in getExtButtons(identifier.identifierType.name)">
<span> {{:: extButton.link}} </span>
<button type="button"
ng-click="openIdentifierPopup(identifier.identifierType.name, extButton.action)">{{:: extButton.display}}
</button>
</span>
</div>
</div>
</article>
</div>
<div ng-if="patient.uuid == undefined">
<article ng-repeat="identifier in patient.extraIdentifiers"
class="form-field existing-patient">
<div class="field-attribute">
<label class="control-label" for="patientID">{{:: getTranslatedPatientControls(identifier.identifierType.name)}}
<span ng-show="::identifier.identifierType.required && !identifier.hasIdentifierSources()"
class="asterick">*</span>
</label>
</div>
<div ng-show="::(identifier.hasIdentifierSources() && !identifier.hasIdentifierSourceWithEmptyPrefix())"
class="field-value" id="patientID">
<select id="identifierPrefix" ng-model="identifier.selectedIdentifierSource"
ng-options="identifierSource.prefix for identifierSource in ::identifier.identifierType.identifierSources"
ng-change="patient.generateIdentifier(identifier)"
required>
</select>
</div>
<div class="field-value" ng-if="!identifier.hasIdentifierSources()">
<input type="text" id="registrationNumber" ng-model="identifier.registrationNumber"
non-blank="identifier.isIdentifierRequired()" pattern-validate
ng-change="identifier.generate()" focus-on="identifier.hasOldIdentifier"
ng-show="identifier.hasOldIdentifier || !identifier.hasIdentifierSources()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-1">
<div class="extension-btn" ng-show="showIdentifierVerificationButton(identifier.identifierType.name,identifier.registrationNumber)">
<span ng-repeat="extButton in getExtButtons(identifier.identifierType.name)">
<span> {{:: extButton.link}} </span>
<button type="button"
ng-click="openIdentifierPopup(identifier.identifierType.name, extButton.action)">{{:: extButton.display}}
</button>
</span>
</div>
</div>

<div class="field-value field-value-has-identifier" ng-show="::identifier.hasIdentifierSources()">
<input type="text" id="registrationNumber" ng-model="identifier.registrationNumber"
non-blank="identifier.isIdentifierRequired()" pattern-validate
ng-change="identifier.generate()" focus-on="identifier.hasOldIdentifier"
ng-show="identifier.hasOldIdentifier || !identifier.hasIdentifierSources()"
ng-disabled="readOnlyExtraIdentifiers.indexOf(identifier.identifierType.name)>-1">

<div class="fl">
<div class="field-attribute hasOldIdentifier-field-attribute">
<label for="hasOldIdentifier" ng-show="::showEnterID" class="control-label">{{::'REGISTRATION_LABEL_ENTER_ID' |
translate}}</label>
</div>
<div class="field-value">
<input class="input-label-inline" ng-show="::showEnterID" type="checkbox"
id="hasOldIdentifier" ng-model="identifier.hasOldIdentifier"
ng-change="identifier.clearRegistrationNumber()">
</div>
</div>
</div>
</article>
</div>
</section>
<extra-patient-identifiers field-validation="::fieldValidation" patient="patient"></extra-patient-identifiers>
<div class="identifier-ui" ng-hide="!showExtIframe">
<div class="identifier-iframe">
<span class="close" ng-click="closeIdentifierPopup()">&times;</span>
Expand Down Expand Up @@ -310,4 +227,4 @@
<ng-include src="'views/patientDeathInformation.html'"></ng-include>
</section>
</div>
</div>
</div>