@Override public void prepare(TestCase testCase) { facts = new ArrayList<Object>(maxStep); FactType observationResult = ksession.getKnowledgeBase().getFactType("opencds.test", "ObservationResult2"); try { for (int j = 0; j < maxStep; j++) { Object obs = null; obs = observationResult.newInstance(); CD cdFocus = new CD(); cdFocus.setCodeSystem("AHRQ v4.3"); cdFocus.setCode("10220"); observationResult.set( obs, "id", "001" + Integer.toString(j)); // UUID.randomUUID().toString()); observationResult.set(obs, "observationFocus", cdFocus); observationResult.set(obs, "subjectIsFocalPerson", true); CD cdCoded = new CD(); cdCoded.setCodeSystem("AHRQ v4.3"); cdCoded.setCode("34254"); ObservationValue obsValue = new ObservationValue(); obsValue.setConcept(cdCoded); obsValue.setIdentifier(UUID.randomUUID().toString()); observationResult.set(obs, "observationValue", obsValue); facts.add(obs); ksession.insert(obs); } } catch (InstantiationException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } catch (IllegalAccessException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }
private Object setTriggerFactInstanceParams( FactType triggerFact, Object triggerFactInstance, String triggerFactInstanceParams) throws Exception { StringTokenizer st = new StringTokenizer(triggerFactInstanceParams, "|"); while (st.hasMoreTokens()) { StringTokenizer st1 = new StringTokenizer(st.nextToken(), ","); String paramName = st1.nextToken(); String paramValue = st1.nextToken(); Object o = null; if (paramValue.equalsIgnoreCase("EXIST")) { Field f = getClass().getDeclaredField(paramName); System.out.println(f.get(this)); o = f.get(this); } triggerFact.set(triggerFactInstance, paramName, o); } return triggerFactInstance; }
@Override public void prepare(TestCase testCase) { facts = new ArrayList<Object>(maxStep); FactType inputObject = ksession.getKnowledgeBase().getFactType("opencds.test", "InputObject"); try { Object obj = null; obj = inputObject.newInstance(); inputObject.set(obj, "id", "00A001"); facts.add(obj); ksession.insert(obj); } catch (InstantiationException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } catch (IllegalAccessException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } wCounter = 0; tCounter++; }