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

Closed
wants to merge 52 commits into from
Closed
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.

Always

Just for now

improved task

  • Loading branch information...
dilekamadushan committed Jul 13, 2018
commit 1454af8f62f9f3e50b22690b198f621a087e02ab
@@ -37,6 +37,8 @@

MuzimaGeneratedReport getMuzimaGeneratedReportById(Integer id);

MuzimaGeneratedReport getLastMuzimaGeneratedReportByPatientId(Integer id);

List<MuzimaGeneratedReport> getMuzimaGeneratedReportByPatientId(Integer id);

MuzimaGeneratedReport getMuzimaGeneratedReportByUuid(String Uuid);
@@ -116,6 +116,14 @@ public MuzimaGeneratedReport getMuzimaGeneratedReportById(Integer id) {
return (MuzimaGeneratedReport) criteria.list();
}

@Override
public MuzimaGeneratedReport getLastMuzimaGeneratedReportByPatientId(Integer patientId) {
Criteria criteria = session().createCriteria(mappedClass);
criteria.add(Restrictions.eq("patientId", patientId));
criteria.add(Restrictions.eq("retired", Boolean.FALSE));
return (MuzimaGeneratedReport) criteria.list();
}

@Override
@Transactional
public List<MuzimaGeneratedReport> getMuzimaGeneratedReportByPatientId(Integer patientId){
@@ -24,6 +24,8 @@

List<MuzimaGeneratedReport> getMuzimaGeneratedReportByPatientId(final Integer id);

MuzimaGeneratedReport getLastMuzimaGeneratedReportByPatientId(final Integer id);

MuzimaGeneratedReport getMuzimaGeneratedReportByPatientIdANDCohortReportConfigId(Integer patientId, Integer cohortReportConfigId);

MuzimaGeneratedReport getMuzimaGeneratedReportByUuid(final String uuid);
@@ -43,6 +43,11 @@ public void setDao(MuzimaGeneratedReportDao dao) {
return dao.getMuzimaGeneratedReportByPatientId(id);
}

@Override
public MuzimaGeneratedReport getLastMuzimaGeneratedReportByPatientId(Integer id) {
return dao.getLastMuzimaGeneratedReportByPatientId(id);
}

@Override
public MuzimaGeneratedReport getMuzimaGeneratedReportByPatientIdANDCohortReportConfigId(Integer patientId,
Integer cohortReportConfigId) {
@@ -23,17 +23,17 @@

private Integer id;
private Integer patientId;
private Integer cohortReportConfigId;
private String reportRequestUuid;
private String cohortReportConfigUuid;
private User user;
private String status;
private String reportJson;

public MuzimaGeneratedReport(){
} // used by hibernate

public MuzimaGeneratedReport(String reportRequestUuid, String cohortReportConfigUuid){
setCohortReportConfigUuid(cohortReportConfigUuid);
public MuzimaGeneratedReport(String reportRequestUuid, Integer cohortReportConfigId){
setCohortReportConfigId(cohortReportConfigId);
setReportRequestUuid(reportRequestUuid);

}
@@ -48,12 +48,12 @@ public void setId(final Integer id) {
this.id = id;
}

public void setCohortReportConfigUuid(final String cohortReportConfigUuid) {
this.cohortReportConfigUuid = cohortReportConfigUuid;
public void setCohortReportConfigId(final Integer cohortReportConfigId) {
this.cohortReportConfigId = cohortReportConfigId;
}

public String getCohortReportConfigUuid(){
return cohortReportConfigUuid;
public Integer getCohortReportConfigId(){
return cohortReportConfigId;
}

public void setReportRequestUuid(final String reportRequestUuid) {
@@ -14,6 +14,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.Cohort;
import org.openmrs.Obs;
import org.openmrs.Patient;
import org.openmrs.api.ObsService;
import org.openmrs.api.PatientService;
import org.openmrs.api.PersonService;
import org.openmrs.api.context.Context;
import org.openmrs.module.muzima.api.service.MuzimaGeneratedReportService;
@@ -54,96 +58,129 @@ public void processAllReports() {
List<ReportConfiguration> reportConfigurations = Context.getService(ReportConfigurationService.class)
.getAllReportConfigurations();
ReportService reportService = Context.getService(ReportService.class);
ReportDefinitionService rds = Context.getService(ReportDefinitionService.class);
System.out.println("fffffffffffffffffffffI am befbore line");
try {
MuzimaGeneratedReportService muzimaGeneratedReportService = Context.getService(MuzimaGeneratedReportService.class);

}
catch (Exception ex){
System.out.println(ex.toString());
MuzimaGeneratedReportService muzimaGeneratedReportService = null;
}
System.out.println("fffffffffffffffffffffI am after line");
ReportDefinitionService reportDefinitionService = Context.getService(ReportDefinitionService.class);
ObsService obsService = Context.getService(ObsService.class);
PersonService personService = Context.getService(PersonService.class);
PatientService patientService = Context.getService(PatientService.class);
MuzimaGeneratedReportService muzimaGeneratedReportService = Context.getService(MuzimaGeneratedReportService.class);

for (ReportConfiguration reportConfiguration : reportConfigurations) {
System.out.println("fffffffffffffffffbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + reportConfiguration.getReportDesignUuid());
System.out
.println("fffffffffffffffff1111111111111111111111111111111" + reportConfiguration.getReportDesignUuid());

Cohort cohort = Context.getCohortService().getCohortByUuid(reportConfiguration.getCohortUuid());
System.out.println("fffffffffffffffff1111111111111111111");

String patientIds = cohort.getCommaSeparatedPatientIds();
String[] patientList = "1,2".split(",");
System.out.println("fffffffffffffffff22222222222222222222" + patientIds);
String[] patientList = patientIds.split(",");

RenderingMode selectedRenderingMode = null;

ReportDesign design = reportService.getReportDesignByUuid(reportConfiguration.getReportDesignUuid());
ReportDefinition reportDefinition = rds.getDefinitionByUuid(design.getReportDefinition().getUuid());
System.out.println("fffffffffffffffff2222222222222222222222");
ReportDefinition reportDefinition = reportDefinitionService
.getDefinitionByUuid(design.getReportDefinition().getUuid());
for (RenderingMode renderingMode : reportService.getRenderingModes(reportDefinition)) {
if (renderingMode.getLabel().equals(design.getName())) {
selectedRenderingMode = renderingMode;
System.out.println("vvvvvvvvvvvvvvvvvvvvvvfffffffffffffffff2222222222222222222222");
}
}
System.out.println("ttttttttttttttttttttttttt1");

System.out.println("ttttttttttttttttttttttttt2");
// for (String patientId : patientList) {
System.out.println("ffffffffffffffffffccccccccccccccccccccccccccccccc");

List<MuzimaGeneratedReport> generatedReportList = muzimaGeneratedReportService.getMuzimaGeneratedReportByPatientId(1);
System.out.println("tttttttttttffffffffccccccccccccccccccccccccccccccc" + generatedReportList.size());
if (generatedReportList.size() != 0) {
System.out.println("eeeeeeeeeeeffffffffdddddddddddddddddddddddddddddddddddd");
System.out.println("fffffff33333333333333333 Reports remain" + generatedReportList.size());
MuzimaGeneratedReport generatedReport = generatedReportList.get(generatedReportList.size() - 1);
if (!"completed".equals(generatedReport.getStatus())) {
System.out.println("fffffffffeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
ReportRequest reportRequest = reportService
.getReportRequestByUuid(generatedReport.getReportRequestUuid());
for (String patientId : patientList) {
System.out.println("ffffffffffffffffff333333333333333333333" + patientId);

MuzimaGeneratedReport generatedReport = muzimaGeneratedReportService
.getLastMuzimaGeneratedReportByPatientId(Integer.valueOf(patientId));
System.out.println("tttttttttttffffffffccccccccccccccccccccccccccccccc" + generatedReport);
if (generatedReport != null) {
System.out.println("fffffffffffffffff4444444444444444444444444444444444");
if (!"completed".equals(generatedReport.getStatus())) {
System.out.println("fffffffffffffffff5555555555555555555555555555");
ReportRequest reportRequest = reportService
.getReportRequestByUuid(generatedReport.getReportRequestUuid());

byte[] data = reportService.loadRenderedOutput(reportRequest);

if (data != null) {
System.out.println("fffffffffffffffff6666666666666666666666666666" + data);
System.out.println("Text [Byte Format] : " + data);
System.out.println("Text [Byte Format] : " + design.toString());

String s = new String(data);
System.out.println("Text Decryted : " + s);

generatedReport.setReportJson(s);
generatedReport.setStatus("completed");
muzimaGeneratedReportService.saveMuzimaGeneratedReport(generatedReport);
System.out.println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
} else {
System.out.println("ffffffffffffffffffffffffffffffffffffffffffffailed");
}
}

System.out.println("ffffffffffffffffffff77777777777777777777777" + 1);

byte[] data = reportService.loadRenderedOutput(reportRequest);
Patient patient = patientService.getPatient(Integer.valueOf(patientId));
List<Obs> obsList = obsService.getObservationsByPerson(patient);

String filename = selectedRenderingMode.getRenderer().getFilename(reportRequest).replace(" ", "_");
System.out.println("rrrrrrrrrrrrrrrrrrrrrrrr" + filename);
System.out.println(
"23333333333333" + selectedRenderingMode.getRenderer().getRenderedContentType(reportRequest));
Obs obs = obsList.get(obsList.size() - 1);

if (data != null) {
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());
} else {
System.out.println("ffffffffffffffffffffffffffffffffffffffffffffailed");
if (obs.getObsDatetime().after(generatedReport.getDateCreated())) {
System.out.println("fffffffffffffffA new report has to be generated");

ReportRequest reportRequest = new ReportRequest();
Map<String, Object> params = new LinkedHashMap<String, Object>();

params.put("person", personService.getPerson(1));
reportRequest.setReportDefinition(new Mapped<ReportDefinition>(reportDefinition, params));
reportRequest.setRenderingMode(selectedRenderingMode);
reportRequest.setPriority(ReportRequest.Priority.NORMAL);

reportRequest = reportService.queueReport(reportRequest);
reportService.processNextQueuedReports();
System.out.println("fffff11111111111111111111End of AsynchronousTask");

MuzimaGeneratedReport muzimaGeneratedReport = new MuzimaGeneratedReport();
muzimaGeneratedReport.setReportRequestUuid(reportRequest.getUuid());
muzimaGeneratedReport.setCohortReportConfigId(reportConfiguration.getId());
muzimaGeneratedReport.setPatientId(1);
muzimaGeneratedReport.setStatus("progress");

muzimaGeneratedReportService.saveMuzimaGeneratedReport(muzimaGeneratedReport);
System.out.println("fffffff2222222222222222222222222Save of generatedReport Success");
}

} else {

System.out.println("fffff00000000000000000000000000000" + 1);

System.out.println("A new report has to be generated");

ReportRequest reportRequest = new ReportRequest();
Map<String, Object> params = new LinkedHashMap<String, Object>();

params.put("person", personService.getPerson(1));
reportRequest.setReportDefinition(new Mapped<ReportDefinition>(reportDefinition, params));
reportRequest.setRenderingMode(selectedRenderingMode);
reportRequest.setPriority(ReportRequest.Priority.NORMAL);

reportRequest = reportService.queueReport(reportRequest);
reportService.processNextQueuedReports();
System.out.println("fffff11111111111111111111End of AsynchronousTask");

MuzimaGeneratedReport muzimaGeneratedReport = new MuzimaGeneratedReport();
muzimaGeneratedReport.setReportRequestUuid(reportRequest.getUuid());
muzimaGeneratedReport.setCohortReportConfigId(reportConfiguration.getId());
muzimaGeneratedReport.setPatientId(1);
muzimaGeneratedReport.setStatus("progress");

muzimaGeneratedReportService.saveMuzimaGeneratedReport(muzimaGeneratedReport);
System.out.println("fffffff2222222222222222222222222Save of generatedReport Success");

}
} else {
System.out.println("fffff00000000000000000000000000000" + 1);

ReportRequest reportRequest = new ReportRequest();
Map<String, Object> params = new LinkedHashMap<String, Object>();

params.put("person", Context.getService(PersonService.class).getPerson(1));
reportRequest.setReportDefinition(new Mapped<ReportDefinition>(reportDefinition, params));
reportRequest.setRenderingMode(selectedRenderingMode);
reportRequest.setPriority(ReportRequest.Priority.NORMAL);

reportRequest = reportService.queueReport(reportRequest);
reportService.processNextQueuedReports();
System.out.println("fffff11111111111111111111End of AsynchronousTask");

MuzimaGeneratedReport muzimaGeneratedReport = new MuzimaGeneratedReport();
muzimaGeneratedReport.setReportRequestUuid(reportRequest.getUuid());
muzimaGeneratedReport.setCohortReportConfigUuid(reportConfiguration.getCohortUuid());
muzimaGeneratedReport.setPatientId(1);
muzimaGeneratedReport.setStatus("progress");

muzimaGeneratedReportService.saveMuzimaGeneratedReport(muzimaGeneratedReport);
System.out.println("fffffff2222222222222222222222222Save of generatedReport Success");
break;
}

//}
//break;
break;
}
}
}
@@ -9,7 +9,7 @@
<id name="id" type="java.lang.Integer" column="id" unsaved-value="0">
<generator class="native"/>
</id>
<property name="cohortReportConfigUuid" type="java.lang.String" column="cohort_report_config_id" not-null="true"/>
<property name="cohortReportConfigId" type="java.lang.Integer" column="cohort_report_config_id" not-null="true"/>
<property name="patientId" type="java.lang.Integer" column="patient_id" not-null="true"/>

<property name="reportRequestUuid" type="java.lang.String" column="report_request_uuid" length="38" not-null="true"/>
@@ -58,6 +58,10 @@
<constructor-arg ref="dbSessionFactory"/>
</bean>

<bean id="muzimaGeneratedReportDAO" class="org.openmrs.module.muzima.api.db.hibernate.HibernateMuzimaGeneratedReportDao">
<constructor-arg ref="dbSessionFactory"/>
</bean>

<!-- Services accessible via Context.getService() -->
<bean parent="serviceContext">
<property name="moduleService">
@@ -316,4 +320,29 @@
</list>
</property>
</bean>

<bean parent="serviceContext">
<property name="moduleService">
<list>
<value>org.openmrs.module.muzima.api.service.MuzimaGeneratedReportService</value>
<bean
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<bean class="org.openmrs.module.muzima.api.service.impl.MuzimaGeneratedReportServiceImpl">
<constructor-arg name="dao" ref="muzimaGeneratedReportDAO"/>
</bean>
</property>
<property name="preInterceptors">
<ref bean="serviceInterceptors" />
</property>
<property name="transactionAttributeSource">
<ref bean="transactionAttributeSource" />
</property>
</bean>
</list>
</property>
</bean>
</beans>
@@ -33,7 +33,7 @@
<class>org.openmrs.module.muzima.extension.html.AdminList</class>
</extension>

<!-- Maps hibernate file's, if present ReportConfiguration.hbm.xml -->
<!-- Maps hibernate file's, if present -->
<mappingFiles>
ArchiveData.hbm.xml
DataSource.hbm.xml
@@ -48,6 +48,7 @@
RegistrationData.hbm.xml
MuzimaSetting.hbm.xml
ReportConfiguration.hbm.xml
MuzimaGeneratedReport.hbm.xml
</mappingFiles>

<!-- Internationalization -->
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.