Commit 535ef3b6 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

Interface for observation transformations

parent 2e305673
......@@ -9,7 +9,10 @@
@prefix dwh: <http://sekmi.de/histream/dwh#> .
@prefix snomed: <http://purl.bioontology.org/ontology/SNOMEDCT/>
:eurIPFreg a skos:ConceptScheme .
:FF.2235.qspab_60 a dwh:Concept ;
skos:inScheme :eurIPFreg ;
skos:notation "FF.2235.qspab_60" .
dwh:mapTo [
dwh:ifValueEquals 1 ;
......
package de.sekmi.histream.ontology.skos;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ObservationFactory;
import de.sekmi.histream.io.Transformation;
public class RDFTransformation implements Transformation {
private ObservationFactory factory;
public RDFTransformation(ObservationFactory factory){
this.factory = factory;
}
@Override
public Optional<Observation> transform(Observation fact) {
if( wantRemoved(fact) ) return Optional.empty();
Observation n = factory.createObservation(fact.getPatientId(), fact.getConceptId(), fact.getStartTime());
modify(n);
return Optional.of(n);
}
@Override
public Function<Observation, Observation> modificationFunction() {
// TODO Auto-generated method stub
return null;
}
@Override
public Predicate<Observation> allowedPredicate() {
return new Predicate<Observation>() {
@Override
public boolean test(Observation t) {
return !wantRemoved(t);
}
};
}
@Override
public boolean wantRemoved(Observation fact) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean modify(Observation fact) {
// TODO Auto-generated method stub
return false;
}
}
package de.sekmi.histream.io;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import de.sekmi.histream.Observation;
/**
* Transformation of observations.
* <p>
* A transformation can modify or remove observations.
* @author Raphael
*
*/
public interface Transformation {
/**
* Transforms a single observation.
* The original observation is not changed.
* @param fact observation to transform
* @return new transformed observation or empty opional if it should be removed
*/
Optional<Observation> transform(Observation fact);
/**
* Returns whether this transformation wants the supplied observation to be removed.
* @param fact observation to check for removal
* @return true if the observation should be removed, false to keep the observation
*/
boolean wantRemoved(Observation fact);
/**
* Modifies the supplied observation to match the transformation rule.
* @param fact observation to modify (in place)
* @return whether the supplied observation was modified.
*/
boolean modify(Observation fact);
/**
* Returns a function which applies this transformations
* modifications to any observation. Observations will not
* be removed by the returned function.
*
* @return function which applies this transformation
*/
Function<Observation, Observation> modificationFunction();
/**
* Returns a predicate which indicates whether to allow the
* observation.
* <p>
* The predicate's {@link Predicate#test(Object)} function will
* true if the argument should be allowed or modified, and false
* if the argument should be removed.
* @return predicate indicating whether to allow or remove an observation
*/
Predicate<Observation> allowedPredicate();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment