openmrs-module-fhir2 icon indicating copy to clipboard operation
openmrs-module-fhir2 copied to clipboard

FM2-347:Add support for _has and _has:...:not for ServiceRequest and …

Open gitcliff opened this issue 4 years ago • 5 comments
trafficstars

LINK:https://issues.openmrs.org/browse/FM2-347

gitcliff avatar Mar 20 '21 18:03 gitcliff

Codecov Report

Merging #335 (b0c8a88) into master (6abb746) will decrease coverage by 0.48%. The diff coverage is 32.14%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #335      +/-   ##
============================================
- Coverage     80.22%   79.74%   -0.48%     
- Complexity     2214     2219       +5     
============================================
  Files           204      204              
  Lines          5941     5993      +52     
  Branches        704      707       +3     
============================================
+ Hits           4766     4779      +13     
- Misses          768      806      +38     
- Partials        407      408       +1     
Impacted Files Coverage Δ
.../fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java 43.55% <0.00%> (-43.95%) :arrow_down:
.../providers/r3/ObservationFhirResourceProvider.java 96.43% <ø> (+7.14%) :arrow_up:
...iders/r3/ProcedureRequestFhirResourceProvider.java 91.67% <ø> (ø)
...oviders/r4/ServiceRequestFhirResourceProvider.java 85.71% <ø> (ø)
...org/openmrs/module/fhir2/api/dao/impl/BaseDao.java 65.52% <42.86%> (-0.81%) :arrow_down:
...ule/fhir2/api/dao/impl/FhirObservationDaoImpl.java 86.09% <71.43%> (-0.95%) :arrow_down:
...ule/fhir2/api/impl/FhirObservationServiceImpl.java 94.29% <100.00%> (+0.17%) :arrow_up:
.../fhir2/api/impl/FhirServiceRequestServiceImpl.java 87.50% <100.00%> (ø)
...rs/module/fhir2/api/search/SearchQueryInclude.java 87.98% <100.00%> (ø)
.../providers/r4/ObservationFhirResourceProvider.java 96.55% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6abb746...b0c8a88. Read the comment docs.

codecov[bot] avatar Mar 21 '21 09:03 codecov[bot]

@ibacher kindly review

gitcliff avatar Mar 29 '21 17:03 gitcliff

PS I think the handling of the _has parameter should look something like this:

private void handleHasAndParam(Criteria criteria, HasAndListParam hasAndListParam) {
	if (hasAndListParam == null) {
		return;
	}

	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Obs.class);

	hasAndListParam.getValuesAsQueryTokens().stream().map(this::handleHasOrParam).filter(Optional::isPresent)
			.flatMap(Optional::get).forEach(detachedCriteria::add);
		
		
	criteria.add(Subqueries.exists(detachedCriteria));
}

private Optional<Stream<Criterion>> handleHasOrParam(HasOrListParam hasOrListParam) {
	if (hasOrListParam == null) {
		return Optional.empty();
	}

	return Optional.of(hasOrListParam.getValuesAsQueryTokens().stream().map(this::handleHasParam).filter(
			Optional::isPresent).map(Optional::get));
}

private Optional<Criterion> handleHasParam(HasParam hasParam) {
	if (hasParam == null) {
		return Optional.empty();
	}
		
	if (!FhirConstants.OBSERVATION.equals(hasParam.getTargetResourceType())) {
		return Optional.empty();
	}
}

(I've left out the mapping of the fields to the right criteria, but hopefully this outline is useful).

ibacher avatar Mar 29 '21 19:03 ibacher

@ibacher thanks for the outline ,,, i have added the field mapping

gitcliff avatar Mar 31 '21 16:03 gitcliff

hello @ibacher,,, i added some unit tests

gitcliff avatar Jun 08 '21 08:06 gitcliff