Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2018 Patient Clinical Summary Enhancement Changes For reveiew #38

Open
wants to merge 52 commits into
base: master
from
Open
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
57e6f86
added first changes
dilekamadushan Jun 16, 2018
f77149f
commented changes in liquibase.xml
dilekamadushan Jun 17, 2018
7a5e7da
completed ui designs
dilekamadushan Jun 20, 2018
7b9fbf0
added controllers to get access database
dilekamadushan Jun 20, 2018
c975a99
Merge branch 'master' of https://github.com/muzima/openmrs-module-muz…
dilekamadushan Jun 20, 2018
6219746
added debug lines
dilekamadushan Jun 21, 2018
3cce4da
added liquibase changes
dilekamadushan Jun 21, 2018
a5a4d98
Merge branch 'master' into gsoc_task1
dilekamadushan Jun 21, 2018
f7f02ad
added values to database
dilekamadushan Jun 21, 2018
2015716
added insert of report functionality
dilekamadushan Jun 22, 2018
54e0271
added search functionality
dilekamadushan Jun 23, 2018
c5bf58a
added getReports method in controller
dilekamadushan Jun 24, 2018
94c7d5d
added reporting dependency
dilekamadushan Jun 26, 2018
daedd78
Merge branch 'master' of https://github.com/muzima/openmrs-module-muz…
dilekamadushan Jun 26, 2018
f8c7e2a
added dependency to poms
dilekamadushan Jun 27, 2018
eb5e00c
added dependency to poms
dilekamadushan Jun 27, 2018
cbf8811
changed mvn version
dilekamadushan Jun 28, 2018
4ecdd2c
changed mvn version
dilekamadushan Jun 28, 2018
1f2668c
added reporting version
dilekamadushan Jun 28, 2018
86f07c9
started creating ReportGeneration task
dilekamadushan Jun 29, 2018
861f43d
added method to bring reportDefinitions
dilekamadushan Jun 29, 2018
73a0d94
added method to generate reports
dilekamadushan Jul 1, 2018
593890f
get names of reports and cohorts
dilekamadushan Jul 1, 2018
8ad905b
Merge branch 'masterUpstream' into gsoc_task
dilekamadushan Jul 1, 2018
05ec7f6
improved report generation task
dilekamadushan Jul 1, 2018
1c86e88
improved editing of report configurations
dilekamadushan Jul 2, 2018
31c750b
added endpoint to download generated reports
dilekamadushan Jul 3, 2018
a17fb56
modified code
dilekamadushan Jul 3, 2018
e7ea8eb
added functionality to listen to report log
dilekamadushan Jul 10, 2018
4f9a5b4
modified logic in report generation process
dilekamadushan Jul 11, 2018
33b8bd5
added a try catch when getting reportService
dilekamadushan Jul 12, 2018
1454af8
improved task
dilekamadushan Jul 13, 2018
5b3a8f5
added checkbox
dilekamadushan Jul 18, 2018
a8cbf25
commit for muzima scrum
dilekamadushan Jul 20, 2018
5eb742f
removed comment
dilekamadushan Jul 20, 2018
d76e99e
added new method to get generatedReport by patientUuid
dilekamadushan Jul 21, 2018
c4e4fb4
added priority column to generated report table
dilekamadushan Jul 22, 2018
7e5ac5e
liquidbase change
dilekamadushan Jul 22, 2018
00cdcf8
Merge branch 'masterUpstream' into gsoc_task
dilekamadushan Jul 22, 2018
7033fe3
added Generated report resource
dilekamadushan Jul 23, 2018
0df87f3
modified logging
dilekamadushan Jul 27, 2018
150073a
bug in omod
dilekamadushan Jul 28, 2018
e560222
changed reportJson field to blob
dilekamadushan Jul 29, 2018
ae94559
modified for debug
dilekamadushan Jul 31, 2018
e845024
renamed endpoint
dilekamadushan Aug 3, 2018
3134eda
renamed endpoint param
dilekamadushan Aug 7, 2018
d7f977d
tried to remove code
dilekamadushan Aug 7, 2018
f9d6d3c
removed debug lines
dilekamadushan Aug 7, 2018
d32bb05
added comments for functions
dilekamadushan Aug 10, 2018
052e78b
Merge branch 'masterUpstream' into for_reveiew
dilekamadushan Aug 10, 2018
10fd8f0
renamed methods
dilekamadushan Aug 10, 2018
d6e827d
added comments to the task
dilekamadushan Aug 10, 2018
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+375 −112
Diff settings

Always

Just for now

added method to generate reports

  • Loading branch information...
dilekamadushan committed Jul 1, 2018
commit 73a0d9498ba51069087be5b10949de4cebfdeb7f
@@ -128,8 +128,14 @@
<version>3.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>reporting-api</artifactId>
<version>1.16.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<!-- end spring boot test dependencies -->

