Commit eee998eb authored by R.W.Majeed's avatar R.W.Majeed

transformation of patient and visit in observation stream

parent ef79d79b
......@@ -65,6 +65,7 @@ public interface Observation extends ConceptValuePair{
<T> T getExtension(Class<T> extensionType) throws IllegalArgumentException;
<T> void setExtension(Class<T> extensionType, T extension) throws IllegalArgumentException;
void setPatientId(String patientId);
void setEncounterId(String encounterId);
void setLocationId(String locationId);
......
......@@ -115,6 +115,7 @@ public class ObservationImpl implements Observation, Cloneable{
@Override
public String getPatientId() {return patientId;}
@Override
public void setPatientId(String patientId){this.patientId = patientId;}
@Override
......
package de.sekmi.histream.io.transform;
import java.util.function.Consumer;
import java.util.function.Function;
import de.sekmi.histream.Observation;
import de.sekmi.histream.ext.Patient;
import de.sekmi.histream.ext.Visit;
import de.sekmi.histream.io.Transformation;
import de.sekmi.histream.io.TransformationException;
/**
* Replace patient and visit information for each observation.
*
* @author Raphael
*
*/
public class PatientVisitTransformation implements Transformation {
private Function<String, String> patientIdMapper;
private Function<String, String> visitIdMapper;
private Function<Patient, Patient> patientMapper;
private Function<Visit, Visit> visitMapper;
public PatientVisitTransformation() {
}
/**
* Set the patient mapping functions
*
* @param patientExtensionMapper map a patient.
* Warning, changing the patient object might also change the patient object
* of other facts which share the patient extension. If you do so, take care
* not to process the same patient object again.
*
* @param patientIdMapper maps the patient id from {@link Observation#getPatientId()}.
* This function is always called after the patientExtensionMapper.
*/
public void setPatientMapping(Function<Patient,Patient> patientExtensionMapper, Function<String,String> patientIdMapper){
this.patientIdMapper = patientIdMapper;
this.patientMapper = patientExtensionMapper;
}
public void setVisitMapping(Function<Visit,Visit> visitExtensionMapper, Function<String,String> visitIdMapper){
this.visitIdMapper = visitIdMapper;
this.visitMapper = visitExtensionMapper;
}
@Override
public Observation transform(Observation fact, Consumer<Observation> generatedReceiver)
throws TransformationException {
if( patientMapper != null ){
fact.setExtension(Patient.class, patientMapper.apply(fact.getExtension(Patient.class)));
}
if( patientIdMapper != null ){
fact.setPatientId(patientIdMapper.apply(fact.getPatientId()));
}
if( visitMapper != null ){
fact.setExtension(Visit.class, visitMapper.apply(fact.getExtension(Visit.class)));
}
if( visitIdMapper != null ){
fact.setEncounterId(visitIdMapper.apply(fact.getEncounterId()));
}
return fact;
}
}
/**
* Transformation of observations
*
*/
package de.sekmi.histream.io.transform;
\ No newline at end of file
Markdown is supported
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