| | 75 | |
|---|
| | 76 | |
|---|
| | 77 | /* |
|---|
| | 78 | public void testAddTokenTags() throws Exception |
|---|
| | 79 | { |
|---|
| | 80 | Context.getLogicService().addTokenTag("AGE", "COMMON"); |
|---|
| | 81 | Context.getLogicService().addTokenTag("GENDER", "COMMON"); |
|---|
| | 82 | Context.getLogicService().addTokenTag("DEATH DATE", "COMMON"); |
|---|
| | 83 | |
|---|
| | 84 | System.out.println(Context.getLogicService().getTokensByTag("COMMON")); |
|---|
| | 85 | |
|---|
| | 86 | System.out.println(Context.getLogicService().getTagsByToken("GENDER")); |
|---|
| | 87 | //Context.getLogicService(). |
|---|
| | 88 | |
|---|
| | 89 | } |
|---|
| | 90 | */ |
|---|
| | 91 | |
|---|
| | 92 | public void testGetCohorts() |
|---|
| | 93 | { |
|---|
| | 94 | |
|---|
| | 95 | for (CohortDefinitionItemHolder c : Context.getCohortService().getAllCohortDefinitions()) |
|---|
| | 96 | { |
|---|
| | 97 | System.out.println("<filter name=\"" + c.getName() + "\" id=\"" + c.getKey() + "\" />"); |
|---|
| | 98 | } |
|---|
| | 99 | } |
|---|
| | 100 | |
|---|
| | 101 | public void testGetTags() throws Exception { |
|---|
| | 102 | Set<String> tags = Context.getLogicService().findTags(""); |
|---|
| | 103 | System.out.println("Tags: " + tags); |
|---|
| | 104 | |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| | 107 | |
|---|
| | 108 | public void testGetData() |
|---|
| | 109 | { |
|---|
| | 110 | CohortDefinition cohortDefinition = Context.getCohortService().getCohortDefinition("3:org.openmrs.cohort.StaticCohortDefinition"); |
|---|
| | 111 | Cohort patients = Context.getCohortService().evaluate(cohortDefinition, null); |
|---|
| | 112 | |
|---|
| | 113 | String[] tokens = {"GENDER", "AGE"}; |
|---|
| | 114 | |
|---|
| | 115 | LogicContext logicContext = new LogicContext(patients); |
|---|
| | 116 | LogicService ls = Context.getLogicService(); |
|---|
| 61 | | |
|---|
| | 118 | //List<Map<Integer, Result>> resultsForTokens = new ArrayList<Map<Integer, Result>>(); |
|---|
| | 119 | |
|---|
| | 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()); |
|---|
| | 132 | |
|---|
| | 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 | } |
|---|
| | 145 | } |
|---|