Skip to content

Commit

Permalink
Update display of ETASU responses in REMS Admin page such that only t…
Browse files Browse the repository at this point in the history
…he Patient Status Update forms are sorted by timestamp
  • Loading branch information
jtquach1 committed Oct 24, 2023
1 parent be17365 commit 8918560
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions src/views/Questionnaire/components/RemsInterface/RemsInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ interface RemsInterfaceProps {
interface RemsAdminResponse {
data: JsonData;
}

type MetRequirements = {
completed: boolean;
requirementName: string;
requirementDescription: string;
};

interface JsonData {
case_number: string;
status: string;
metRequirements: [
{
requirementName: string;
completed: boolean;
requirementDescription: string;
}
];
metRequirements: MetRequirements[];
}

export default function RemsInterface(props: RemsInterfaceProps) {
const [remsAdminResponse, setRemsAdminResponse] = useState<RemsAdminResponse | null>(null);
const [response, setResponse] = useState<AxiosResponse | null>(null);
Expand All @@ -48,18 +50,27 @@ export default function RemsInterface(props: RemsInterfaceProps) {
};

const unfurlJson = (jsonData: JsonData) => {
return jsonData.metRequirements.map(metReq => {
console.log(metReq);
return (
<div>
<div className={'resource-entry etasu-container'}>
<div className={'resource-entry-text'}>{metReq.requirementName}</div>
<div className={'resource-entry-icon'}>{metReq.completed ? '✅' : '❌'}</div>
<div className={'resource-entry-hover'}>{metReq.requirementDescription}</div>
return jsonData.metRequirements
.sort((first: MetRequirements, second: MetRequirements) => {
// Keep the other forms unsorted.
if (second.requirementName.includes('Patient Status Update')) {
// Sort the Patient Status Update forms in descending order of timestamp.
return second.requirementName.localeCompare(first.requirementName);
}
return 0;
})
.map(metReq => {
console.log(metReq);
return (
<div>
<div className={'resource-entry etasu-container'}>
<div className={'resource-entry-text'}>{metReq.requirementName}</div>
<div className={'resource-entry-icon'}>{metReq.completed ? '✅' : '❌'}</div>
<div className={'resource-entry-hover'}>{metReq.requirementDescription}</div>
</div>
</div>
</div>
);
});
);
});
};

const getResource = (bundle: Bundle, resourceReference: string) => {
Expand Down

0 comments on commit 8918560

Please sign in to comment.