| 118 | | //List<Map<Integer, Result>> resultsForTokens = new ArrayList<Map<Integer, Result>>(); |
|---|
| | 100 | List<LogicCriteria> tokens = new ArrayList<LogicCriteria>(); |
|---|
| | 101 | tokens.add(LogicCriteria.parse("{WEIGHT (KG)}")); |
|---|
| | 102 | tokens.add(LogicCriteria.parse("{AGE}")); |
|---|
| | 103 | tokens.add(LogicCriteria.parse("{HEIGHT (CM)}")); |
|---|
| | 104 | |
|---|
| | 105 | Map<LogicCriteria, Map<Integer, Result>> resultsForTokens = null; |
|---|
| | 106 | try |
|---|
| | 107 | { |
|---|
| | 108 | resultsForTokens = ls.eval(patients, tokens); |
|---|
| | 109 | } |
|---|
| | 110 | catch (LogicException e) |
|---|
| | 111 | { |
|---|
| | 112 | // TODO Auto-generated catch block |
|---|
| | 113 | e.printStackTrace(); |
|---|
| | 114 | } |
|---|
| 120 | | try |
|---|
| 121 | | { |
|---|
| 122 | | for (String t : tokens) |
|---|
| 123 | | { |
|---|
| 124 | | Set<Integer> patientIDs = patients.getMemberIds(); |
|---|
| 125 | | Iterator<Integer> iter = patientIDs.iterator(); |
|---|
| 126 | | |
|---|
| 127 | | //Map<Integer,Result> patientResult = new HashMap<Integer, Result>(); |
|---|
| 128 | | |
|---|
| 129 | | while(iter.hasNext()) |
|---|
| 130 | | { |
|---|
| 131 | | Patient patient = Context.getPatientService().getPatient(iter.next()); |
|---|
| | 116 | String save = ""; |
|---|
| | 117 | |
|---|
| | 118 | for (Map.Entry<LogicCriteria, Map<Integer, Result>> resByCrit : resultsForTokens.entrySet()) |
|---|
| | 119 | { |
|---|
| | 120 | for(Map.Entry<Integer, Result> resByPat : resByCrit.getValue().entrySet()) |
|---|
| | 121 | { |
|---|
| | 122 | |
|---|
| | 123 | if(resByPat.getValue().size() > 0) |
|---|
| | 124 | { |
|---|
| | 125 | for(int i = 0; i < resByPat.getValue().size(); i++) |
|---|
| | 126 | { |
|---|
| | 127 | System.out.println("<row>"); |
|---|
| | 128 | |
|---|
| | 129 | //always print the patient id first |
|---|
| | 130 | System.out.println("<value>" + resByPat.getKey() + "</value>"); |
|---|
| | 131 | |
|---|
| | 132 | System.out.println("<value>" + resByCrit.getKey().getRootToken() + "</value>"); |
|---|
| | 133 | |
|---|
| | 134 | System.out.println("<value>" + resByPat.getValue().get(i).toString() + "</value>"); |
|---|
| | 135 | |
|---|
| | 136 | assertFalse(save.equals(resByPat.getValue().get(i).toString())); |
|---|
| | 137 | save = resByPat.getValue().get(i).toString(); |
|---|
| | 138 | |
|---|
| | 139 | System.out.println("</row>"); |
|---|
| | 140 | } |
|---|
| | 141 | } |
|---|
| | 142 | else |
|---|
| | 143 | { |
|---|
| | 144 | System.out.println("<row>"); |
|---|
| 133 | | System.out.println("LogicContext.read - " + logicContext.read(patient, (new LogicCriteria(t)))); |
|---|
| 134 | | |
|---|
| 135 | | System.out.println("LogicService.eval - " + ls.eval(patient, (new LogicCriteria(t)))); |
|---|
| 136 | | |
|---|
| 137 | | //patientResult.put(patient.getPatientId(), logicContext.read(patient, (new LogicCriteria(t)))); |
|---|
| 138 | | } |
|---|
| 139 | | |
|---|
| 140 | | //resultsForTokens.add(patientResult); |
|---|
| 141 | | } |
|---|
| 142 | | } catch (Exception e) { |
|---|
| 143 | | e.printStackTrace(); |
|---|
| 144 | | } |
|---|
| | 146 | //always print the patient id first |
|---|
| | 147 | System.out.println("<value>" + resByPat.getKey() + "</value>"); |
|---|
| | 148 | |
|---|
| | 149 | System.out.println("<value>" + resByCrit.getKey().getRootToken() + "</value>"); |
|---|
| | 150 | |
|---|
| | 151 | System.out.println("<value>" + resByPat.getValue().toString() + "</value>"); |
|---|
| | 152 | |
|---|
| | 153 | System.out.println("</row>"); |
|---|
| | 154 | |
|---|
| | 155 | } |
|---|
| | 156 | } |
|---|
| | 157 | } |
|---|