Skip to content

Commit

Permalink
gix age and gender display
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Chen committed Oct 30, 2024
1 parent 6ede57b commit 87c951a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/server/Model/Cohort/DemographicAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public class DemographicAggregator

readonly Dictionary<string,int> Religion = new Dictionary<string, int>();
readonly Dictionary<string,int> Sex = new Dictionary<string, int>();
readonly Dictionary<string,int> Gender = new Dictionary<string, int>();
readonly Dictionary<string,int> Age = new Dictionary<string, int>();
readonly SortedDictionary<string,int> Gender = new SortedDictionary<string, int>();
readonly SortedDictionary<string,int> Age = new SortedDictionary<string, int>();
readonly Dictionary<string,int> Race = new Dictionary<string, int>();

readonly NihRaceEthnicityBuckets NihRaceEthnicity = new NihRaceEthnicityBuckets();
Expand Down Expand Up @@ -467,7 +467,7 @@ void RecordRace(PatientDemographic patient)
Race.Add(race, 1);
}

readonly static string[] adultAgeBuckets = { "0-19", "20-29", "30-39", "40-49", "50-59", "60-69", ">=70"};
readonly static string[] adultAgeBuckets = { "<20", "20-29", "30-39", "40-49", "50-59", "60-69", "70+"};
void RecordAge(PatientDemographic patient)
{
if (String.IsNullOrEmpty(patient.Age?.ToString()))
Expand Down
4 changes: 2 additions & 2 deletions src/server/Model/Cohort/DemographicStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class DemographicStatistics
public VariableBucketSet LanguageByHeritageData { get; set; }
public Dictionary<string,int> ReligionData { get; set; }
public Dictionary<string,int> SexData { get; set; }
public Dictionary<string,int> GenderData { get; set; }
public Dictionary<string,int> AgeData { get; set; }
public SortedDictionary<string,int> GenderData { get; set; }
public SortedDictionary<string,int> AgeData { get; set; }
public Dictionary<string,int> RaceData { get; set; }
public NihRaceEthnicityBuckets NihRaceEthnicityData { get; set; }
}
Expand Down
10 changes: 1 addition & 9 deletions src/ui-client/src/components/Visualize/Age.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,7 @@ export class Age extends React.PureComponent<Props, State> {
const w = width > this.maxWidth ? this.maxWidth : width;

if (!counts) return <div style={{margin: "24px"}}>No data available</div>;
const sorted = Object.entries(counts)
.sort((a, b) => {
const arrA = a[0].split("-");
const arrB = b[0].split("-");
const a1 = parseInt(!isNaN(parseInt(arrA[0]))?arrA[0]: arrA[1]);
const b1 = parseInt(!isNaN(parseInt(arrB[0]))?arrB[0]: arrB[1]);
return a1 - b1;
});
let data = sorted
let data = Object.entries(counts)
.map(([key, value]) => ({ key, value }))
.sort((a, b) => (a.value > b.value ? 0 : 1));
const len = data.length;
Expand Down
4 changes: 1 addition & 3 deletions src/ui-client/src/components/Visualize/Gender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export class Gender extends React.PureComponent<Props, State> {
const w = width > this.maxWidth ? this.maxWidth : width;

if (!counts) return <div style={{margin: "24px"}}>No data available</div>;
const sorted = Object.entries(counts)
.sort((a, b) => a[0].localeCompare(b[0]));
let data = sorted
let data = Object.entries(counts)
.map(([key, value]) => ({ key, value }))
.sort((a, b) => (a.value > b.value ? 0 : 1));
const len = data.length;
Expand Down

0 comments on commit 87c951a

Please sign in to comment.