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

(chore) O3-4125: Vitals and Biometrics should not rely on concept search #2125

Open
wants to merge 2 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __mocks__/vitals-and-biometrics.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6002,6 +6002,7 @@ export const mockVitalsConfig = {
systolicBloodPressureUuid: '5085AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
temperatureUuid: '5088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
weightUuid: '5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
vitalsSignsUuid: '1114AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
vitals: {
encounterTypeUuid: '67a71486-1a54-468f-ac3e-7091a9a79584',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BiometricsBase: React.FC<BiometricsBaseProps> = ({ patientUuid, pageSize,
const config = useConfig<ConfigObject>();
const { bmiUnit } = config.biometrics;
const { data: biometrics, isLoading, error, isValidating } = useVitalsAndBiometrics(patientUuid, 'biometrics');
const { data: conceptUnits } = useVitalsConceptMetadata();
const { data: conceptUnits } = useVitalsConceptMetadata(config.concepts.vitalsSignsUuid);
const { currentVisit } = useVisitOrOfflineVisit(patientUuid);

const launchBiometricsForm = useCallback(
Expand Down
12 changes: 5 additions & 7 deletions packages/esm-patient-vitals-app/src/common/data.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,26 @@ export interface ConceptMetadata {
}

interface VitalsConceptMetadataResponse {
results: Array<{
setMembers: Array<ConceptMetadata>;
}>;
setMembers: Array<ConceptMetadata>;
}

function getInterpretationKey(header: string) {
// Reason for `Render` string is to match the column header in the table
return `${header}RenderInterpretation`;
}

export function useVitalsConceptMetadata() {
export function useVitalsConceptMetadata(vitalsSignsConceptUUID) {
const customRepresentation =
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 customRepresentation =
const { concepts } = useConfig<ConfigObject>();
const vitalSignsConceptSetUuid = concepts.vitalSignsConceptSetUuid;
const customRepresentation =

We could get the config property directly here from the useConfig hook and avoid passing it down as an argument in all invocations of useVitalsConceptMetadata. This approach:

  • Directly destructures the specific UUID you need from the config
  • Reduces unnecessary variable declarations
  • Makes the code more concise and easier to follow
  • Eliminates the need to pass the concept UUID as an argument through multiple function calls

'custom:(setMembers:(uuid,display,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units))';

const apiUrl = `${restBaseUrl}/concept/?q=VITALS SIGNS&v=${customRepresentation}`;
const apiUrl = `${restBaseUrl}/concept/${vitalsSignsConceptUUID}?v=${customRepresentation}`;
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 apiUrl = `${restBaseUrl}/concept/${vitalsSignsConceptUUID}?v=${customRepresentation}`;
const apiUrl = `${restBaseUrl}/concept/${vitalSignsConceptSetUuid}?v=${customRepresentation}`;


const { data, error, isLoading } = useSWRImmutable<{ data: VitalsConceptMetadataResponse }, Error>(
apiUrl,
openmrsFetch,
);

const conceptMetadata = data?.data?.results[0]?.setMembers;
const conceptMetadata = data?.data?.setMembers;

const conceptUnits = conceptMetadata?.length
? new Map<string, string>(conceptMetadata.map((concept) => [concept.uuid, concept.units]))
Expand Down Expand Up @@ -114,8 +112,8 @@ const vitalsHooksMutates = new Map<number, KeyedMutator<VitalsFetchResponse[]>>(
* @returns An SWR-like structure that includes the cleaned-up vitals
*/
export function useVitalsAndBiometrics(patientUuid: string, mode: VitalsAndBiometricsMode = 'vitals') {
const { conceptMetadata } = useVitalsConceptMetadata();
const { concepts } = useConfig<ConfigObject>();
const { conceptMetadata } = useVitalsConceptMetadata(concepts.vitalsSignsUuid);
const biometricsConcepts = useMemo(
() => [concepts.heightUuid, concepts.midUpperArmCircumferenceUuid, concepts.weightUuid],
[concepts.heightUuid, concepts.midUpperArmCircumferenceUuid, concepts.weightUuid],
Expand Down
5 changes: 5 additions & 0 deletions packages/esm-patient-vitals-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const configSchema = {
_type: Type.ConceptUuid,
_default: '1343AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
vitalsSignsUuid: {
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
vitalsSignsUuid: {
vitalSignsConceptSetUuid: {

Because this property represents a concept set:

CleanShot 2024-12-04 at 11  19 32@2x

_type: Type.ConceptUuid,
_default: '1114AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
},
},
vitals: {
useFormEngine: {
Expand Down Expand Up @@ -116,6 +120,7 @@ export interface ConfigObject {
weightUuid: string;
respiratoryRateUuid: string;
midUpperArmCircumferenceUuid: string;
vitalsSignsUuid: string;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

};
vitals: {
useFormEngine: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface VitalsHeaderProps {
const VitalsHeader: React.FC<VitalsHeaderProps> = ({ patientUuid, hideLinks = false }) => {
const { t } = useTranslation();
const config = useConfig<ConfigObject>();
const { data: conceptUnits, conceptMetadata } = useVitalsConceptMetadata();
const { data: conceptUnits, conceptMetadata } = useVitalsConceptMetadata(config.concepts.vitalsSignsUuid);
const { data: vitals, isLoading, isValidating } = useVitalsAndBiometrics(patientUuid, 'both');
const latestVitals = vitals?.[0];
const [showDetailsPanel, setShowDetailsPanel] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ const VitalsAndBiometricsForm: React.FC<DefaultPatientWorkspaceProps> = ({
const session = useSession();
const patient = usePatient(patientUuid);
const { currentVisit } = useVisit(patientUuid);
const { data: conceptUnits, conceptMetadata, conceptRanges, isLoading } = useVitalsConceptMetadata();
const {
data: conceptUnits,
conceptMetadata,
conceptRanges,
isLoading,
} = useVitalsConceptMetadata(config.concepts.vitalsSignsUuid);
const [hasInvalidVitals, setHasInvalidVitals] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false);
const [muacColorCode, setMuacColorCode] = useState('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const VitalsOverview: React.FC<VitalsOverviewProps> = ({ patientUuid, pageSize,

const { excludePatientIdentifierCodeTypes } = useConfig();
const { data: vitals, error, isLoading, isValidating } = useVitalsAndBiometrics(patientUuid);
const { data: conceptUnits } = useVitalsConceptMetadata();
const { data: conceptUnits } = useVitalsConceptMetadata(config.concepts.vitalsSignsUuid);
const showPrintButton = config.vitals.showPrintButton && !chartView;

const launchVitalsBiometricsForm = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface WeightTileInterface {
const WeightTile: React.FC<WeightTileInterface> = ({ patientUuid }) => {
const { t } = useTranslation();
const config = useConfig<ConfigObject>();
const { data: conceptUnits } = useVitalsConceptMetadata();
const { data: conceptUnits } = useVitalsConceptMetadata(config.concepts.vitalsSignsUuid);
const { data: biometrics, isLoading } = useVitalsAndBiometrics(patientUuid, 'biometrics');
const weightData = biometrics?.filter((result) => result.weight);

Expand Down
Loading