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

in the OTZ Discontinuation form, does not save the correct data when … #1792

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/esm-patient-chart-app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export const moduleName = '@openmrs/esm-patient-chart-app';
export const patientChartWorkspaceSlot = 'patient-chart-workspace-slot';
export const patientChartWorkspaceHeaderSlot = 'patient-chart-workspace-header-slot';
export const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ';
export const otzUuid = '159836AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
export const otzOutPut = 'Opt out of OTZ';
Comment on lines +9 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this hard coded values. These should be provided by the config file

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { SkeletonText } from '@carbon/react';
import { useConfig } from '@openmrs/esm-framework';
import { type Observation } from '../visit.resource';
import styles from './styles.scss';
import { otzUuid, otzOutPut } from '../../../constants';

interface EncounterObservationsProps {
observations: Array<Observation>;
Expand All @@ -12,15 +13,22 @@ interface EncounterObservationsProps {
const EncounterObservations: React.FC<EncounterObservationsProps> = ({ observations }) => {
const { t } = useTranslation();
const { obsConceptUuidsToHide = [] } = useConfig();
const { obsConceptDisplayOverrides = { otzUuid: otzOutPut } } = useConfig();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { obsConceptDisplayOverrides = { otzUuid: otzOutPut } } = useConfig();
const { obsConceptDisplayOverrides = useConfig();

function getAnswerFromDisplay(display: string): string {
const colonIndex = display.indexOf(':');
if (colonIndex === -1) {
return '';
} else {
return display.substring(colonIndex + 1).trim();
}
}
const getAnswerFromDisplay = useMemo(() => {
return (display: string, conceptUuid: string): string => {
const colonIndex = display.indexOf(':');
if (colonIndex === -1) {
return '';
} else {
const displayValue = display.substring(colonIndex + 1).trim();
if (obsConceptDisplayOverrides[conceptUuid]) {
return obsConceptDisplayOverrides[conceptUuid];
}
return displayValue;
}
};
}, [obsConceptDisplayOverrides]);

if (!observations) {
return <SkeletonText />;
Expand All @@ -43,7 +51,7 @@ const EncounterObservations: React.FC<EncounterObservationsProps> = ({ observati
{obs.groupMembers.map((member) => (
<React.Fragment key={index}>
<span className={styles.childConcept}>{member.concept.display}</span>
<span>{getAnswerFromDisplay(member.display)}</span>
<span>{getAnswerFromDisplay(member.display, obs.value.uuid)}</span>
</React.Fragment>
))}
</React.Fragment>
Expand All @@ -52,20 +60,14 @@ const EncounterObservations: React.FC<EncounterObservationsProps> = ({ observati
return (
<React.Fragment key={index}>
<span>{obs.concept.display}</span>
<span>{getAnswerFromDisplay(obs.display)}</span>
<span>{getAnswerFromDisplay(obs.display, obs.value.uuid)}</span>
</React.Fragment>
);
}
})}
</div>
);
}

return (
<div className={styles.observation}>
<p>{t('noObservationsFound', 'No observations found')}</p>
</div>
);
};
Comment on lines -63 to -68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this empty status


export default EncounterObservations;