Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: better-care/better-ui-components
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: crs4/aqlbetter
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 14 commits
  • 29 files changed
  • 1 contributor

Commits on Sep 3, 2024

  1. First working release

    sasurfer committed Sep 3, 2024
    Copy the full SHA
    7de5da5 View commit details
  2. Copy the full SHA
    46636af View commit details

Commits on Sep 4, 2024

  1. Copy the full SHA
    9a303f2 View commit details

Commits on Sep 9, 2024

  1. Copy the full SHA
    0d24056 View commit details

Commits on Sep 10, 2024

  1. README updated

    sasurfer committed Sep 10, 2024
    Copy the full SHA
    70bc859 View commit details

Commits on Feb 19, 2025

  1. Added acknowledgments

    sasurfer committed Feb 19, 2025
    Copy the full SHA
    d448480 View commit details

Commits on Feb 20, 2025

  1. Update README.md

    sasurfer authored Feb 20, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a225a1e View commit details
  2. Merge pull request #1 from crs4/master

    Update README.md
    sasurfer authored Feb 20, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ee91b3a View commit details

Commits on Feb 24, 2025

  1. Update README.md

    sasurfer authored Feb 24, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    aa1b6ba View commit details
  2. Copy the full SHA
    baf8887 View commit details
  3. fixed typo in README

    sasurfer committed Feb 24, 2025
    Copy the full SHA
    cc96495 View commit details

Commits on Feb 25, 2025

  1. Version for EHRBase>2.14.0

    sasurfer committed Feb 25, 2025
    Copy the full SHA
    89ba646 View commit details
  2. Copy the full SHA
    e78e5ea View commit details
  3. Copy the full SHA
    e560006 View commit details
Showing with 18,636 additions and 13,320 deletions.
  1. +303 −0 README.md
  2. +2 −1 angular.json
  3. +17,491 −13,176 package-lock.json
  4. +1 −1 package.json
  5. +2 −2 projects/aql-builder/e2e/protractor.conf.js
  6. +0 −1 projects/aql-builder/src/app/aql-builder/editor/editor-tabs/editor-tabs.component.html
  7. +1 −1 projects/aql-builder/src/app/aql-builder/editor/editor-tabs/editor-tabs.component.ts
  8. +23 −5 projects/aql-builder/src/app/aql-builder/editor/editor.component.ts
  9. +12 −9 ...aql-builder/src/app/aql-builder/editor/sidebar-content-panel/sidebar-content-panel.component.html
  10. +29 −5 ...s/aql-builder/src/app/aql-builder/editor/sidebar-content-panel/sidebar-content-panel.component.ts
  11. +2 −1 projects/aql-builder/src/app/aql-builder/monaco/monaco-autocomplete.helper.ts
  12. +1 −1 projects/aql-builder/src/app/aql-builder/save/save.component.html
  13. +49 −12 projects/aql-builder/src/app/aql-builder/save/save.component.ts
  14. +18 −2 projects/aql-builder/src/app/core/app-context.service.ts
  15. +2 −1 projects/aql-builder/src/app/core/aql-template-tree.service.ts
  16. +42 −2 projects/aql-builder/src/app/core/code-snippet.service.ts
  17. +272 −28 projects/aql-builder/src/app/core/ehr-api.service.ts
  18. +4 −0 projects/aql-builder/src/app/core/token.interceptor.ts
  19. +96 −24 projects/aql-builder/src/app/domain-select/domain-select.component.html
  20. +43 −4 projects/aql-builder/src/app/domain-select/domain-select.component.ts
  21. +1 −1 projects/aql-builder/src/app/navbar/import/import.component.ts
  22. +20 −8 projects/aql-builder/src/app/shared/models/ehr-view.model.ts
  23. +29 −12 projects/aql-builder/src/app/shared/models/template/template.model.ts
  24. +1 −0 projects/aql-builder/src/assets/i18n/aql-builder/en.json
  25. +126 −22 projects/aql-builder/src/assets/logos/logo-aql-app.svg
  26. +23 −0 projects/aql-builder/src/environments/environment.prod.ts.BASICAUTH
  27. +29 −0 projects/aql-builder/src/environments/environment.prod.ts.OAUTH2
  28. +1 −1 projects/aql-builder/src/index.html
  29. +13 −0 projects/aql-builder/src/proxy.conf.json
