@@ -7,26 +7,13 @@ import { hdsModel, serviceInfoUrl, initHDSModel, stateSaveApp } from "./common-l
77const APP_MANAGING_STREAMID = 'app-dr-hds' ;
88/** The name of this application */
99const APP_MANAGING_NAME = 'HDS Dr App PoC' ;
10- /** The app Manging */
11- let appManaging ; // initalized during pryvAuthStateChange
1210
1311export const drLib = {
14- // OK for v2
1512 showLoginButton,
16- getAppManaging,
1713 getPatientsData,
18- getPatientDetails,
19- // OLD
20- getFirstFormFields
14+ getPatientDetails
2115} ;
2216
23- /**
24- * exposes appManaging for the app
25- */
26- function getAppManaging ( ) {
27- return appManaging ;
28- }
29-
3017function showLoginButton ( loginSpanId , stateChangeCallBack ) {
3118 const authSettings = {
3219 spanButtonID : loginSpanId , // div id the DOM that will be replaced by the Service specific button
@@ -63,13 +50,12 @@ function showLoginButton (loginSpanId, stateChangeCallBack) {
6350 console . log ( "##pryvAuthStateChange" , state ) ;
6451 if ( state . id === HDSLib . pryv . Browser . AuthStates . AUTHORIZED ) {
6552 await initHDSModel ( ) ; // hds model needs to be initialized
66- appManaging = await HDSLib . appTemplates . AppManagingAccount . newFromApiEndpoint ( APP_MANAGING_STREAMID , state . apiEndpoint , APP_MANAGING_NAME ) ;
53+ const appManaging = await HDSLib . appTemplates . AppManagingAccount . newFromApiEndpoint ( APP_MANAGING_STREAMID , state . apiEndpoint , APP_MANAGING_NAME ) ;
6754 stateSaveApp ( 'managing' , appManaging ) ;
6855 await initDemoAccount ( appManaging ) ;
6956 stateChangeCallBack ( "loggedIN" ) ;
7057 }
7158 if ( state . id === HDSLib . pryv . Browser . AuthStates . INITIALIZED ) {
72- appManaging = null ;
7359 stateSaveApp ( 'managing' , null ) ;
7460 stateChangeCallBack ( "loggedOUT" ) ;
7561 }
@@ -152,8 +138,11 @@ async function getPatientsData (collector) {
152138 createdAt : 'Date'
153139 }
154140 // headers from first form
155- const itemDefs = getFirstFormFields ( requestContent . app . data . forms ) ;
156- for ( const itemDef of itemDefs ) {
141+ const firstForm = Object . values ( requestContent . app . data . forms ) [ 0 ] ;
142+ const itemDefs = [ ] ;
143+ for ( const itemKey of firstForm . itemKeys ) {
144+ const itemDef = hdsModel ( ) . itemsDefs . forKey ( itemKey ) ;
145+ itemDefs . push ( itemDef ) ;
157146 headers [ itemDef . key ] = HDSLib . l ( itemDef . data . label ) ;
158147 }
159148
@@ -220,19 +209,6 @@ async function getPatientDetails(invite, itemDefs) {
220209 return patient ;
221210}
222211
223- /**
224- * get the list of rows for the initial table
225- */
226- function getFirstFormFields ( forms ) {
227- const firstForm = Object . values ( forms ) [ 0 ] ;
228- const itemDefs = [ ] ;
229- for ( const itemKey of firstForm . itemKeys ) {
230- itemDefs . push ( hdsModel ( ) . itemsDefs . forKey ( itemKey ) ) ;
231- }
232-
233- return itemDefs ;
234- }
235-
236212/**
237213 * Link an event to a data field from form
238214 * @param {* } event
0 commit comments