<build>
@@ -38,7 +38,7 @@

ReportConfiguration getReportConfigurationByUuid(String Uuid);

ReportConfiguration getReportConfigurationByReportId(String reportId);
ReportConfiguration getReportConfigurationByReportUuid(String reportUuid);

ReportConfiguration saveOrUpdateReportConfiguration(ReportConfiguration reportConfiguration);

@@ -136,9 +136,9 @@ public ReportConfiguration getReportConfigurationByUuid(String uuid){

@Override
@Transactional
public ReportConfiguration getReportConfigurationByReportId(String reportId){
public ReportConfiguration getReportConfigurationByReportUuid(String reportUuid){
Criteria criteria = session().createCriteria(mappedClass);
criteria.add(Restrictions.eq("reportId", reportId));
criteria.add(Restrictions.eq("reportUuid", reportUuid));
criteria.add(Restrictions.eq("retired", Boolean.FALSE));
return (ReportConfiguration)criteria.uniqueResult();
}
@@ -23,8 +23,7 @@
ReportConfiguration getReportConfigurationById(final Integer id);

ReportConfiguration getReportConfigurationByUuid(final String uuid);

ReportConfiguration getReportConfigurationByReportId(final String reportId);


ReportConfiguration saveReportConfiguration(ReportConfiguration reportConfiguration);

@@ -48,10 +48,7 @@ public ReportConfiguration getReportConfigurationByUuid(final String uuid){
return dao.getReportConfigurationByUuid(uuid);
}

@Override
public ReportConfiguration getReportConfigurationByReportId(final String reportId){
return dao.getReportConfigurationByReportId(reportId);
}


@Override
public ReportConfiguration saveReportConfiguration(ReportConfiguration reportConfiguration){
@@ -0,0 +1,92 @@
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.muzima.model;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.openmrs.BaseOpenmrsMetadata;
import org.openmrs.User;

@JsonIgnoreProperties(ignoreUnknown = true)
public class MuzimaGeneratedReport extends BaseOpenmrsMetadata {
private static final long serialVersionUID = 1L;

private Integer id;
private String reportUuid;
private String cohortUuid;
private User user;

public MuzimaGeneratedReport(){
} // used by hibernate

public MuzimaGeneratedReport(String reportUuid, String cohortUuid){
setReportUuid(reportUuid);
setCohortUuid(cohortUuid);

}

@Override
public Integer getId() {
return id;
}

@Override
public void setId(final Integer id) {
this.id = id;
}

public void setReportUuid(final String reportUuid) {
this.reportUuid = reportUuid;
}

public String getReportUuid(){
return reportUuid;
}



public String getCohortUuid(){
return cohortUuid;
}

public void setCohortUuid(final String cohortUuid) {
this.cohortUuid = cohortUuid;
}

public User getCreator(){
return user;
}
public void setCreator(User creator){
this.user = creator;
}

@Override
public String toString() {
return "MuzimaSetting{" +
"id=" + id +
", uuid=" + getUuid() +
", name='" + getName() +
", reportId='" + getReportUuid() +
", cohortId='" + getCohortUuid()+
", description='" + getDescription() +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

return true;
}
}
@@ -23,17 +23,16 @@
private static final long serialVersionUID = 1L;

private Integer id;
private Integer reportId;
private Integer cohortId;
private Cohort cohort;
private String reportUuid;
private String cohortUuid;
private User user;

public ReportConfiguration(){
} // used by hibernate

public ReportConfiguration(Integer reportId, Integer cohortId){
setReportId(reportId);
setCohortId(cohortId);
public ReportConfiguration(String reportUuid, String cohortUuid){
setReportUuid(reportUuid);
setCohortUuid(cohortUuid);

}

@@ -47,28 +46,22 @@ public void setId(final Integer id) {
this.id = id;
}

public void setReportId(final Integer reportId) {
this.reportId = reportId;
public void setReportUuid(final String reportUuid) {
this.reportUuid = reportUuid;
}

public Integer getReportId(){
return reportId;
public String getReportUuid(){
return reportUuid;
}

public void setCohort(Cohort cohort){
this.cohort = cohort;
}

public Cohort getCohort(){
return cohort;
}

public Integer getCohortId(){
return cohortId;
public String getCohortUuid(){
return cohortUuid;
}

public void setCohortId(final Integer cohortId) {
this.cohortId = cohortId;
public void setCohortUuid(final String cohortUuid) {
this.cohortUuid = cohortUuid;
}

public User getCreator(){
@@ -84,8 +77,8 @@ public String toString() {
"id=" + id +
", uuid=" + getUuid() +
", name='" + getName() +
", reportId='" + getReportId() +
", cohortId='" + getCohortId()+
", reportId='" + getReportUuid() +
", cohortId='" + getCohortUuid()+
", description='" + getDescription() +
'}';
}
@@ -0,0 +1,134 @@
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs.module.muzima.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.Cohort;
import org.openmrs.Patient;
import org.openmrs.api.PersonService;
import org.openmrs.api.context.Context;
import org.openmrs.cohort.CohortDefinition;
import org.openmrs.module.muzima.api.service.ReportConfigurationService;
import org.openmrs.module.muzima.model.ReportConfiguration;
import org.openmrs.module.reporting.ReportingConstants;
import org.openmrs.module.reporting.common.ObjectUtil;
import org.openmrs.module.reporting.evaluation.parameter.Mapped;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;
import org.openmrs.module.reporting.report.ReportData;
import org.openmrs.module.reporting.report.ReportDesign;
import org.openmrs.module.reporting.report.ReportDesignResource;
import org.openmrs.module.reporting.report.ReportProcessorConfiguration;
import org.openmrs.module.reporting.report.ReportRequest;
import org.openmrs.module.reporting.report.definition.ReportDefinition;
import org.openmrs.module.reporting.report.renderer.RenderingMode;
import org.openmrs.module.reporting.report.service.ReportService;
import org.openmrs.module.reporting.report.util.ReportUtil;
import org.openmrs.module.reporting.web.renderers.WebReportRenderer;
import org.openmrs.report.EvaluationContext;
import org.openmrs.module.reporting.definition.DefinitionSummary;
import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService;
import org.openmrs.util.OpenmrsUtil;
import org.openmrs.web.WebConstants;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.WebRequest;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
*/
public class MuzimaReportProcessor {

private final Log log = LogFactory.getLog(MuzimaReportProcessor.class);

private static Boolean isRunning = false;

public void generateReports() {
if (!isRunning) {
processAllReports();
} else {
log.info("Queue data processor aborting (another processor already running)!");
}
}

public void processAllReports() {

List<ReportConfiguration> reportConfigurations = Context.getService(ReportConfigurationService.class).getAllReportConfigurations();
ReportService rs = Context.getService(ReportService.class);
ReportDefinitionService rds = Context.getService(ReportDefinitionService.class);
for (ReportConfiguration reportConfiguration : reportConfigurations) {
Cohort cohort = Context.getCohortService().getCohortByUuid(reportConfiguration.getCohortUuid());
String patientIds = cohort.getCommaSeparatedPatientIds();
String[] patientList = patientIds.split(",");
RenderingMode selectedRenderingMode = null;


ReportDesign design = rs.getReportDesignByUuid(reportConfiguration.getReportUuid());


ReportDefinition reportDefinition = rds.getDefinitionByUuid(design.getReportDefinition().getUuid());

System.out.println("12 12 12 12 12 12 12 InReport"+reportDefinition.toString());

for (Parameter p : reportDefinition.getParameters()) {
System.out.println("13 13 13 13 13 13 13InReport"+p.getName()+" "+p.getLabel());
System.out.println("1414144141414141441414InReport"+rs.getRenderingModes(reportDefinition));
}
for (RenderingMode renderingMode : rs.getRenderingModes(reportDefinition)) {
System.out.println("16161616161616161616166116"+renderingMode.getLabel()+"kkkkk"+design.getName());
if(renderingMode.getLabel().equals(design.getName())){
selectedRenderingMode = renderingMode;
}

}

for (String patientId : patientList) {
System.out.println("171717717717717171717717"+patientId);

design.getRendererType();
ReportRequest rr = new ReportRequest();
Map<String, Object> params = new LinkedHashMap<String, Object>();
params.put("person",Context.getService(PersonService.class).getPerson(1));
rr.setReportDefinition(new Mapped<ReportDefinition>(reportDefinition, params));
rr.setRenderingMode(selectedRenderingMode);
rr.setPriority(ReportRequest.Priority.NORMAL);
rr = rs.queueReport(rr);
rs.processNextQueuedReports();
ReportDesignResource r = design.getResourceByUuid(design.getUuid());
File file1 =rs.getReportDataFile(rr);

System.out.println("1818181818181818"+file1.toString());

File file2 =rs.getReportOutputFile(rr);

System.out.println("199999999999999"+file1.toString());

for (ReportProcessorConfiguration c : ReportUtil
.getAvailableReportProcessorConfigurations(rr, ReportProcessorConfiguration.ProcessorMode.values())) {
ReportProcessorConfiguration.ProcessorMode m = c.getProcessorMode();
}
System.out.println("2020202020202020202020"+file1.toString());
ReportData reportData = rs.loadReportData(rr);
System.out.println("212121212121212121212121"+reportData);
byte[] data = rs.loadRenderedOutput(rr);
System.out.println("22 22 22 22 22 22 22 22 22 2 22 222"+data);
System.out.println("22 22 22 22 22 22 22 22 22 2 22 222"+data.toString());
}
}
}
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.