Skip to content

Commit

Permalink
(feat) O3-3365: Make freeTextFieldConceptUuid configurable (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Jun 26, 2024
1 parent 5ee3e64 commit bd4bf42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/esm-patient-chart-app/src/config-schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Type } from '@openmrs/esm-framework';

export const esmPatientChartSchema = {
freeTextFieldConceptUuid: {
_default: '5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
_type: Type.ConceptUuid,
},
visitDiagnosisConceptUuid: {
_default: '159947AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
_type: Type.ConceptUuid,
Expand Down Expand Up @@ -131,6 +135,7 @@ export const esmPatientChartSchema = {
},
};
export interface ChartConfig {
freeTextFieldConceptUuid: string;
offlineVisitTypeUuid: string;
visitTypeResourceUrl: string;
showRecommendedVisitTypeTab: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
import { WarningFilled } from '@carbon/react/icons';
import { EmptyState, type DefaultPatientWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import { ExtensionSlot, useLayoutType, showSnackbar, ResponsiveWrapper } from '@openmrs/esm-framework';
import { ExtensionSlot, useLayoutType, showSnackbar, ResponsiveWrapper, useConfig } from '@openmrs/esm-framework';
import { markPatientDeceased, useCausesOfDeath } from '../data.resource';
import { type ChartConfig } from '../config-schema';
import styles from './mark-patient-deceased-form.scss';

const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ closeWorkspace, patientUuid }) => {
const freetextCauseOfDeathUuid = '5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
const isTablet = useLayoutType() === 'tablet';
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const memoizedPatientUuid = useMemo(() => ({ patientUuid }), [patientUuid]);
const [isSubmitting, setIsSubmitting] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
const { causesOfDeath, isLoading: isLoadingCausesOfDeath } = useCausesOfDeath();
const { freeTextFieldConceptUuid } = useConfig<ChartConfig>();

const filteredCausesOfDeath = useMemo(() => {
if (!searchTerm) {
Expand All @@ -59,7 +60,7 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close
}),
nonCodedCauseOfDeath: z.string().optional(),
})
.refine((data) => !(data.causeOfDeath === freetextCauseOfDeathUuid && !data.nonCodedCauseOfDeath), {
.refine((data) => !(data.causeOfDeath === freeTextFieldConceptUuid && !data.nonCodedCauseOfDeath), {
message: t('nonCodedCauseOfDeathRequired', 'Please enter the non-coded cause of death'),
path: ['nonCodedCauseOfDeath'],
});
Expand Down Expand Up @@ -210,7 +211,7 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close
{errors?.causeOfDeath && <p className={styles.errorMessage}>{errors?.causeOfDeath?.message}</p>}
</section>
</div>
{causeOfDeathValue === freetextCauseOfDeathUuid && (
{causeOfDeathValue === freeTextFieldConceptUuid && (
<div className={styles.nonCodedCauseOfDeath}>
<Controller
name="nonCodedCauseOfDeath"
Expand Down

0 comments on commit bd4bf42

Please sign in to comment.