@@ -15,6 +15,7 @@ import {ErrorHelper} from '../../utilities/error-helper';
15
15
import { NavbarService } from "../navbar.service" ;
16
16
import { BehaviorSubject } from "rxjs" ;
17
17
import { MedcoNodeResult } from "../../models/picsure-models/i2b2-medco/medco-node-result" ;
18
+ import { MedcoQueryType } from "../../models/picsure-models/i2b2-medco/medco-query-type" ;
18
19
19
20
// todo 12/04/19: delayed upgrade of medco-unlynx-js (stay with 0.1.8),
20
21
// wait for bug fix of wasm go compiler (?) (changes marked XXX)
@@ -106,22 +107,30 @@ export class MedcoService {
106
107
*/
107
108
parseMedCoResults ( results : MedcoNodeResult [ ] ) : number {
108
109
109
- // k is 0, 1, 2, ....
110
110
for ( let k in results ) {
111
- // let b64EncodedResultObject = data[k][`medco_results_${k}`];
112
- // let resultObject = JSON.parse(atob(b64EncodedResultObject));
113
111
114
112
if ( this . publicKey !== results [ k ] . encryptionKey ) {
115
113
console . warn ( `Returned public key is different from public key, expect problems (${ results [ k ] . encryptionKey } )` ) ;
116
114
}
117
115
118
116
results [ k ] . nodeName = `Clinical Site ${ k } ` ; // todo: get from node
119
117
results [ k ] . networkName = 'MedCo Network' ; // todo: get from node
120
- results [ k ] . decryptedCount = Number ( this . decryptInteger ( results [ k ] . encryptedCount ) ) ;
121
118
results [ k ] . timeMeasurements = { } ; // todo
122
119
123
- // results.push(result);
124
- console . log ( `${ k } : ${ results [ k ] . decryptedCount } , times: ${ JSON . stringify ( results [ k ] . timeMeasurements ) } ` )
120
+ // decrypt count
121
+ results [ k ] . decryptedCount = Number ( this . decryptInteger ( results [ k ] . encryptedCount ) ) ;
122
+
123
+ // decrypt patient list, ignore IDs that are zero (= dummies nullified)
124
+ results [ k ] . decryptedPatientList = results [ k ] . encryptedPatientList ?
125
+ results [ k ] . encryptedPatientList
126
+ . map ( ( encId ) => Number ( this . decryptInteger ( encId ) ) )
127
+ . filter ( ( pId ) => pId !== 0 ) :
128
+ [ ] ;
129
+
130
+ // parse query type
131
+ results [ k ] . parsedQueryType = MedcoQueryType . ALL_TYPES . find ( ( type ) => type . id === results [ k ] . queryType ) ;
132
+
133
+ console . log ( `${ k } : count=${ results [ k ] . decryptedCount } , #patient IDs=${ results [ k ] . decryptedPatientList . length } , times: ${ JSON . stringify ( results [ k ] . timeMeasurements ) } ` )
125
134
}
126
135
127
136
// randomize results (according to configuration)
@@ -133,9 +142,15 @@ export class MedcoService {
133
142
}
134
143
135
144
this . results . next ( results ) ;
136
- this . addMedcoResultsTab ( ) ;
137
145
138
- return results . map ( ( r ) => r . decryptedCount ) . reduce ( ( a , b ) => Number ( a ) + Number ( b ) ) ;
146
+ if ( results [ 0 ] . parsedQueryType === MedcoQueryType . COUNT_GLOBAL ||
147
+ results [ 0 ] . parsedQueryType === MedcoQueryType . COUNT_GLOBAL_OBFUSCATED ) {
148
+ // count is global: all results should be the same, return the first one
149
+ return results [ 0 ] . decryptedCount ;
150
+ } else {
151
+ this . addMedcoResultsTab ( ) ;
152
+ return results . map ( ( r ) => r . decryptedCount ) . reduce ( ( a , b ) => Number ( a ) + Number ( b ) ) ;
153
+ }
139
154
}
140
155
141
156
/**
0 commit comments