ehr_emulator v1.0.5
EHR Emulator package
Requirements
- NodeJS via nvm
- MacOs (ARM)
- Current build of the emulator is compatible with macOS only. Windows is currently still in development.
Node Version
Make sure you are on the correct node and npm version. This project keeps an .nvmrc
file in the root to help developers switch versions more easily. See this section of the nvm docs for more information on using it. The node and npm versions are also tracked in package.json
in the engines
field.
Note: When updating node and npm versions, we need to keep the following in sync: .nvmrc
and package.json
engines.
Installation
# with npm
npm install ehr_emulator
# with yarn
yarn add ehr_emulator
Usage
Once emulator package is installed follow the below directions.
Create Configuration Directory
Inside the src directory create a directory labeled emulator and create the base emulator file.
src/emulator/index.ts
// import the start command for the emulator
import { start } from "ehr_emulator";
start()
.then((response) => {
// any code you would like to run once emulator is live
// this is where you can also add additonal URLOverrides if needed
})
.catch((error) => {
console.log(error);
// handle errors as you wish for the emulator start sequence
});
Add the following script to your package.json to start the emulator.
NOTE: This script can be altered as you wish this is just a base example.
package.json
{
"scripts": {
"start:emulator": "npx ts-node src/emulator/index.ts"
}
}
Adding Url Overrides
Inside the emulator directory create an overrides.config.ts
.
overrides.config.ts
// import the override class
import { UrlOverrider } from "ehr_emulator";
// register your url to be overriden
UrlOverrider.register({
url: "/test",
title: "Test Override",
active_response: 0,
response_options: [
{
title: "Success Test",
status: 200,
method: "get",
response: {
message: "success",
},
},
],
})
NOTE: You can place as many registers as you wish in a single file, and they can be chained as so
UrlOverrider.register({}).register({})
Update emulator to use new overrides
Overrides must be sent to emulator once it has been started.
src/emulator/index.ts
// Bring in the override class
import { UrlOverrider, start } from "ehr_emulator";
// import the overrides config file
import "./overrides.config";
// NOTE: you can include as many as you wish and give them easier names to leverage
// import "./patient.overrrides.config"
start()
.then((response) => {
console.log("=== started app ===");
// activate the sendToEmulator method
UrlOverrider.sendToEmulator();
})
.catch((error) => {
console.log(error);
});