(feat) : Add patient identifier validation directive#158
(feat) : Add patient identifier validation directive#158donaldkibet wants to merge 1 commit intomainfrom
Conversation
afcf39e to
a1d7094
Compare
|
Thanks, @donaldkibet |
|
|
||
| private validateIdentifier(identifier: string): Observable<any> { | ||
| // For testing purposes, change openmrsBase to the OpenMRS server you are using | ||
| const baseUrl = window?.['openmrsBase'] + '/ws/rest/v1' + '/'; |
There was a problem hiding this comment.
Why are we concatenating /ws/rest/v1 with / here? These feel like they could be used elsewhere.
There was a problem hiding this comment.
(I don't think there's any reason you can't rely on the framework constants here).
| const baseUrl = window?.['openmrsBase'] + '/ws/rest/v1' + '/'; | ||
| const apiUrl = `${baseUrl}patient`; | ||
|
|
||
| const params = new HttpParams().set('q', identifier); |
There was a problem hiding this comment.
I don't love this mechanism for checking if an ID is duplicated. We really need to use information about the type of identifier being configured. Specifically, OpenMRS IDs, depending on identifier type can be:
- Unique
- Unique per location
- Allow duplicates
There was a problem hiding this comment.
I think doing this is a great idea, but rather than doing some query of the backend, we should just add a backend endpoint that can tell us if a specified identifier is valid for an identifier type. That also allows us to check other validation constraints that this mechanism can't support. It wouldn't be too hard to write a REST endpoint that takes a (potential) identifier and identifier type and runs the validation and returns any errors that occur.
|
Also, we need a ticket documenting this change, please. |
Requirements
Summary
This PR adds an asynchronous patient identifier validator, which validates whether the captured patient identifier has been assigned to another patient. The aim is to perform validation while capturing form fields instead of when doing submission. This validation directive works on text input control
Sample form schema
{ "label": "Patient Identifier", "isExpanded": "true", "questions": [ { "label": "Unique Patient Number", "id": "uniquePatientNumber", "questionOptions": { "rendering": "text", "identifierType": "dfacd928-0370-4315-99d7-6ec1c9f7ae76" }, "type": "patientIdentifier", "validators": [] } ] }Screenshots
Related Issue
Other