Skip to content

Commit

Permalink
Questionnaire Response | Display multi values (#10448)
Browse files Browse the repository at this point in the history
  • Loading branch information
amjithtitus09 authored Feb 6, 2025
1 parent 23ae17e commit 87f70f4
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,31 @@ export function formatValue(
function QuestionResponseValue({ question, response }: QuestionResponseProps) {
if (!response) return null;

const value =
response.values[0]?.value || response.values[0]?.value_quantity?.value;

if (!value) return null;

return (
<div>
<div className="text-xs text-gray-500">{question.text}</div>
<div className="text-sm font-medium whitespace-pre-wrap">
{formatValue(value, question.type)}
{question.unit?.code && (
<span className="ml-1 text-xs">{question.unit.code}</span>
)}
{response.note && (
<span className="ml-2 text-xs text-gray-500">({response.note})</span>
)}
<div className="space-y-1">
{response.values.map((valueObj, index) => {
const value = valueObj.value || valueObj.value_quantity?.value;
if (!value) return null;

return (
<div
key={index}
className="text-sm font-medium whitespace-pre-wrap"
>
{formatValue(value, question.type)}
{question.unit?.code && (
<span className="ml-1 text-xs">{question.unit.code}</span>
)}
{index === response.values.length - 1 && response.note && (
<span className="ml-2 text-xs text-gray-500">
({response.note})
</span>
)}
</div>
);
})}
</div>
</div>
);
Expand Down

0 comments on commit 87f70f4

Please sign in to comment.