303 changes: 303 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,306 @@
# AQL BUILDER WRITTEN BY BETTER AND ADAPTED BY SASURFER (@GITHUB)
_WARNING: for EHRBase versions < 2.5.0 use release 1.0.0. Use latest version for EHRBase version >= 2.14.0 . No version available for 2.5.0<= EHRBase version<2.14.0__

This sofware helps in building openEHR aql queries. It needs a running instance of EHRBase in order to work. Its main capabilities are: creating the query with autocompletion and template visualization, saving queries on the running instance of EHRBase (called views) or locally (called snippets), performing queries, retrieving and showing the results, importing (writing into EHRBase) templates. More info at [aql builder site]( https://docs.better.care/studio/aql-builder/overview ).

At login are asked: Username, Password, Platform URL. If oauth2 is configured (see below on how to do it) then the client_secret is also requested. The platform URL has the form http://{yourehrbaseservername}:{yourehrbaseserverport}/ehrbase

NOTE: It is necessary to login with the EHRBase admin credentials to let all template and views methods work as intended.

Example of values for the default credentials:
- Username: ehrbase-admin
- Password: EvenMoreSecretPassword
- Platform URL: http://localhost:8080/ehrbase


## INSTALL LOCALLY
Conda is optional. You can install with or without it.

Clone the repository:
```
git clone https://github.com/sasurfer/aqlbetter.git
```
creates, optionally, a conda environment and install nodejs and run install and build scripts:
```
cd aqlbetter
conda create --name aqlbetter
conda activate aqlbetter
conda install -c conda-forge nodejs
npm install -g @angular/cli@10.1.0
cd projects/aql-builder/
npm install --save-dev @angular-devkit/build-angular --force
export NODE_OPTIONS=--openssl-legacy-provider
ng build aql-builder --prod
```

## COMMON CONFIGURATION
Modify 'localhost:8080' in projects/aql-builder/src/proxy.conf.json with {youehrbaseservername}:{yourehrbaseserverport}.
This step, though optional, ensures that the app uses the EHRBase nodename, e.g., local.ehrbase.org, to create the full name for the queries. If the server in proxy is not recognized a default nodename will be used instead.

## RUN WITH BASIC AUTH

### EHRBASE CONFIGURATION
In the EHRBase directory creates two files: .env.ehrbase and docker-compose.yml

This is an example of .env.ehrbase (read by docker-compose.yaml):
```
SERVER_NODENAME=local.ehrbase.org
SECURITY_AUTHTYPE=BASIC
SECURITY_AUTHUSER=ehrbase-user
SECURITY_AUTHPASSWORD=SuperSecretPassword
SECURITY_AUTHADMINUSER=ehrbase-admin
SECURITY_AUTHADMINPASSWORD=EvenMoreSecretPassword
SECURITY_OAUTH2USERROLE=USER
SECURITY_OAUTH2ADMINROLE=ADMIN
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI=
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE=env,health,info,metrics,prometheus
MANAGEMENT_ENDPOINTS_WEB_BASEPATH=/management
MANAGEMENT_ENDPOINT_ENV_ENABLED=true
MANAGEMENT_ENDPOINT_HEALTH_ENABLED=true
MANAGEMENT_ENDPOINT_HEALTH_DATASOURCE_ENABLED=true
MANAGEMENT_ENDPOINT_INFO_ENABLED=true
MANAGEMENT_ENDPOINT_METRICS_ENABLED=true
MANAGEMENT_ENDPOINT_PROMETHEUS_ENABLED=FALSE
MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
MANAGEMENT_ENDPOINT_ENV_SHOWVALUES=ALWAYS
SYSTEM_ALLOW_TEMPLATE_OVERWRITE=true
EHRBASE_TEMPLATE_ALLOW_OVERWRITE=true
ADMIN_API_ACTIVE=true
CACHE_ENABLED=true
ADMINAPI_ALLOWDELETEALL=true
WEB_CORS_ALLOWEDORIGINS=http://localhost:4201
WEB_CORS_ALLOWEDORIGINPATTERNS=http://*.localhost:4201
WEB_CORS_ALLOWEDMETHODS=GET,PUT,DELETE,POST,OPTIONS,HEAD
WEB_CORS_ALLOWCREDENTIALS=true
WEB_CORS_ALLOWEDHEADERS=*
```
and the related docker-compose.yml:
```
version: '3'
#
# Minimal setup for a running EHRbase. Contains the server component as well as the required postgres instance.
#
services:
#
# EHRBase container. see `.env.ehrbase` for configuration details.
#
ehrbase:
image: ${EHRBASE_IMAGE:-ehrbase/ehrbase:2.15.0}
env_file:
- .env.ehrbase
environment:
DB_URL: jdbc:postgresql://ehrdb:5432/ehrbase
DB_USER_ADMIN: ehrbase
DB_PASS_ADMIN: ehrbase
DB_USER: ehrbase_restricted
DB_PASS: ehrbase_restricted
links:
- ehrdb
depends_on:
ehrdb:
condition: service_healthy
ports:
- "8080:8080"
networks:
- ehrbase-net
#
# Pre-configured ehrbase postgres.
#
ehrdb:
image: ${EHRBASE_POSTGRES_IMAGE:-ehrbase/ehrbase-v2-postgres:16.2}
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
EHRBASE_USER_ADMIN: ehrbase
EHRBASE_PASSWORD_ADMIN: ehrbase
EHRBASE_USER: ehrbase_restricted
EHRBASE_PASSWORD: ehrbase_restricted
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 12
ports:
- "5432:5432"
networks:
- ehrbase-net
volumes:
- ./.pgdata:/var/lib/postgresql/data
networks:
ehrbase-net: { }
```
Start the services:
```
docker compose up
```
### AQLBETTER CONFIGURATION
Make sure to use {aqlbetter_dir}/projects/aql-builder/src/environments/environment.prod.ts.BASICAUTH
From the dir {aqlbetter_dir}/projects/aql-builder:
```
cp ./src/environments/environment.prod.ts.BASICAUTH ./src/environments/environment.prod.ts
```
Remember to rerun the build step:
```
ng build aql-builder --prod
```
### RUN
Run with:
```
ng serve aql-builder --port 4201
```
Open a browser tab to localhost:4201, fill the credentials and click "Start querying data".

## OAUTH2
### EHRBASE CONFIGURATION
Create a directory for EHRBase and copy the following two example files.

This is an example of .env.ehrbase (read by docker compose yaml):
```
SERVER_NODENAME=local.ehrbase.org
SECURITY_AUTHTYPE=OAUTH
SECURITY_AUTHUSER=ehrbase-user
SECURITY_AUTHPASSWORD=SuperSecretPassword
SECURITY_AUTHADMINUSER=ehrbase-admin
SECURITY_AUTHADMINPASSWORD=EvenMoreSecretPassword
SECURITY_OAUTH2USERROLE=USER
SECURITY_OAUTH2ADMINROLE=ADMIN
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI=http://172.31.0.2:8080/auth/realms/ehrbase
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE=env,health,info,metrics,prometheus
MANAGEMENT_ENDPOINTS_WEB_BASEPATH=/management
MANAGEMENT_ENDPOINT_ENV_ENABLED=true
MANAGEMENT_ENDPOINT_HEALTH_ENABLED=true
MANAGEMENT_ENDPOINT_HEALTH_DATASOURCE_ENABLED=true
MANAGEMENT_ENDPOINT_INFO_ENABLED=true
MANAGEMENT_ENDPOINT_METRICS_ENABLED=true
MANAGEMENT_ENDPOINT_PROMETHEUS_ENABLED=FALSE
MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=true
MANAGEMENT_ENDPOINT_ENV_SHOWVALUES=ALWAYS
SYSTEM_ALLOW_TEMPLATE_OVERWRITE=true
ADMIN_API_ACTIVE=true
CACHE_ENABLED=true
ADMINAPI_ALLOWDELETEALL=true
WEB_CORS_ALLOWEDORIGINS=http://localhost:4201
WEB_CORS_ALLOWEDORIGINPATTERNS=http://*.localhost:4201
WEB_CORS_ALLOWEDMETHODS=GET,PUT,DELETE,POST,OPTIONS,HEAD
WEB_CORS_ALLOWCREDENTIALS=true
WEB_CORS_ALLOWEDHEADERS=*
```
and the docker-compose.yml:
```
version: '3'
#
# Minimal setup for a running EHRbase. Contains the server component as well as the required postgres instance.
#
services:
#
# EHRBase container. see `.env.ehrbase` for configuration details.
#
ehrbase:
image: ${EHRBASE_IMAGE:-ehrbase/ehrbase:2.6.0}
env_file:
- .env.ehrbase
environment:
DB_URL: jdbc:postgresql://ehrdb:5432/ehrbase
DB_USER_ADMIN: ehrbase
DB_PASS_ADMIN: ehrbase
DB_USER: ehrbase_restricted
DB_PASS: ehrbase_restricted
links:
- ehrdb
- keycloak3
depends_on:
ehrdb:
condition: service_healthy
keycloak3:
condition: service_started
ports:
- "8080:8080"
networks:
- ehrbase-net
#
# Pre-configured ehrbase postgres.
#
ehrdb:
image: ${EHRBASE_POSTGRES_IMAGE:-ehrbase/ehrbase-v2-postgres:16.2}
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
EHRBASE_USER_ADMIN: ehrbase
EHRBASE_PASSWORD_ADMIN: ehrbase
EHRBASE_USER: ehrbase_restricted
EHRBASE_PASSWORD: ehrbase_restricted
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 5s
timeout: 5s
retries: 12
ports:
- "5432:5432"
networks:
- ehrbase-net
volumes:
- ./.pgdata:/var/lib/postgresql/data
keycloak3:
image: quay.io/keycloak/keycloak:24.0.3
#image: registry.vitasystems.dev/docker-registry/keycloak-x:0.9.9
container_name: keycloak3
command: "start-dev --import-realm"
ports:
- "8081:8080"
environment:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
KC_HTTP_RELATIVE_PATH: /auth
KC_HTTP_PORT: 8080
volumes:
- ./tests/keycloak/import:/opt/keycloak/data/import
networks:
- ehrbase-net
networks:
ehrbase-net: { }
```
from the latest https://github.com/ehrbase/ehrbase.git copy the path to the file (included) tests/keycloak/import/ehrbase-realm-exported.json to this directory.

Modify the SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI server and port with your keycloak ip and port.

Start the services:
```
docker compose up
```

### AQLBETTER CONFIGURATION
Use {aqlbetter_dir}/projects/aql-builder/src/environments/environment.prod.ts.OAUTH2 and modify the authorizationUrl according to your installation of keycloak. Remember that the address (server:port) must be the same as the one given in SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI in the EHRBase settings (172.31.0.2:8080 in the example).
Rerun the build step:
```
ng build aql-builder --prod
```
### KEYCLOAK
Open a browser tab to localhost:8081/auth/admin and login to keycloak (admin/admin). Create, inside the ehrbase realm, a client named aqlbetter with client_id=aqlbetter, the urls set to http://localhost:4201 and Authentication and OAuth 2.0 Device Authorization Grant flagged on, choose client_id and client_secret as credentials and copy the newly created client_secret. Reset the ehrbase-admin password and copy it. client_secret and password for ehrbase-admin will be needed for the login form.

### RUN
Run with:
```
ng serve aql-builder --port 4201 --prod
```
Open a browser tab to localhost:4201, fill the credentials and click "Start querying data".

## Acknowledgments
This work has been partially funded by the following sources:
<li>“Total Patient Management” (ToPMa) project (grant by the Sardinian Regional Authority, grant number RC_CRP_077);</li>
<li>the “Processing, Analysis, Exploration, and Sharing of Big and/or Complex Data” (XDATA) project (grant by the Sardinian Regional Authority).
</li><ul>

# ORIGINAL README FROM BETTER FOLLOWS

# Better UI components

![Lint all packages](https://github.com/better-care/better-ui-components/workflows/Lint%20all%20packages/badge.svg)
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
@@ -274,7 +274,8 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "aql-builder:build"
"browserTarget": "aql-builder:build",
"proxyConfig": "projects/aql-builder/src/proxy.conf.json"
},
"configurations": {
"production": {
Loading