@@ -34,8 +34,34 @@ define(function (require, exports) {
34
34
self . n_code_cells = 0 ;
35
35
self . n_markdown_cells = 0 ;
36
36
37
+ // Parameters to replace
38
+ self . dbServer = "localhost/ohdsi" ;
39
+ self . dbUser = "demo" ;
40
+ self . cdmDatabaseSchema = "cdm5" ;
41
+ self . resultsDatabaseSchema = "webapi" ;
42
+ self . exposureTable = "cohort" ;
43
+ self . outcomeTable = "cohort" ;
44
+ self . outputDirectory = "./" ;
45
+ self . target = "T" ;
46
+ self . comparator = "C" ;
47
+
48
+ // Patterns to replace
49
+ self . parameters = {
50
+ 'localhost/ohdsi' : self . dbServer ,
51
+ 'joe' : self . dbUser ,
52
+ 'supersecret' : self . dbUser ,
53
+ 'my_cdm_data' : self . cdmDatabaseSchema ,
54
+ 'my_results|(exposure|outcome)_database_schema' : self . resultsDatabaseSchema ,
55
+ 'exposure_table' : self . exposureTable ,
56
+ 'outcome_table' : self . outcomeTable ,
57
+ '<insert your directory here>' : self . outputDirectory ,
58
+ 'Target' : self . target ,
59
+ 'Comparator' : self . comparator
60
+ } ;
61
+
37
62
self . createNotebook = function ( rawR ) {
38
63
var notebook = self . copyShallow ( self . notebookBase ) ;
64
+ rawR = self . replaceParameters ( rawR ) ;
39
65
notebook . cells = self . createCells ( rawR ) ;
40
66
return notebook ;
41
67
} ;
@@ -119,6 +145,19 @@ define(function (require, exports) {
119
145
return cellContent . trim ( ) ;
120
146
} ;
121
147
148
+ self . replaceParameters = function ( string ) {
149
+ var regex ;
150
+ for ( var key in self . parameters ) {
151
+ // check if the property/key is defined in the object itself, not in parent
152
+ if ( ! self . parameters . hasOwnProperty ( key ) ) {
153
+ continue ;
154
+ }
155
+ regex = new RegExp ( '"(' + key + ')"' , 'g' ) ;
156
+ string = string . replace ( regex , '"' + self . parameters [ key ] + '"' ) ;
157
+ }
158
+ return string ;
159
+ } ;
160
+
122
161
self . copyShallow = function ( object ) {
123
162
return JSON . parse ( JSON . stringify ( object ) ) ;
124
163
} ;
0 commit comments