StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/cdss");
// set globals
RecommendationService recommendationService = new RecommendationService();
ksession.setGlobal( "recommendationService",
recommendationService );
// create patient
Patient patient = new Patient();
patient.setName( "John Doe" );
patient.setAge( 20 );
ksession.insert( patient );
// Go!
Diagnose diagnose = new Diagnose( Terminology.DIAGNOSE_X );
ksession.insert( diagnose );
ksession.fireAllRules();
// Print out recommendations
List<Recommendation> recommendations = recommendationService.getRecommendations();
for ( Recommendation recommendation: recommendations ) {
System.out.println( recommendation );
}
recommendations.clear();
// Simulate a diagnose: incomplete results
diagnose = new Diagnose( Terminology.DIAGNOSE_X_TYPE_UNKNOWN );
ksession.insert( diagnose );
ksession.fireAllRules();
// Print out recommendations
recommendations = recommendationService.getRecommendations();
for ( Recommendation recommendation: recommendations ) {
System.out.println( recommendation );
}
recommendations.clear();