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) O3-3818 Add support for other form workspaces #2018

Merged
merged 2 commits into from
Sep 25, 2024
Merged
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
30 changes: 26 additions & 4 deletions packages/esm-patient-common-lib/src/form-entry-interop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { launchPatientWorkspace, launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';

export const clinicalFormsWorkspace = 'clinical-forms-workspace';
export const formEntryWorkspace = 'patient-form-entry-workspace';
export const htmlFormEntryWorkspace = 'patient-html-form-entry-workspace';

interface HtmlFormEntryForm {
formUuid: string;
formName: string;
Expand All @@ -19,12 +23,15 @@ export function launchFormEntryOrHtmlForms(
visitStartDatetime?: string,
visitStopDatetime?: string,
mutateForms?: () => void,
clinicalFormsWorkspaceName = clinicalFormsWorkspace,
formEntryWorkspaceName = formEntryWorkspace,
htmlFormEntryWorkspaceName = htmlFormEntryWorkspace,
) {
if (visitUuid) {
const htmlForm = htmlFormEntryForms.find((form) => form.formUuid === formUuid);

if (htmlForm) {
launchHtmlFormEntry(formName, encounterUuid, visitUuid, htmlForm);
launchHtmlFormEntry(patientUuid, formName, encounterUuid, visitUuid, htmlForm, htmlFormEntryWorkspaceName);
} else {
launchFormEntry(
formUuid,
Expand All @@ -37,6 +44,8 @@ export function launchFormEntryOrHtmlForms(
visitStopDatetime,
htmlForm,
mutateForms,
clinicalFormsWorkspaceName,
formEntryWorkspaceName,
);
}
} else {
Expand All @@ -55,9 +64,14 @@ export function launchFormEntry(
visitStopDatetime?: string,
htmlForm?: HtmlFormEntryForm,
mutateForm?: () => void,
clinicalFormsWorkspaceName = clinicalFormsWorkspace,
formEntryWorkspaceName = formEntryWorkspace,
) {
launchPatientWorkspace('patient-form-entry-workspace', {
launchPatientWorkspace(formEntryWorkspaceName, {
workspaceTitle: formName,
clinicalFormsWorkspaceName,
formEntryWorkspaceName,
patientUuid,
mutateForm,
formInfo: {
encounterUuid,
Expand All @@ -72,9 +86,17 @@ export function launchFormEntry(
});
}

export function launchHtmlFormEntry(formName, encounterUuid, visitUuid, htmlForm) {
launchPatientWorkspace('patient-html-form-entry-workspace', {
export function launchHtmlFormEntry(
patientUuid: string,
formName: string,
encounterUuid: string,
visitUuid: string,
htmlForm: HtmlFormEntryForm,
workspaceName = htmlFormEntryWorkspace,
) {
launchPatientWorkspace(workspaceName, {
workspaceTitle: formName,
patientUuid,
formInfo: {
encounterUuid,
visitUuid,
Expand Down