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

adminui-crud extend suggestions #7

Open
yudin-s opened this issue Jul 7, 2020 · 0 comments
Open

adminui-crud extend suggestions #7

yudin-s opened this issue Jul 7, 2020 · 0 comments

Comments

@yudin-s
Copy link

yudin-s commented Jul 7, 2020

With next iteration of the development process, I’ve discovered things that can be improved.

Right now we are assembly any CRUD tables using crud_assembly functions from the adminui-crud.js. We cannot edit this function so when we need to add filtering by the patient_id we need to override hook retrieveRecordSummary , copy/paste whole code what is make re-render of the DataTable when data is retrieved and add only 5 new lines:

if (context.selectedPatient ) {
if (context.selectedPatient.id !== record.patient_id) {
return true; // SKIP BY FILTER
}
}

For save hook situation are the same: if patient are selected we must add «patient_id» automatically so what we can do:

We are override save hook inside of adminui-button and put thee new lines. Whole code with save process must be copy/pasted from the adminui-crud.js:

if (_this.context.selectedPatient) {
params.patient_id = _this.context.selectedPatient.id;
}

You can see this on www/pt-wc-q/js/extended/events.js file what is sended to PR

But this way looks very bad: each CRUD what placed inside of the exists platform: vitals, events, medications, adverse_events need be extended with this copy/paste code.

Every time we are calling QEWD.reply to send queries inside of JSDB.
My suggestion is to provide callback wrapper based on middleware patterns for preprocess data. On architecture basics that will look like:

[Server] <-> [QEWD.reply <-> filters chain callbacks with data processing <-> reply promise resolve ] -> Send filtered and processed data outside to hooks

Middleware QEWD response can be attached in app.js like we attach context things now. That will provide to us solution that can extend behaviour of data communications without changing lot files. Only by one function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant