Skip to content

Commit

Permalink
(feat) registered a helper function to form engine, to auto generate … (
Browse files Browse the repository at this point in the history
#24)

* (feat) registered a helper function to form engine, to auto generate infant ptracker id

* fixed lint issues
  • Loading branch information
Herobiam authored Oct 10, 2023
1 parent 57c3090 commit c8df42b
Show file tree
Hide file tree
Showing 4 changed files with 1,950 additions and 1,806 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "src/index.ts",
"source": true,
"scripts": {
"start": "openmrs develop --backend https://ohri-namibia-dev.globalhealthapp.net",
"start": "openmrs develop --backend https://ohri-namibia-demo.globalhealthapp.net",
"serve": "webpack serve --mode=development",
"build": "webpack --mode production",
"analyze": "webpack --mode=production --env.analyze=true",
Expand Down Expand Up @@ -58,6 +58,7 @@
"devDependencies": {
"@ohri/openmrs-esm-ohri-commons-lib": "next",
"@openmrs/esm-framework": "next",
"@openmrs/openmrs-form-engine-lib": "next",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.6",
"@swc/jest": "^0.2.23",
Expand Down
11 changes: 11 additions & 0 deletions src/helpers/ptracker-form-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const generateInfantPTrackerId = (
fieldId: string,
motherPtrackerId: string
): string | undefined => {
if (!fieldId || !motherPtrackerId) return;
return fieldId === "infantPtrackerid"
? motherPtrackerId + "1"
: fieldId.includes("_")
? motherPtrackerId.concat(fieldId.split("_")[1])
: undefined;
};
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { getAsyncLifecycle, defineConfigSchema } from "@openmrs/esm-framework";
import { configSchema } from "./config-schema";
import { registerExpressionHelper } from "@openmrs/openmrs-form-engine-lib";
import { generateInfantPTrackerId } from "./helpers/ptracker-form-helpers";

require("./root.scss");

Expand All @@ -18,6 +20,10 @@ const options = {

export function startupApp() {
defineConfigSchema(moduleName, configSchema);
registerExpressionHelper(
"customGenerateInfantPTrackerId",
generateInfantPTrackerId
);
}

export const mnchClinicalDashboard = getAsyncLifecycle(
Expand Down
Loading

0 comments on commit c8df42b

Please sign in to comment.