Skip to content

Commit

Permalink
(chore) O3-4125: Vitals and Biometrics should not rely on concept search
Browse files Browse the repository at this point in the history
  • Loading branch information
D-matz committed Dec 3, 2024
1 parent 7ca5b09 commit b3869b0
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 12 deletions.
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 =
'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}`;

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: {
_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;
};
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

0 comments on commit b3869b0

Please sign in to comment.