Skip to content

adminui-crud extend suggestions  #7

@yudin-s

Description

@yudin-s

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions