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

make generateInfantPTrackerId defensive #1685

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"resolutions": {
"@carbon/react": "1.17.0",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5"
"@types/react-dom": "^18.0.5",
"@openmrs/openmrs-form-engine-lib": "portal:/Users/hero/Documents/GitHub/openmrs-form-engine-lib"
},
"packageManager": "[email protected]"
}
29 changes: 21 additions & 8 deletions packages/esm-ohri-pmtct-app/src/utils/ptracker-forms-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
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;
};
): string => {
try {
if (typeof fieldId !== 'string' || typeof motherPtrackerId !== 'string') {
throw new Error('Invalid input types');
}

if (fieldId === "infantPtrackerid") {
return motherPtrackerId + "1";
} else if (fieldId.includes("_")) {
const position = fieldId.split("_")[1];
if (position && !isNaN(Number(position))) {
return motherPtrackerId.concat(position);
}
}

return;;
} catch (error) {
return;;
}
};

9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4091,9 +4091,9 @@ __metadata:
languageName: node
linkType: hard

"@openmrs/openmrs-form-engine-lib@npm:next":
version: 1.0.0-pre.446
resolution: "@openmrs/openmrs-form-engine-lib@npm:1.0.0-pre.446"
"@openmrs/openmrs-form-engine-lib@portal:/Users/hero/Documents/GitHub/openmrs-form-engine-lib::locator=%40ohri%2Fopenmrs-esm-ohri%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@openmrs/openmrs-form-engine-lib@portal:/Users/hero/Documents/GitHub/openmrs-form-engine-lib::locator=%40ohri%2Fopenmrs-esm-ohri%40workspace%3A."
dependencies:
ace-builds: ^1.4.12
enzyme: ^3.11.0
Expand All @@ -4116,9 +4116,8 @@ __metadata:
react: ^18.2.0
react-i18next: 11.x
rxjs: 6.x
checksum: a7f375d49778515a646429288d4515efc4af62e6c0e284162d8d657fc9e3d4a302f6bcc56d7f7b387c1da3baddf6dde8bf0b41a5d0968f1fd2f4dcf168cce856
languageName: node
linkType: hard
linkType: soft

"@openmrs/webpack-config@npm:5.1.1-pre.1031":
version: 5.1.1-pre.1031
Expand Down
Loading