Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Issue #96 Highlighting new cases in last 3 days #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/NetworkMapLegend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
male_hosp,
male_cured,
male_dead,
male_hosp_new,
state_node,
city_node,
plane_abroad_node,
Expand Down Expand Up @@ -77,6 +78,10 @@ const NetworkMapLegend = ({ currentFilter }) => {
<Image src={male_dead} />
<Label>Deceased</Label>
</ImageContainer>
<ImageContainer>
<Image src={male_hosp_new} />
<Label> New case (last 3 days)</Label>
</ImageContainer>
{['State', 'City'].includes(currentFilter) ?
<ImageContainer>
<Image src={state_node} />
Expand Down
13 changes: 13 additions & 0 deletions images/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import female_cured from './female/cured.png'
import female_dead from './female/dead.png'
import female_hosp from './female/hospitalized.png'

import male_cured_new from './new/male/cured_new.png'
import male_dead_new from './new/male/dead_new.png'
import male_hosp_new from './new/male/hospitalized_new.png'
import female_cured_new from './new/female/cured_new.png'
import female_dead_new from './new/female/dead_new.png'
import female_hosp_new from './new/female/hospitalized_new.png'

import abroad from './filter/abroad.png'
import state from './filter/state.png'
import city from './filter/city.png'
Expand All @@ -22,6 +29,12 @@ export {
female_cured,
female_dead,
female_hosp,
male_cured_new,
male_dead_new,
male_hosp_new,
female_cured_new,
female_dead_new,
female_hosp_new,
state,
city,
state_node,
Expand Down
Binary file added images/new/female/cured_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/new/female/dead_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/new/female/hospitalized_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/new/male/cured_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/new/male/dead_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/new/male/hospitalized_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dot-prop-immutable": "^2.1.0",
"google-spreadsheet": "^3.0.10",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"next": "^9.3.1",
"next-images": "^1.3.1",
"object-hash": "^2.0.3",
Expand Down
78 changes: 55 additions & 23 deletions util/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,71 @@ import {
female_cured,
female_hosp,
female_dead,
male_hosp_new,
male_cured_new,
male_dead_new,
female_cured_new,
female_hosp_new,
female_dead_new,
} from '../images/index'
import dotProp from 'dot-prop-immutable'
import moment from 'moment'

export function letterToCode(str) {
const letterPos = parseInt(str[0], 36)
return parseInt(letterPos.toString() + str.substring(1))
}

export function getIcon(patient) {
if (patient.gender === 'male') {
if (patient.status === 'Recovered') {
return male_cured
} else if (patient.status === 'Hospitalized') {
return male_hosp
} else if (patient.status === 'Deceased') {
return male_dead
} else {
return male_hosp
}
} else if (patient.gender === 'female') {
if (patient.status === 'Recovered') {
return female_cured
} else if (patient.status === 'Hospitalized') {
return female_hosp
} else if (patient.status === 'Deceased') {
return female_dead
} else {
return female_hosp
}
let activeDays = moment().diff(moment(patient.reportedOn,'DD/MM/YYYY'),'days')
if (activeDays>3){
if (patient.gender === 'male') {
if (patient.status === 'Recovered') {
return male_cured
} else if (patient.status === 'Hospitalized') {
return male_hosp
} else if (patient.status === 'Deceased') {
return male_dead
} else {
return male_hosp
}
} else if (patient.gender === 'female') {
if (patient.status === 'Recovered') {
return female_cured
} else if (patient.status === 'Hospitalized') {
return female_hosp
} else if (patient.status === 'Deceased') {
return female_dead
} else {
return female_hosp
}
} else {
return female_hosp
}
} else {
return female_hosp
if (patient.gender === 'male') {
if (patient.status === 'Recovered') {
return male_cured_new
} else if (patient.status === 'Hospitalized') {
return male_hosp_new
} else if (patient.status === 'Deceased') {
return male_dead_new
} else {
return male_hosp_new
}
} else if (patient.gender === 'female') {
if (patient.status === 'Recovered') {
return female_cured_new
} else if (patient.status === 'Hospitalized') {
return female_hosp_new
} else if (patient.status === 'Deceased') {
return female_dead_new
} else {
return female_hosp_new
}
} else {
return female_hosp_new
}
}
}

Expand All @@ -111,7 +145,6 @@ export const rowsToGraph = rows => {
nodes: [],
edges: [],
}

rows.forEach(row => {
const patientCode = letterToCode('P' + row.patientId)
let node = {
Expand All @@ -121,7 +154,6 @@ export const rowsToGraph = rows => {
image: getIcon(row),
group: 'patient'
}

graph = dotProp.set(graph, 'nodes', list => [...list, node])

if (row.contractedFrom) {
Expand Down