Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding metrics #5301

Merged
merged 21 commits into from
Sep 29, 2023
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
leif stawnyczy authored and leif stawnyczy committed Sep 13, 2023
commit b70e9c9250190db43d8d61b3e821ea4a4e80ab13
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.data.IMdmLinkJpaMetricsRepository;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.mdm.api.BaseMdmMetricSvc;
import ca.uhn.fhir.mdm.api.IMdmMetricSvc;
import ca.uhn.fhir.mdm.api.IMdmResourceDaoSvc;
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
Expand All @@ -24,22 +25,17 @@
import java.util.Arrays;
import java.util.List;

public class MdmMetricSvcJpaImpl implements IMdmMetricSvc {
public class MdmMetricSvcJpaImpl extends BaseMdmMetricSvc {

private final IMdmLinkJpaMetricsRepository myJpaRepository;

private final IMdmResourceDaoSvc myResourceDaoSvc;

private final DaoRegistry myDaoRegistry;

public MdmMetricSvcJpaImpl(
IMdmLinkJpaMetricsRepository theRepository,
IMdmResourceDaoSvc theResourceDaoSvc,
DaoRegistry theDaoRegistry
) {
super(theResourceDaoSvc, theDaoRegistry);
myJpaRepository = theRepository;
myDaoRegistry = theDaoRegistry;
myResourceDaoSvc = theResourceDaoSvc;
}

@Transactional
Expand Down Expand Up @@ -71,30 +67,6 @@ public MdmLinkMetrics generateLinkMetrics(GenerateMdmLinkMetricParameters thePar
return metrics;
}

@SuppressWarnings("rawtypes")
@Override
public MdmResourceMetrics generateResourceMetrics(GenerateMdmResourceMetricsParameters theParameters) {
String resourceType = theParameters.getResourceType();

GetGoldenResourceCountParameters resourceCountParameters = new GetGoldenResourceCountParameters();
resourceCountParameters.setResourceType(resourceType);
MdmGoldenResourceCount grCountResult = myResourceDaoSvc.getGoldenResourceCounts(resourceCountParameters);

SearchParameterMap searchParameterMap = new SearchParameterMap();
searchParameterMap.setLoadSynchronous(true);
searchParameterMap.setCount(0);
searchParameterMap.setSearchTotalMode(SearchTotalModeEnum.ACCURATE);
IFhirResourceDao dao = myDaoRegistry.getResourceDao(resourceType);
IBundleProvider result = dao.search(searchParameterMap, new SystemRequestDetails());

MdmResourceMetrics metrics = new MdmResourceMetrics();
metrics.setResourceType(resourceType);
metrics.setGoldenResourcesCount(grCountResult.getGoldenResourceCount());
metrics.setExcludedResources(grCountResult.getBlockListedGoldenResourceCount());
metrics.setSourceResourcesCount(result.size() - metrics.getGoldenResourcesCount());

return metrics;
}

@Transactional
@Override
Expand Down
Loading
Loading