29
29
import ca .uhn .fhir .context .support .DefaultProfileValidationSupport ;
30
30
import ca .uhn .fhir .context .support .IValidationSupport ;
31
31
import dev .dsf .fhir .validator .client .TerminologyServerClient ;
32
+ import dev .dsf .fhir .validator .implementation_guide .ValidationPackageIdentifier ;
32
33
import dev .dsf .fhir .validator .implementation_guide .ValidationPackageWithDepedencies ;
33
34
import dev .dsf .fhir .validator .structure_definition .SnapshotGenerator ;
34
35
import dev .dsf .fhir .validator .structure_definition .SnapshotGenerator .SnapshotWithValidationMessages ;
@@ -154,27 +155,29 @@ private List<ValueSet> withExpandedValueSets(ValidationPackageWithDepedencies pa
154
155
155
156
packageWithDependencies .getValueSetsIncludingDependencies (valueSetBindingStrengths , fhirContext ).forEach (v ->
156
157
{
157
- logger .debug ("Expanding ValueSet {}|{}" , v .getUrl (), v .getVersion ());
158
+ logger .debug ("Expanding ValueSet {}|{} from package (incl. dependencies) {}" , v .getUrl (), v .getVersion (),
159
+ packageWithDependencies .getIdentifier ().toString ());
158
160
159
161
// ValueSet uses filter or import in compose
160
162
if (v .hasCompose () && ((v .getCompose ().hasInclude ()
161
163
&& (v .getCompose ().getInclude ().stream ().anyMatch (c -> c .hasFilter () || c .hasValueSet ())))
162
164
|| (v .getCompose ().hasExclude ()
163
165
&& v .getCompose ().getExclude ().stream ().anyMatch (c -> c .hasFilter () || c .hasValueSet ()))))
164
166
{
165
- expandExternal (expandedValueSets , v );
167
+ expandExternal (expandedValueSets , v , packageWithDependencies . getIdentifier () );
166
168
}
167
169
else
168
170
{
169
171
// will try external expansion if internal not successful
170
- expandInternal (expandedValueSets , expander , v );
172
+ expandInternal (expandedValueSets , expander , v , packageWithDependencies . getIdentifier () );
171
173
}
172
174
});
173
175
174
176
return expandedValueSets ;
175
177
}
176
178
177
- private void expandExternal (List <ValueSet > expandedValueSets , ValueSet v )
179
+ private void expandExternal (List <ValueSet > expandedValueSets , ValueSet v ,
180
+ ValidationPackageIdentifier validationPackageIdentifier )
178
181
{
179
182
try
180
183
{
@@ -184,41 +187,45 @@ private void expandExternal(List<ValueSet> expandedValueSets, ValueSet v)
184
187
catch (WebApplicationException e )
185
188
{
186
189
logger .warn (
187
- "Error while expanding ValueSet {}|{} externally, this may result in incomplete validation: {} - {}" ,
188
- v .getUrl (), v .getVersion (), e .getClass ().getName (), e .getMessage ());
190
+ "Unable to expand ValueSet {}|{} from package (incl. dependencies) {} externally, this may result in incomplete validation: {} - {}" ,
191
+ v .getUrl (), v .getVersion (), validationPackageIdentifier .toString (), e .getClass ().getName (),
192
+ e .getMessage ());
189
193
getOutcome (e ).ifPresent (m -> logger .debug ("Expansion error response: {}" , m ));
190
194
logger .debug ("ValueSet with error while expanding: {}" ,
191
195
fhirContext .newJsonParser ().encodeResourceToString (v ));
192
196
}
193
197
catch (Exception e )
194
198
{
195
199
logger .warn (
196
- "Error while expanding ValueSet {}|{} externally, this may result in incomplete validation: {} - {}" ,
197
- v .getUrl (), v .getVersion (), e .getClass ().getName (), e .getMessage ());
200
+ "Unable to expand ValueSet {}|{} from package (incl. dependencies) {} externally, this may result in incomplete validation: {} - {}" ,
201
+ v .getUrl (), v .getVersion (), validationPackageIdentifier .toString (), e .getClass ().getName (),
202
+ e .getMessage ());
198
203
logger .debug ("ValueSet with error while expanding: {}" ,
199
204
fhirContext .newJsonParser ().encodeResourceToString (v ));
200
205
}
201
206
}
202
207
203
- private void expandInternal (List <ValueSet > expandedValueSets , ValueSetExpander expander , ValueSet v )
208
+ private void expandInternal (List <ValueSet > expandedValueSets , ValueSetExpander expander , ValueSet v ,
209
+ ValidationPackageIdentifier validationPackageIdentifier )
204
210
{
205
211
try
206
212
{
207
213
ValueSetExpansionOutcome expansion = expander .expand (v );
208
214
209
215
if (expansion .getError () != null )
210
- logger .warn ("Error while expanding ValueSet {}|{} internally: {}" , v . getUrl (), v . getVersion () ,
211
- expansion .getError ());
216
+ logger .warn ("Unable to expand ValueSet {}|{} from package (incl. dependencies) {} internally: {}" ,
217
+ v . getUrl (), v . getVersion (), validationPackageIdentifier . toString (), expansion .getError ());
212
218
else
213
219
expandedValueSets .add (expansion .getValueset ());
214
220
}
215
221
catch (Exception e )
216
222
{
217
223
logger .info (
218
- "Error while expanding ValueSet {}|{} internally: {} - {}, trying to expand via external terminology server next" ,
219
- v .getUrl (), v .getVersion (), e .getClass ().getName (), e .getMessage ());
224
+ "Unable to expand ValueSet {}|{} from package (incl. dependencies) {} internally: {} - {}, trying to expand via external terminology server next" ,
225
+ v .getUrl (), v .getVersion (), validationPackageIdentifier .toString (), e .getClass ().getName (),
226
+ e .getMessage ());
220
227
221
- expandExternal (expandedValueSets , v );
228
+ expandExternal (expandedValueSets , v , validationPackageIdentifier );
222
229
}
223
230
}
224
231
@@ -250,15 +257,16 @@ private IValidationSupport withSnapshots(List<ValueSet> expandedValueSets,
250
257
packageWithDependencies .getValidationSupportResources ().getStructureDefinitions ().stream ()
251
258
.filter (s -> s .hasDifferential () && !s .hasSnapshot ())
252
259
.forEach (diff -> createSnapshot (packageWithDependencies , snapshotsAndExpandedValueSets , snapshots ,
253
- generator , diff ));
260
+ generator , diff , packageWithDependencies . getIdentifier () ));
254
261
}
255
262
256
263
return supportChain ;
257
264
}
258
265
259
266
private void createSnapshot (ValidationPackageWithDepedencies packageWithDependencies ,
260
267
ValidationSupportWithCustomResources snapshotsAndExpandedValueSets ,
261
- Map <String , StructureDefinition > snapshots , SnapshotGenerator generator , StructureDefinition diff )
268
+ Map <String , StructureDefinition > snapshots , SnapshotGenerator generator , StructureDefinition diff ,
269
+ ValidationPackageIdentifier validationPackageIdentifier )
262
270
{
263
271
if (snapshots .containsKey (diff .getUrl () + "|" + diff .getVersion ()))
264
272
return ;
@@ -267,8 +275,8 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
267
275
definitions .addAll (packageWithDependencies .getStructureDefinitionDependencies (diff ));
268
276
definitions .add (diff );
269
277
270
- logger .debug ("Generating snapshot for {}|{}, base {}, dependencies {}" , diff . getUrl (), diff . getVersion () ,
271
- diff .getBaseDefinition (),
278
+ logger .debug ("Generating snapshot for {}|{} from package (incl. dependencies) {} , base {}, dependencies {}" ,
279
+ diff .getUrl (), diff . getVersion (), validationPackageIdentifier . toString (), diff . getBaseDefinition (),
272
280
definitions .stream ()
273
281
.filter (sd -> !sd .equals (diff ) && !sd .getUrl ().equals (diff .getBaseDefinition ())
274
282
&& !(sd .getUrl () + "|" + sd .getVersion ()).equals (diff .getBaseDefinition ()))
@@ -284,16 +292,19 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
284
292
285
293
if (PublicationStatus .ACTIVE .equals (diff .getStatus ()) && !dependenciesWithDifferentStatus .isEmpty ())
286
294
{
287
- logger .warn ("StructureDefinition {}|{}, has dependencies with no active status [{}]" , diff .getUrl (),
288
- diff .getVersion (), dependenciesWithDifferentStatus );
295
+ logger .warn (
296
+ "StructureDefinition {}|{} from package (incl. dependencies) {}, has dependencies with no active status [{}]" ,
297
+ diff .getUrl (), diff .getVersion (), validationPackageIdentifier .toString (),
298
+ dependenciesWithDifferentStatus );
289
299
}
290
300
291
301
definitions .stream ().filter (sd -> sd .hasDifferential () && !sd .hasSnapshot ()
292
302
&& !snapshots .containsKey (sd .getUrl () + "|" + sd .getVersion ())).forEach (sd ->
293
303
{
294
304
try
295
305
{
296
- logger .debug ("Generating snapshot for {}|{}" , sd .getUrl (), sd .getVersion ());
306
+ logger .debug ("Generating snapshot for {}|{} from package (incl. dependencies) {}" , sd .getUrl (),
307
+ sd .getVersion (), validationPackageIdentifier .toString ());
297
308
SnapshotWithValidationMessages snapshot = generator .generateSnapshot (sd );
298
309
299
310
if (snapshot .getSnapshot ().hasSnapshot ())
@@ -304,8 +315,8 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
304
315
}
305
316
else
306
317
logger .error (
307
- "Error while generating snapshot for {}|{}: Not snaphsot returned from generator" ,
308
- diff .getUrl (), diff .getVersion ());
318
+ "Error while generating snapshot for {}|{} from package (incl. dependencies) {} : Not snaphsot returned from generator" ,
319
+ diff .getUrl (), diff .getVersion (), validationPackageIdentifier . toString () );
309
320
310
321
snapshot .getMessages ().forEach (m ->
311
322
{
@@ -320,12 +331,15 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
320
331
}
321
332
catch (Exception e )
322
333
{
323
- logger .error ("Error while generating snapshot for {}|{}: {} - {}" , diff .getUrl (),
324
- diff .getVersion (), e .getClass ().getName (), e .getMessage ());
334
+ logger .error (
335
+ "Error while generating snapshot for {}|{} from package (incl. dependencies) {}: {} - {}" ,
336
+ diff .getUrl (), diff .getVersion (), validationPackageIdentifier .toString (),
337
+ e .getClass ().getName (), e .getMessage ());
325
338
}
326
339
});
327
340
328
- logger .debug ("Generating snapshot for {}|{} [Done]" , diff .getUrl (), diff .getVersion ());
341
+ logger .debug ("Generating snapshot for {}|{} from package (incl. dependencies) {} [Done]" , diff .getUrl (),
342
+ diff .getVersion (), validationPackageIdentifier .toString ());
329
343
}
330
344
331
345
private ValidationSupportChain createSupportChain (FhirContext context ,
0 commit comments