https://github.com/dipsas/ehrcraft-form-api
A typescript definition of the JavaScript API used in DIPS Forms
https://github.com/dipsas/ehrcraft-form-api
Last synced: 2 months ago
JSON representation
A typescript definition of the JavaScript API used in DIPS Forms
- Host: GitHub
- URL: https://github.com/dipsas/ehrcraft-form-api
- Owner: DIPSAS
- License: mit
- Created: 2020-11-29T21:14:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-10T22:57:25.000Z (6 months ago)
- Last Synced: 2025-04-25T18:55:23.676Z (2 months ago)
- Language: TypeScript
- Size: 118 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EHR Craft Form
This is the definitions of the JS classes used within the EHR Craft Form renderer developed by DIPS AS. The purpose of this library is to be able to write form scripts using typed classes defined with Typescript.
Warning: The library is in early beta and intended for internal use.
## Versions
* 1.5.0 - Added callback on ctx
* 2.0.0 - Attribute names from upper camelcase to lower camelcase.
* 2.1.0 - Fixed attribute name value to lower case for DvBoolean.
* 2.3.x - Added support for terminology and system-configuration search
* 2.4.x - Added support for lab
* 2.5.x - Added support for api2
* 2.6.x - Added support for `OnClick` event for generic buttons## Usage
The script engine only runs vanilla JS, thus we need to remove the references to this library when running insinde the form renderer.
To generated vanilla JS from typescript we use the library and setup define by this Yeoman generator: https://www.npmjs.com/package/generator-ehrcraft-script
The following typescript is a boilerplate to get started.
```typescript
import { API, Container } from "ehrcraft-form-api/dist/api";
import { DvCodedText, DvDateTime, DvQuantity } from "ehrcraft-form-api";function main(api: API) {
console.log("Your main function was invoked");
const t = new DvCodedText();
t.Value = "Test";
}
// THIS method is invoked from the generated script by generator-ehrcraft-script
main(api);```
The example below illustrates the complete main function with all context objects injected. To make this work the following must be injected in the generated/compiled javascript: ```main(api,ctx,terminology,config);```
```typescript
import { API, CTX, SystemConfiguration, TerminologyService } from "ehrcraft-form-api";
const f_systolic = "";
export function main(api: API, ctx: CTX, term: TerminologyService, conf: SystemConfiguration){api.addListener(f_systolic, "OnChanged", (id, value, parent) => {
// do something when systolic is changed
});}
```