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

(feat): support for historical expressions #185

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.d.ts
**/node_modules/**/*
35 changes: 0 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,38 +104,3 @@ jobs:
- run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

bump-form-engine_ohri:
runs-on: ubuntu-latest

needs: pre_release

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: UCSF-IGHS/openmrs-esm-ohri
ref: dev

- name: Install dependencies
run: yarn

- name: Bump form engine
run: yarn ci:bump-form-engine-lib

- name: Commit changes
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
git add yarn.lock
git commit -m "(chore) bump-form-engine"

- name: Create PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ACTIONS_OHRI_PAT }}
commit-message: "(chore) Bump `@openmrs/openmrs-form-engine-lib`"
title: "(chore) Bump `@openmrs/openmrs-form-engine-lib`"
body: "This is an automated PR that bumps the [form engine library](https://github.com/openmrs/openmrs-form-engine-lib) to the newest available version tagged `next`."
branch: chore/bump-form-engine
base: dev
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dist/
node_modules/
**/*.md
**/*.json
**/*.yml
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div id="top"></div>

:wave: *New to O3? Be sure to review the [OpenMRS 3 Frontend Developer Documentation](https://openmrs.github.io/openmrs-esm-core/#/). You may find the [Map of the Project](https://openmrs.github.io/openmrs-esm-core/#/main/map) especially helpful.* :teacher:
:wave: *New to O3? Be sure to review the [OpenMRS 3 Frontend Developer Documentation](https://openmrs.github.io/openmrs-esm-core/#/). You may find the [Map of the Project](https://openmrs.github.io/openmrs-esm-core/#/main/map) especially helpful.* :teacher:

[![Form-engine-CI](https://github.com/UCSF-IGHS/openmrs-ohri-form-engine-lib/actions/workflows/node.js.yml/badge.svg)](https://github.com/UCSF-IGHS/openmrs-ohri-form-engine-lib/actions/workflows/node.js.yml)

# OpenMRS Form Engine

Expand Down Expand Up @@ -48,10 +47,10 @@ yarn add @openmrs/openmrs-form-engine-lib@latest

### Local Development

#### Install Dependencies
#### Install Dependencies

```bash
yarn
yarn
```

#### Build the library
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/forms/omrs-forms/component_art.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/forms/omrs-forms/component_preclinic-review.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand Down
12 changes: 6 additions & 6 deletions __mocks__/forms/omrs-forms/demo_hts-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand All @@ -34,17 +34,17 @@
"links": [
{
"rel": "value",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0/value",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0/value",
"resourceAlias": "resource"
},
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0",
"resourceAlias": "resource"
},
{
"rel": "full",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0?v=full",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55/resource/f12989b8-b8cb-47a2-b115-24a7ebe6d7f0?v=full",
"resourceAlias": "resource"
}
],
Expand All @@ -54,9 +54,9 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/form/955ab92f-f93e-4dc0-9c68-b7b2346def55",
"resourceAlias": "form"
}
],
"resourceVersion": "1.9"
}
}
2 changes: 1 addition & 1 deletion __mocks__/forms/omrs-forms/form-component.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand Down
4 changes: 2 additions & 2 deletions __mocks__/forms/omrs-forms/nested-form1.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand All @@ -35,4 +35,4 @@
}
],
"resourceVersion": "1.9"
}
}
4 changes: 2 additions & 2 deletions __mocks__/forms/omrs-forms/nested-form2.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"links": [
{
"rel": "self",
"uri": "http://ohri-demo.globalhealthapp.net/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"uri": "https://dev3.openmrs.org/openmrs/ws/rest/v1/user/82f18b44-6814-11e8-923f-e9a88dcb533f",
"resourceAlias": "user"
}
]
Expand All @@ -35,4 +35,4 @@
}
],
"resourceVersion": "1.9"
}
}
74 changes: 74 additions & 0 deletions __mocks__/forms/rfe-forms/multi-select-form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "Multi select form",
"pages": [
{
"label": "One",
"sections": [
{
"label": "Section One",
"isExpanded": "true",
"questions": [
{
"label": "Patient covered by NHIF:",
"id": "nhif",
"questionOptions": {
"rendering": "select",
"concept": "0b49e3e6-55df-4096-93ca-59edadb74b3f",
"answers": [
{
"concept": "8b715fed-97f6-4e38-8f6a-c167a42f8923",
"label": "Yes"
},
{
"concept": "a899e0ac-1350-11df-a1f1-0026b9348838",
"label": "No"
}
]
},
"type": "obs",
"validators": []
},
{
"label": "Was this visit scheduled?",
"type": "obs",
"required": false,
"id": "scheduledVisit",
"questionOptions": {
"rendering": "checkbox",
"concept": "a89ff9a6-1350-11df-a1f1-0026b9348838",
"answers": [
{
"concept": "a89b6440-1350-11df-a1f1-0026b9348838",
"label": "Scheduled visit",
"disable": {
"disableWhenExpression": "sex !== 'F'"
}
},
{
"concept": "a89ff816-1350-11df-a1f1-0026b9348838",
"label": "Unscheduled visit early",
"disable": {
"disableWhenExpression": "nhif !== '8b715fed-97f6-4e38-8f6a-c167a42f8923'"
}
},
{
"concept": "a89ff8de-1350-11df-a1f1-0026b9348838",
"label": "Unscheduled visit late"
}
]
},
"inlineRendering": null,
"isHidden": false
}
]
}
]
}
],
"processor": "EncounterFormProcessor",
"encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
"referencedForms": [],
"uuid": "0859d9ad-2ed4-48db-96eb-7b0ce0c9903e",
"description": "A form containing most fields, to be used for testing purposes",
"version": "1.0"
}
12 changes: 6 additions & 6 deletions __mocks__/react-i18next.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const React = require('react');
const reactI18next = require('react-i18next');

const hasChildren = node => node && (node.children || (node.props && node.props.children));
const hasChildren = (node) => node && (node.children || (node.props && node.props.children));

const getChildren = node => (node && node.children ? node.children : node.props && node.props.children);
const getChildren = (node) => (node && node.children ? node.children : node.props && node.props.children);

const renderNodes = reactNodes => {
const renderNodes = (reactNodes) => {
if (typeof reactNodes === 'string') {
return reactNodes;
}
Expand All @@ -29,18 +29,18 @@ const renderNodes = reactNodes => {
});
};

const useMock = [k => k, {}];
const useMock = [(k) => k, {}];
useMock.t = (key, defaultValue) => defaultValue || key;
useMock.i18n = {};

module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
Trans: ({ children }) => renderNodes(children),
Translation: ({ children }) => children(k => k, { i18n: {} }),
Translation: ({ children }) => children((k) => k, { i18n: {} }),
useTranslation: () => useMock,

// mock if needed
I18nextProvider: reactI18next.I18nextProvider,
I18nextProvider: jest.fn().mockImplementation(({ children }) => children),
initReactI18next: reactI18next.initReactI18next,
setDefaults: reactI18next.setDefaults,
getDefaults: reactI18next.getDefaults,
Expand Down
26 changes: 13 additions & 13 deletions __mocks__/use-initial-values/encounter.mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@
"voided": false,
"value": "Mother is in perfect condition",
"valueModifier": null,
"formFieldPath": "ohri-forms-notes",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-notes",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -329,8 +329,8 @@
"voided": false,
"value": "2023-07-24T00:00:00.000+0000",
"valueModifier": null,
"formFieldPath": "ohri-forms-date_of_birth",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-date_of_birth",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -414,8 +414,8 @@
"voided": false,
"value": "TBD",
"valueModifier": null,
"formFieldPath": "ohri-forms-infant_name",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-infant_name",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -575,8 +575,8 @@
"voided": false,
"value": " TDB II",
"valueModifier": null,
"formFieldPath": "ohri-forms-infant_name_2",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-infant_name_2",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -660,8 +660,8 @@
"voided": false,
"value": "2023-07-24T00:00:00.000+0000",
"valueModifier": null,
"formFieldPath": "ohri-forms-date_of_birth_2",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-date_of_birth_2",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -781,8 +781,8 @@
"voided": false,
"value": 2,
"valueModifier": null,
"formFieldPath": "ohri-forms-number_of_babies",
"formFieldNamespace": "ohri-forms",
"formFieldPath": "rfe-forms-number_of_babies",
"formFieldNamespace": "rfe-forms",
"status": "FINAL",
"interpretation": null,
"links": [
Expand Down Expand Up @@ -864,4 +864,4 @@
}
],
"resourceVersion": "2.2"
}
}
Loading
Loading