Skip to content

Commit

Permalink
feat(rf2): validate and report incorrect non-sctids in container...
Browse files Browse the repository at this point in the history
...component columns (eg. concept in case of a description file)
  • Loading branch information
cmark committed May 1, 2024
1 parent 6c615e8 commit b297247
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 B2i Healthcare, https://b2ihealthcare.com
* Copyright 2021-2024 B2i Healthcare, https://b2ihealthcare.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ public IgnoredRf2EffectiveTimeSlice(String effectiveTimeToIgnore, String message
}

@Override
public void register(String containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder) {
public void register(long containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 B2i Healthcare, https://b2ihealthcare.com
* Copyright 2017-2024 B2i Healthcare, https://b2ihealthcare.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,25 +105,24 @@ private <T extends SnomedComponent> T getComponent(String componentId) {
}

@Override
public void register(String containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder) {
public void register(long containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder) {

String[] valuesWithType = new String[values.length + 1];
valuesWithType[0] = type.getType();
System.arraycopy(values, 0, valuesWithType, 1, values.length);

final String componentId = values[0];
final long containerIdL = Long.parseLong(containerId);

// track refset members via membersByReferencedComponent map
if (Rf2RefSetContentType.class.isAssignableFrom(type.getClass())) {
if (!membersByReferencedComponent.containsKey(containerIdL)) {
membersByReferencedComponent.put(containerIdL, newHashSet());
if (!membersByReferencedComponent.containsKey(containerId)) {
membersByReferencedComponent.put(containerId, newHashSet());
}
membersByReferencedComponent.get(containerIdL).add(componentId);
membersByReferencedComponent.get(containerId).add(componentId);
} else {
// register other non-concept components in the dependency graph to force strongly connected subgraphs
if (!IComponent.ROOT_ID.equals(containerId)) {
registerDependencies(containerIdL, PrimitiveSets.newLongOpenHashSet(Long.parseLong(componentId)));
if (IComponent.ROOT_IDL != containerId) {
registerDependencies(containerId, PrimitiveSets.newLongOpenHashSet(Long.parseLong(componentId)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 B2i Healthcare, https://b2ihealthcare.com
* Copyright 2017-2024 B2i Healthcare, https://b2ihealthcare.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,8 +38,15 @@ public interface Rf2ContentType<T extends SnomedComponent> {
default void register(String[] values, Rf2EffectiveTimeSlice slice, ImportDefectBuilder defectBuilder) {

final String containerId = getContainerId(values);
slice.register(containerId, this, values, defectBuilder);
slice.registerDependencies(getDependentComponentId(values), getDependencies(values));
try {
final long containerIdL = Long.parseLong(containerId);

slice.register(containerIdL, this, values, defectBuilder);
slice.registerDependencies(getDependentComponentId(values), getDependencies(values));
} catch (NumberFormatException e) {
defectBuilder.error("Non-SCTID (%s) present in container column of RF2 content type of '%s'", containerId, getType());
return;
}
}

default long getDependentComponentId(String[] values) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 B2i Healthcare, https://b2ihealthcare.com
* Copyright 2021-2024 B2i Healthcare, https://b2ihealthcare.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,7 @@ public interface Rf2EffectiveTimeSlice {

int BATCH_SIZE = 5000;

void register(String containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder);
void register(long containerId, Rf2ContentType<?> type, String[] values, ImportDefectBuilder defectBuilder);

void registerDependencies(long componentId, LongSet dependencies);

Expand Down

0 comments on commit b297247

Please sign in to comment.