39
39
ftx_loinc_services, ftx_service;
40
40
41
41
42
- const
43
- KEY_INCREMENT = 10 ;
44
-
45
42
type
46
-
47
- { TKeySet }
48
-
49
- TKeySet = class (TFslObject)
50
- private
51
- FKeys : TKeyArray;
52
- FCount : integer;
53
- public
54
- procedure addKey (key : integer);
55
- procedure getKeys (b : TFslStringBuilder);
56
- end ;
57
43
58
44
{ TCodeInformation }
59
45
TCodeInformation = class (TFslObject)
@@ -110,7 +96,7 @@ TLoincImporter = class (TFslObject)
110
96
FPropValues : TDictionary<String, Integer>;
111
97
112
98
// working items
113
- conn, dbCodes, dbRels, dbDesc, dbProps: TFDBConnection;
99
+ conn, dbCodes, dbRels, dbDesc, dbProps, dbText : TFDBConnection;
114
100
codes : TCodeMap;
115
101
codeList : TFslList<TCodeInformation>;
116
102
rels, langs, statii, dTypes, props : TKeyMap;
@@ -225,6 +211,7 @@ procedure TLoincImporter.ImportLOINC;
225
211
dbRels := db.GetConnection(' relationships' );
226
212
dbDesc := db.GetConnection(' descriptions' );
227
213
dbProps := db.GetConnection(' properties' );
214
+ dbText := db.GetConnection(' text' );
228
215
try
229
216
CreateTables(1 );
230
217
@@ -236,6 +223,8 @@ procedure TLoincImporter.ImportLOINC;
236
223
dbDesc.prepare;
237
224
dbProps.sql := ' Insert into Properties (PropertyKey, PropertyTypeKey, CodeKey, PropertyValueKey) values (:pk, :ptk, :ck, :v)' ;
238
225
dbProps.prepare;
226
+ dbText.sql := ' Insert into TextIndex (CodeKey, Type, Lang, Text) values (:ck, :tk, :lk, :t)' ;
227
+ dbText.prepare;
239
228
240
229
ProcessLanguageVariants(2 , st);
241
230
FStepCount := 12 + st.count;
@@ -255,11 +244,13 @@ procedure TLoincImporter.ImportLOINC;
255
244
dbRels.terminate;
256
245
dbDesc.terminate;
257
246
dbProps.terminate;
247
+ dbText.terminate;
258
248
259
249
dbCodes.Release;
260
250
dbRels.Release;
261
251
dbDesc.terminate;
262
252
dbProps.terminate;
253
+ dbText.terminate;
263
254
conn.Release;
264
255
except
265
256
on e : Exception do
@@ -430,6 +421,9 @@ procedure TLoincImporter.CreateTables(step: integer);
430
421
' PRIMARY KEY (`AncestorKey`, `DescendentKey`))' ;
431
422
conn.ExecSQL(sql);
432
423
424
+ sql := ' CREATE VIRTUAL TABLE TextIndex USING fts5(codekey UNINDEXED, type UNINDEXED, lang UNINDEXED, text)' ;
425
+ conn.ExecSQL(sql);
426
+
433
427
addEntry(' Types' , ' TypeKey' , ' Code' , nil , ' Code' , 1 );
434
428
addEntry(' Types' , ' TypeKey' , ' Code' , nil , ' Part' , 2 );
435
429
addEntry(' Types' , ' TypeKey' , ' Code' , nil , ' AnswerList' , 3 );
@@ -509,7 +503,8 @@ procedure TLoincImporter.CreateTables(step: integer);
509
503
addEntry(' PropertyTypes' , ' PropertyTypeKey' , ' Description' , props, ' AskAtOrderEntry' , 6 );
510
504
addEntry(' PropertyTypes' , ' PropertyTypeKey' , ' Description' , props, ' UNITSREQUIRED' , 7 );
511
505
addEntry(' PropertyTypes' , ' PropertyTypeKey' , ' Description' , props, ' CLASS' , 8 );
512
-
506
+ addEntry(' PropertyTypes' , ' PropertyTypeKey' , ' Description' , props, ' Copyright' , 9 );
507
+
513
508
conn.ExecSQL(' Insert into Languages (LanguageKey, Code, Description) values (1, '' en-US'' , '' English (United States)'' )' );
514
509
langs.addKey(' en-US' , 1 );
515
510
end ;
@@ -528,6 +523,12 @@ procedure TLoincImporter.ProcessDescription(codeKey, languageKey, descriptionTyp
528
523
dbDesc.BindInteger(' tk' , descriptionType);
529
524
dbDesc.BindString(' v' , value );
530
525
dbDesc.Execute;
526
+
527
+ dbText.BindInteger(' ck' , codeKey);
528
+ dbText.BindInteger(' tk' , descriptionType);
529
+ dbDesc.BindInteger(' lk' , languageKey);
530
+ dbText.BindString(' t' , value );
531
+ dbText.Execute;
531
532
end ;
532
533
end ;
533
534
@@ -729,6 +730,7 @@ procedure TLoincImporter.ProcessCodeItems(items: TStringArray);
729
730
ProcessProperty(ck, props.getKey(' PanelType' ), items[34 ]);
730
731
ProcessProperty(ck, props.getKey(' AskAtOrderEntry' ), items[35 ]);
731
732
ProcessProperty(ck, props.getKey(' UNITSREQUIRED' ), items[18 ]);
733
+ ProcessProperty(ck, props.getKey(' Copyright' ), items[23 ]);
732
734
733
735
734
736
ProcessDescription(ck, 1 , dTypes.getKey(' LONG_COMMON_NAME' ), d);
@@ -1090,7 +1092,9 @@ procedure TLoincImporter.ProcessHierarchyItems(items : TStringArray);
1090
1092
dbCodes.execute;
1091
1093
ciC := codes.addCode(c, ck, codeList);
1092
1094
end ;
1093
- if items[2 ] <> ' ' then
1095
+ if items[2 ] = ' ' then
1096
+ conn.ExecSQL(' Insert into Config (ConfigKey, Value) values (3, '' ' +items[3 ]+' '' )' )
1097
+ else
1094
1098
begin
1095
1099
ciP := codes.GetCode(items[2 ]);
1096
1100
@@ -1148,12 +1152,12 @@ procedure TLoincImporter.StoreClosureTable(step: integer);
1148
1152
for ci in codeList do
1149
1153
begin
1150
1154
inc(count);
1151
- if count mod 1000 = 0 then
1155
+ if count mod 10 = 0 then
1152
1156
Progress(step, count / codeList.count, ' Storing Closure Table: ' +pct(count, codeList.count));
1153
1157
if (ci.FChildren <> nil ) then
1154
1158
begin
1155
1159
conn.BindInteger(' a' , ci.FKey);
1156
- for k in ci.FChildren.FKeys do
1160
+ for k in ci.FChildren.Keys do
1157
1161
begin
1158
1162
conn.BindInteger(' d' , k);
1159
1163
conn.Execute;
@@ -1185,34 +1189,6 @@ function TKeyMap.getKey(code: String): integer;
1185
1189
raise EFslException.create(code+' not found in ' +FName+' Table' );
1186
1190
end ;
1187
1191
1188
- { TKeySet }
1189
-
1190
- procedure TKeySet.addKey (key: integer);
1191
- var
1192
- i : integer;
1193
- begin
1194
- for i := low(FKeys) to High(FKeys) do
1195
- if FKeys[i] = key then
1196
- exit;
1197
- if (FCount = length(FKeys)) then
1198
- SetLength(FKeys, length(FKeys) + KEY_INCREMENT);
1199
- FKeys[FCount] := key;
1200
- inc(FCount);
1201
- end ;
1202
-
1203
- procedure TKeySet.getKeys (b : TFslStringBuilder);
1204
- var
1205
- i : integer;
1206
- begin
1207
- b.clear;
1208
- for i := 0 to FCount - 1 do
1209
- begin
1210
- if i > 0 then
1211
- b.append(' ,' );
1212
- b.append(inttostr(FKeys[i]));
1213
- end ;
1214
- end ;
1215
-
1216
1192
{ TCodeInformation }
1217
1193
1218
1194
constructor TCodeInformation.create;
0 commit comments