File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -122,14 +122,26 @@ export class ActivityEntity {
122122 const subscaleTableData = subscaleItem . subscaleTableData
123123
124124 const subscaleTableDataItem = subscaleTableData . find ( ( { sex, age, rawScore } ) => {
125- let reportedAge : number | null = null
125+ let reportedAge : string | null = null
126126 if ( typeof ageAnswer === 'string' ) {
127- reportedAge = Number ( ageAnswer )
128- } else if ( 'value' in ageAnswer && typeof ageAnswer . value === 'number' ) {
129- reportedAge = ageAnswer . value
127+ reportedAge = ageAnswer
128+ } else if ( ageAnswer && 'value' in ageAnswer && [ 'number' , 'string' ] . includes ( typeof ageAnswer . value ) ) {
129+ reportedAge = String ( ageAnswer . value )
130+ }
131+
132+ const hasAgeInterval = age && typeof age === 'string' && age . includes ( INTERVAL_SYMBOL )
133+ let withAge = true
134+
135+ if ( age ) {
136+ if ( ! hasAgeInterval ) {
137+ withAge = String ( age ) === reportedAge
138+ } else {
139+ const [ minAge , maxAge ] = age . replace ( / \s / g, '' ) . split ( INTERVAL_SYMBOL )
140+ const reportedAgeNum = Number ( reportedAge )
141+ withAge = Number ( minAge ) <= reportedAgeNum && reportedAgeNum <= Number ( maxAge )
142+ }
130143 }
131144
132- const withAge = age === reportedAge
133145 const withSex = parseSex ( sex ) === String ( genderAnswer ?. value )
134146
135147 if ( ! withSex || ! withAge ) return false
You can’t perform that action at this time.
0 commit comments