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

BS-258 | Changes from SNOMED Master to Product Master #87

Merged
merged 15 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/docker/bahmni-reports/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV SERVER_PORT=8051
ENV BASE_DIR=/var/run/bahmni-reports
ENV CONTEXT_PATH=/bahmnireports
ENV WAR_DIRECTORY=/var/run/bahmni-reports/bahmni-reports
ENV SERVER_OPTS="-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
ENV SERVER_OPTS="-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Dsun.net.client.defaultConnectTimeout=600000 -Dsun.net.client.defaultReadTimeout=600000"
ENV DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=8003,server=y,suspend=n"

RUN mkdir -p /var/log/bahmni-reports
Expand Down
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,22 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-adhoc</artifactId>
<version>${dynamicreports.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-googlecharts</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.bahmni.reports.extensions;

import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import org.apache.commons.lang3.StringUtils;

import java.util.Collection;
import java.util.Map;

public interface ResultSetExtension {
static final String EMPTY_STRING = "";

void enrich(Collection<Map<String, ?>> collection, JasperReportBuilder jasperReport) throws Exception;

default <T> void enrichRow(Map<String, T> rowMap, String columnName, String columnValue) {
if(StringUtils.isBlank(columnValue)){
columnValue = EMPTY_STRING;
}
rowMap.put(columnName, (T) columnValue);
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/bahmni/reports/model/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public class Constants {
public static final String OBSERVAIONFORMS = "forms";
public static final String LABORDERS = "labOrders";
public static final String FORM_BUILDER_FORMS = "formBuilder";
public static final String FHIR_TS_LOOKUP_DIAGNOSIS = "fhirTSLookupDiagnosis";
public static final String FHIR_TS_LOOKUP_DIAGNOSIS_COUNT = "fhirTSLookupDiagnosisCount";
public static final String FHIR_TS_LOOKUP_DIAGNOSIS_LINE = "fhirTSLookupDiagnosisLine";
}
3 changes: 2 additions & 1 deletion src/main/java/org/bahmni/reports/model/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
@JsonSubTypes.Type(value = MartConcatenatedReport.class, name = "MartConcatenated"),
@JsonSubTypes.Type(value = GenericLabOrderReport.class, name = LABORDERS),
@JsonSubTypes.Type(value = ObservationFormReport.class, name = FORM_BUILDER_FORMS),
@JsonSubTypes.Type(value = TSIntegrationDiagnosisReport.class, name = FHIR_TS_LOOKUP_DIAGNOSIS)
@JsonSubTypes.Type(value = TSIntegrationDiagnosisCountReport.class, name = FHIR_TS_LOOKUP_DIAGNOSIS_COUNT),
@JsonSubTypes.Type(value = TSIntegrationDiagnosisLineReport.class, name = FHIR_TS_LOOKUP_DIAGNOSIS_LINE)
})

public abstract class Report<T extends Config> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.bahmni.reports.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@JsonIgnoreProperties(ignoreUnknown = true)
public class TSIntegrationDiagnosisCountReportConfig extends TSIntegrationDiagnosisReportConfig implements Config {
private Boolean displayGenderGroup;

public Boolean isDisplayGenderGroup() {
return displayGenderGroup;
}

public void setDisplayGenderGroup(Boolean displayGenderGroup) {
this.displayGenderGroup = displayGenderGroup;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.bahmni.reports.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;


@JsonIgnoreProperties(ignoreUnknown = true)
public class TSIntegrationDiagnosisLineReportConfig extends TSIntegrationDiagnosisReportConfig implements Config {
private List<String> patientAttributes;
private List<String> patientAddresses;
private List<String> extensions;

public List<String> getPatientAttributes() {
return patientAttributes;
}

public void setPatientAttributes(List<String> patientAttributes) {
this.patientAttributes = patientAttributes;
}

public List<String> getPatientAddresses() {
return patientAddresses;
}

public void setPatientAddresses(List<String> patientAddresses) {
this.patientAddresses = patientAddresses;
}

public List<String> getExtensions() {
return extensions;
}

public void setExtensions(List<String> extensions) {
this.extensions = extensions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@JsonIgnoreProperties(ignoreUnknown = true)
public class TSIntegrationDiagnosisReportConfig implements Config {
public class TSIntegrationDiagnosisReportConfig {
private String tsConceptSource;
private String conceptNameDisplayFormat;
private String terminologyParentCode;
private String terminologyColumnName;
private Boolean displayTerminologyCode;
private Boolean displayGenderGroup;

public String getTsConceptSource() {
return tsConceptSource;
Expand Down Expand Up @@ -52,11 +50,5 @@ public void setTerminologyColumnName(String terminologyColumnName) {
this.terminologyColumnName = terminologyColumnName;
}

public Boolean isDisplayGenderGroup() {
return displayGenderGroup;
}

public void setDisplayGenderGroup(Boolean displayGenderGroup) {
this.displayGenderGroup = displayGenderGroup;
}
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/bahmni/reports/report/TSHttpClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.bahmni.reports.report;

import org.apache.http.config.Registry;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bahmni.reports.BahmniReportsConfiguration;
import org.bahmni.reports.BahmniReportsProperties;
import org.bahmni.webclients.HttpClient;

public interface TSHttpClient {
Logger logger = LogManager.getLogger(TSHttpClient.class);
final String TS_PROPERTIES_FILENAME = "terminology-service-config.properties";
final String TERMINOLOGY_SERVER_ENDPOINT_PROP = "terminologyServer.endpoint";

default HttpClient getHttpClient(BahmniReportsProperties bahmniReportsProperties) {
BahmniReportsConfiguration bahmniReportsConfiguration = new BahmniReportsConfiguration(bahmniReportsProperties);
SSLConnectionSocketFactory allTrustSSLSocketFactory = bahmniReportsConfiguration.allTrustSSLSocketFactory();
Registry<ConnectionSocketFactory> schemeRegistry = bahmniReportsConfiguration.schemeRegistry(allTrustSSLSocketFactory);
HttpClient httpClient = bahmniReportsConfiguration.httpClient(schemeRegistry);
return httpClient;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.bahmni.reports.report;


import org.bahmni.reports.BahmniReportsProperties;
import org.bahmni.reports.model.Report;
import org.bahmni.reports.model.TSIntegrationDiagnosisCountReportConfig;
import org.bahmni.reports.template.BaseReportTemplate;
import org.bahmni.reports.template.TSIntegrationDiagnosisCountReportTemplate;
import org.bahmni.reports.util.PropertyUtil;
import org.bahmni.webclients.HttpClient;

import java.util.Properties;

public class TSIntegrationDiagnosisCountReport extends Report<TSIntegrationDiagnosisCountReportConfig> implements TSHttpClient {

@Override
public BaseReportTemplate getTemplate(BahmniReportsProperties bahmniReportsProperties) {
HttpClient httpClient = getHttpClient(bahmniReportsProperties);
Properties tsProperties = PropertyUtil.loadProperties(TS_PROPERTIES_FILENAME);
String tsEndpointTemplate = bahmniReportsProperties.getOpenmrsRootUrl() + tsProperties.getProperty(TERMINOLOGY_SERVER_ENDPOINT_PROP);
return new TSIntegrationDiagnosisCountReportTemplate(httpClient, tsProperties, tsEndpointTemplate);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.bahmni.reports.report;


import org.bahmni.reports.BahmniReportsProperties;
import org.bahmni.reports.model.Report;
import org.bahmni.reports.model.TSIntegrationDiagnosisLineReportConfig;
import org.bahmni.reports.template.BaseReportTemplate;
import org.bahmni.reports.template.TSIntegrationDiagnosisLineReportTemplate;
import org.bahmni.reports.util.PropertyUtil;
import org.bahmni.webclients.HttpClient;


import java.util.Properties;

public class TSIntegrationDiagnosisLineReport extends Report<TSIntegrationDiagnosisLineReportConfig> implements TSHttpClient {
@Override
public BaseReportTemplate getTemplate(BahmniReportsProperties bahmniReportsProperties) {
HttpClient httpClient = getHttpClient(bahmniReportsProperties);
Properties tsProperties = PropertyUtil.loadProperties(TS_PROPERTIES_FILENAME);
String tsEndpointTemplate = bahmniReportsProperties.getOpenmrsRootUrl() + tsProperties.getProperty(TERMINOLOGY_SERVER_ENDPOINT_PROP);
return new TSIntegrationDiagnosisLineReportTemplate(httpClient, tsProperties, tsEndpointTemplate);
}

}

This file was deleted.

Loading
Loading