Skip to content

Commit

Permalink
30 add comment to case (#31)
Browse files Browse the repository at this point in the history
* reorder fields

* working comment for curator

* Fix Eslint
  • Loading branch information
stanislaw-zakrzewski authored Oct 4, 2023
1 parent ab3d75f commit 6b71209
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 65 deletions.
2 changes: 2 additions & 0 deletions data-serving/data-service/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ components:
- suspected
- discarded
- omit_error
comment:
type: string
caseReference:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions data-serving/data-service/src/controllers/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export class CasesController {
while (doc != null) {
delete doc.caseReference.sourceEntryId;
const caseDTO = await dtoFromCase(doc);
delete caseDTO.comment;
const stringifiedCase = stringify([caseDTO], {
header: false,
columns: this.csvHeaders,
Expand Down
3 changes: 3 additions & 0 deletions data-serving/data-service/src/model/day0-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const caseSchema = new mongoose.Schema(
enum: CaseStatus,
required: true,
},
comment: String,
pathogen: {
type: String,
required: true,
Expand Down Expand Up @@ -149,6 +150,7 @@ caseSchema.methods.equalsJSON = function (jsonCase: any): boolean {

return (
_.isEqual(thisJson.caseStatus, other.caseStatus) &&
_.isEqual(thisJson.comment, other.comment) &&
_.isEqual(thisJson.demographics, other.demographics) &&
_.isEqual(thisJson.events, other.events) &&
_.isEqual(thisJson.genomeSequences, other.genomeSequences) &&
Expand Down Expand Up @@ -179,6 +181,7 @@ export interface ISource {

export type ICase = {
caseStatus: CaseStatus;
comment?: string;
pathogen: string;
symptoms: string;
dateLastModified: string;
Expand Down
1 change: 1 addition & 0 deletions data-serving/data-service/src/model/fields.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
"_id",
"caseStatus",
"comment",
"pathogen",
"caseReference.additionalSources",
"caseReference.sourceEntryId",
Expand Down
2 changes: 2 additions & 0 deletions verification/curator-service/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ components:
- suspected
- discarded
- omit_error
comment:
type: string
caseReference:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Curator', function () {
// GENERAL
cy.get('div[data-testid="caseStatus"]').click();
cy.get('li[data-value="confirmed"').click();
cy.get('div[data-testid="comment"]').type('This case should be consulted with Supervisor.');

// DATA SOURCE

Expand Down Expand Up @@ -426,6 +427,8 @@ describe('Curator', function () {
// TODO UI for demographics.age needs redesigning
// View full details about the case
cy.contains('td', 'www.example.com').click({ force: true });
// Curator's comment.
cy.contains('This case should be consulted with Supervisor.');
// Case data.
cy.contains('www.example.com');
// Demographics.
Expand Down
2 changes: 2 additions & 0 deletions verification/curator-service/ui/src/api/models/Day0Case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export interface Curators {
export interface Day0Case {
_id?: string;
caseStatus: CaseStatus | '';
comment?: string;
caseReference: CaseReference;
demographics: Demographics;
location: Location;
Expand Down Expand Up @@ -224,6 +225,7 @@ interface VaccinationFormValues {
// contains all the fields present in manual case entry form
export interface Day0CaseFormValues {
caseStatus: CaseStatus | '';
comment?: string;
caseReference: {
sourceId: string;
sourceUrl: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ interface RawParsedCase {
[key: string]: string | number | boolean | undefined;

caseStatus: CaseStatus;
comment?: string;
pathogen: string;

// CaseReference
Expand Down Expand Up @@ -255,6 +256,7 @@ const BulkCaseForm = (props: BulkCaseFormProps) => {
): CompleteParsedCase => {
return {
caseStatus: c.caseStatus,
comment: c.comment,
pathogen: c.pathogen,
caseReference: {
sourceId: caseReference.sourceId,
Expand Down
53 changes: 27 additions & 26 deletions verification/curator-service/ui/src/components/CaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const initialValuesFromCase = (
// return minimal viable case
return {
caseStatus: '',
comment: '',
caseReference: {
sourceId: '',
sourceUrl: '',
Expand Down Expand Up @@ -255,6 +256,7 @@ const NewCaseValidation = Yup.object().shape(
caseStatus: Yup.string()
.oneOf(['confirmed', 'suspected', 'discarded', 'omit_error'])
.required('Required'),
comment: Yup.string(),
caseReference: Yup.object().shape({
sourceUrl: Yup.string()
.required('Required')
Expand Down Expand Up @@ -670,65 +672,64 @@ export default function CaseForm(props: Props): JSX.Element {
</TableOfContentsRow>
<TableOfContentsRow
onClick={(): void =>
scrollTo('demographics')
scrollTo('location')
}
>
{tableOfContentsIcon({
isChecked: isChecked({
optionalValues: [
values.demographics.gender,
values.demographics.age,
values.demographics
.occupation,
values.demographics
.healthcareWorker,
requiredValues: [
values.location.countryISO3,
],
}),
hasError: hasErrors(
['demographics'],
['location'],
errors,
touched,
),
})}
{'Demographics'.toLocaleUpperCase()}
{'Location'.toLocaleUpperCase()}
</TableOfContentsRow>

<TableOfContentsRow
onClick={(): void =>
scrollTo('location')
}
onClick={(): void => scrollTo('events')}
>
{tableOfContentsIcon({
isChecked: isChecked({
requiredValues: [
values.location.countryISO3,
values.events.dateEntry,
values.events.dateReported,
],
}),
hasError: hasErrors(
['location'],
['events'],
errors,
touched,
),
})}
{'Location'.toLocaleUpperCase()}
{'Events'.toLocaleUpperCase()}
</TableOfContentsRow>
<TableOfContentsRow
onClick={(): void => scrollTo('events')}
onClick={(): void =>
scrollTo('demographics')
}
>
{tableOfContentsIcon({
isChecked: isChecked({
requiredValues: [
values.events.dateEntry,
values.events.dateReported,
optionalValues: [
values.demographics.gender,
values.demographics.age,
values.demographics
.occupation,
values.demographics
.healthcareWorker,
],
}),
hasError: hasErrors(
['events'],
['demographics'],
errors,
touched,
),
})}
{'Events'.toLocaleUpperCase()}
{'Demographics'.toLocaleUpperCase()}
</TableOfContentsRow>
<TableOfContentsRow
onClick={(): void =>
Expand Down Expand Up @@ -949,15 +950,15 @@ export default function CaseForm(props: Props): JSX.Element {
hasSourceEntryId
/>
</FormSection>
<FormSection>
<Demographics />
</FormSection>
<FormSection>
<LocationForm />
</FormSection>
<FormSection>
<Events />
</FormSection>
<FormSection>
<Demographics />
</FormSection>
<FormSection>
<Symptoms />
</FormSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ export const createData = (
dateOnset?: string,
source?: string,
caseStatus?: string,
comment?: string,
) => {
return {
caseId: caseId || '',
dateEntry: dateEntry || '',
dateReported: dateReported || '',
caseStatus: caseStatus || '',
comment: comment || '',
country: country || '',
region: region || '',
district: district || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const LinelistTable = () => {
renderDate(data.events.dateOnset) || '-',
data.caseReference.sourceUrl || '-',
data.caseStatus || '-',
data.comment || '',
);
});

Expand Down
82 changes: 43 additions & 39 deletions verification/curator-service/ui/src/components/ViewCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,23 +225,23 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {
<br />
<Button
variant="text"
onClick={(): void => scrollTo('demographics')}
onClick={(): void => scrollTo('location')}
>
demographics
location
</Button>
<br />
<Button
variant="text"
onClick={(): void => scrollTo('location')}
onClick={(): void => scrollTo('event-history')}
>
location
event history
</Button>
<br />
<Button
variant="text"
onClick={(): void => scrollTo('event-history')}
onClick={(): void => scrollTo('demographics')}
>
event history
demographics
</Button>
<br />
<Button
Expand Down Expand Up @@ -490,43 +490,12 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {
props.c.events.dateLastModified,
)}
/>
<RowHeader title="Curator's comment" />
<RowContent content={props.c.comment} isMultiline />
</Grid>
</Scroll.Element>
</Paper>

{/* DEMOGRAPHICS */}
<Paper className={classes.paper} variant="outlined" square>
<Scroll.Element
name="demographics"
className={classes.casebox}
/>
<Typography
className={classes.sectionTitle}
variant="overline"
>
Demographics
</Typography>
<Grid container className={classes.grid}>
<RowHeader title="Age" />
<RowContent
content={parseAgeRange(
props.c.demographics.ageRange,
)}
/>

<RowHeader title="Gender" />
<RowContent content={props.c.demographics.gender} />

<RowHeader title="Occupation" />
<RowContent content={props.c.demographics.occupation} />

<RowHeader title="Healthcare worker" />
<RowContent
content={props.c.demographics.healthcareWorker}
/>
</Grid>
</Paper>

{/* LOCATION */}
<Paper className={classes.paper} variant="outlined" square>
<Scroll.Element name="location" className={classes.casebox}>
Expand Down Expand Up @@ -708,6 +677,39 @@ function CaseDetails(props: CaseDetailsProps): JSX.Element {
</Scroll.Element>
</Paper>

{/* DEMOGRAPHICS */}
<Paper className={classes.paper} variant="outlined" square>
<Scroll.Element
name="demographics"
className={classes.casebox}
/>
<Typography
className={classes.sectionTitle}
variant="overline"
>
Demographics
</Typography>
<Grid container className={classes.grid}>
<RowHeader title="Age" />
<RowContent
content={parseAgeRange(
props.c.demographics.ageRange,
)}
/>

<RowHeader title="Gender" />
<RowContent content={props.c.demographics.gender} />

<RowHeader title="Occupation" />
<RowContent content={props.c.demographics.occupation} />

<RowHeader title="Healthcare worker" />
<RowContent
content={props.c.demographics.healthcareWorker}
/>
</Grid>
</Paper>

{/* SYMPTOMS */}
<Paper className={classes.paper} variant="outlined" square>
<Scroll.Element name="symptoms" className={classes.casebox}>
Expand Down Expand Up @@ -951,6 +953,7 @@ function RowHeader(props: { title: string }): JSX.Element {
function RowContent(props: {
content?: string;
isLink?: boolean;
isMultiline?: boolean;
}): JSX.Element {
const searchQuery = useSelector(selectSearchQuery);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -984,6 +987,7 @@ function RowContent(props: {
</a>
) : (
<Highlighter
style={{ whiteSpace: 'pre-wrap' }}
highlightStyle={{ fontWeight: 'bold' }}
className="highlighted"
searchWords={searchQueryArray}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"_id": "5ef8e943dfe6e00030892d58",
"caseStatus": "confirmed",
"comment": "This case might not contain valid data.\nNeeds to be checked by region supervisor.",
"pathogen": "COVID-19",
"events": {
"dateEntry": "2020-01-02",
Expand Down
Loading

0 comments on commit 6b71209

Please sign in to comment.