Skip to content

Commit

Permalink
add numeric value ranges for numeric tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwanganto committed Jan 30, 2024
1 parent 1a22e53 commit e50810d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/completed-list/completed-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ title {

.headerBtnContainer {
background-color: $ui-background;
padding: spacing.$spacing-05;
// padding: spacing.$spacing-05;
text-align: right;
}

Expand Down
37 changes: 35 additions & 2 deletions src/results/result-form-field.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TextInput, Select, SelectItem } from "@carbon/react";
import { useTranslation } from "react-i18next";
import { ConceptReference } from "./result-form.resource";
import { Controller } from "react-hook-form";
import { min } from "rxjs/operators";

interface ResultFormFieldProps {
concept: ConceptReference;
Expand All @@ -23,6 +24,28 @@ const ResultFormField: React.FC<ResultFormFieldProps> = ({
const isCoded = (concept) => concept.datatype?.display === "Coded";
const isPanel = (concept) => concept.setMembers?.length > 0;

const printValueRange = (concept: ConceptReference) => {
let maxVal;
let minVal;
let rangeString = "";
if (concept?.datatype?.display === "Numeric") {
maxVal = Math.max(
concept?.hiAbsolute,
concept?.hiCritical,
concept?.hiNormal
);
minVal = Math.min(
concept?.lowAbsolute,
concept?.lowCritical,
concept?.lowNormal
);
rangeString = ` (${minVal ?? 0} - ${maxVal ?? 0} ${
concept?.units ?? ""
})`;
}
return rangeString;
};

return (
<>
{Object.keys(errors).length > 0 && (
Expand All @@ -41,7 +64,12 @@ const ResultFormField: React.FC<ResultFormFieldProps> = ({
className={styles.textInput}
{...field}
type={concept.datatype.display === "Numeric" ? "number" : "text"}
labelText={concept?.display}
labelText={
concept?.display +
(concept.datatype.display === "Numeric"
? printValueRange(concept) ?? ""
: "")
}
autoFocus
/>
)}
Expand Down Expand Up @@ -98,7 +126,12 @@ const ResultFormField: React.FC<ResultFormFieldProps> = ({
type={
member.datatype.display === "Numeric" ? "number" : "text"
}
labelText={member?.display}
labelText={
member?.display +
(member.datatype.display === "Numeric"
? printValueRange(member) ?? ""
: "")
}
autoFocus={index === 0}
/>
)}
Expand Down
17 changes: 15 additions & 2 deletions src/results/result-form.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export interface ConceptResponse {
attributes: any[];
links: Link18[];
resourceVersion: string;
hiNormal: number;
hiAbsolute: number;
hiCritical: number;
lowNormal: number;
lowAbsolute: number;
lowCritical: number;
}

export interface Name {
Expand Down Expand Up @@ -159,6 +165,13 @@ export interface ConceptReference {
attributes: any[];
links: Link15[];
resourceVersion: string;
hiNormal: number;
hiAbsolute: number;
hiCritical: number;
lowNormal: number;
lowAbsolute: number;
lowCritical: number;
units?: string;
}

export interface Name3 {
Expand Down Expand Up @@ -300,7 +313,8 @@ export async function GetOrderConceptByUuid(uuid: string) {
}

export function useGetOrderConceptByUuid(uuid: string) {
const apiUrl = `/ws/rest/v1/concept/${uuid}?v=full`;
const apiUrl = `/ws/rest/v1/concept/${uuid}?v=custom:(uuid,display,name,datatype,set,answers,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units,setMembers:(uuid,display,answers,datatype,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units))`;

const { data, error, isLoading, isValidating, mutate } = useSWR<
{ data: ConceptResponse },
Error
Expand All @@ -314,7 +328,6 @@ export function useGetOrderConceptByUuid(uuid: string) {
};
}

// create observation
export async function UpdateEncounter(uuid: string, payload: any) {
const abortController = new AbortController();
return openmrsFetch(`/ws/rest/v1/encounter/${uuid}`, {
Expand Down
9 changes: 6 additions & 3 deletions src/work-list/work-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { Result, useGetOrdersWorklist } from "./work-list.resource";
import styles from "./work-list.scss";
import {
ConfigurableLink,
formatDate,
parseDate,
showModal,
Expand Down Expand Up @@ -149,9 +150,11 @@ const WorkList: React.FC<WorklistProps> = ({ fulfillerStatus }) => {
},
patient: {
content: (
<>
<span>{entry.patient.display.split("-")[1]}</span>
</>
<ConfigurableLink
to={`\${openmrsSpaBase}/patient/${entry.patient.uuid}/chart/laboratory-orders`}
>
{entry.patient.display.split("-")[1]}
</ConfigurableLink>
),
},
orderNumber: { content: <span>{entry.orderNumber}</span> },
Expand Down

0 comments on commit e50810d

Please sign in to comment.