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

improve ASTM analyzers #28

Merged
merged 6 commits into from
Jun 14, 2024
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
5 changes: 5 additions & 0 deletions analyzers/GeneXpert/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"java.project.sourcePaths": [
"src/main/java"
]
}
15 changes: 5 additions & 10 deletions analyzers/GeneXpert/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openelisglobal.plugins</groupId>
<artifactId>GeneXpert</artifactId>
<artifactId>GeneXpertAnalyzer</artifactId>
<parent>
<groupId>org.openelisglobal</groupId>
<artifactId>openelisglobal-plugins</artifactId>
<version>1.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<version>0.3</version>
<version>0.4</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hapi.version>2.3</hapi.version>
Expand All @@ -25,14 +25,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-hl7overhttp</artifactId>
<version>${hapi.version}</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v25</artifactId>
<version>${hapi.version}</version>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* basis, WITHOUT WARRANTY OF ANY KIND, either eXNLress or implied. See the
* License for the specific language governing rights and limitations under
* the License.
*
Expand All @@ -20,39 +20,165 @@

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.openelisglobal.analyzerimport.analyzerreaders.AnalyzerLineInserter;
import org.openelisglobal.common.services.PluginAnalyzerService;
import org.openelisglobal.plugin.AnalyzerImporterPlugin;
import org.openelisglobal.analyzerimport.analyzerreaders.AnalyzerResponder;
import org.openelisglobal.common.log.LogEvent;

public class GeneXpertAnalyzer implements AnalyzerImporterPlugin {

public static final String ANALYZER_NAME = "GeneXpertAnalyzer";

@Override
public boolean connect() {
@Override
public boolean connect() {
List<PluginAnalyzerService.TestMapping> nameMapping = new ArrayList<>();
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.HBV, "HEPATITIS B VIRAL LOAD",
GeneXpertAnalyzerImplementation.HBV_LOINC));
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_WBC, "White Blood Cells Count (WBC)",
GeneXpertAnalyzerImplementation.LOINC_WBC));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RBC, "Red Blood Cells Count (RBC)",
GeneXpertAnalyzerImplementation.LOINC_RBC));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_HGB, "Hemoglobin",
GeneXpertAnalyzerImplementation.LOINC_HGB));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_HCT, "Hematocrit",
GeneXpertAnalyzerImplementation.LOINC_HCT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MCV, "Medium corpuscular volum",
GeneXpertAnalyzerImplementation.LOINC_MCV));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.HCV, "HEPATITIS C VIRAL LOAD",
GeneXpertAnalyzerImplementation.HCV_LOINC));
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MCH, "",
GeneXpertAnalyzerImplementation.LOINC_MCH));
nameMapping
.add(new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MCHC, "",
GeneXpertAnalyzerImplementation.LOINC_MCHC));
nameMapping
.add(new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RDWSD, "",
GeneXpertAnalyzerImplementation.LOINC_RDWSD));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.HIV_QUAL, "​Xpert HIV-1 Qual",
GeneXpertAnalyzerImplementation.HIV_QUAL_LOINC));
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RDWCV, "",
GeneXpertAnalyzerImplementation.LOINC_RDWCV));
nameMapping
.add(new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.HIV_VIRAL, "HIV VIRAL LOAD",
GeneXpertAnalyzerImplementation.HIV_VIRAL_LOINC));
.add(new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_PLT, "Platelets",
GeneXpertAnalyzerImplementation.LOINC_PLT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MPV, "",
GeneXpertAnalyzerImplementation.LOINC_MPV));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_NEUT_COUNT, "Neutrophiles",
GeneXpertAnalyzerImplementation.LOINC_NEUT_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_NEUT_PERCENT, "Neutrophiles (%)",
GeneXpertAnalyzerImplementation.LOINC_NEUT_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_LYMPH_COUNT, "Lymphocytes (Abs)",
GeneXpertAnalyzerImplementation.LOINC_LYMPH_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_LYMPH_PERCENT, "Lymphocytes (%)",
GeneXpertAnalyzerImplementation.LOINC_LYMPH_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MONO_COUNT, "Monocytes (Abs)",
GeneXpertAnalyzerImplementation.LOINC_MONO_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MONO_PERCENT, "Monocytes (%)",
GeneXpertAnalyzerImplementation.LOINC_MONO_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_EO_COUNT, "Eosinophiles",
GeneXpertAnalyzerImplementation.LOINC_EO_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_EO_PERCENT, "Eosinophiles (%)",
GeneXpertAnalyzerImplementation.LOINC_EO_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_BASO_COUNT, "Basophiles",
GeneXpertAnalyzerImplementation.LOINC_BASO_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_BASO_PERCENT, "Basophiles (%)",
GeneXpertAnalyzerImplementation.LOINC_BASO_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_IG_COUNT, "",
GeneXpertAnalyzerImplementation.LOINC_IG_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_IG_PERCENT, "",
GeneXpertAnalyzerImplementation.LOINC_IG_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.COV_2, "COVID-19 PCR",
GeneXpertAnalyzerImplementation.COV_2_LOINC));
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RET_COUNT, "",
GeneXpertAnalyzerImplementation.LOINC_RET_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RET_PERCENT, "",
GeneXpertAnalyzerImplementation.LOINC_RET_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_IRF, "",
GeneXpertAnalyzerImplementation.LOINC_IRF));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RETHE, "",
GeneXpertAnalyzerImplementation.LOINC_RETHE));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_WBCBF, "",
GeneXpertAnalyzerImplementation.LOINC_WBCBF));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_RBCBF, "",
GeneXpertAnalyzerImplementation.LOINC_RBCBF));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MN_COUNT, "",
GeneXpertAnalyzerImplementation.LOINC_MN_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_MN_PERCENT, "",
GeneXpertAnalyzerImplementation.LOINC_MN_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_PMN_COUNT, "",
GeneXpertAnalyzerImplementation.LOINC_PMN_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_PMN_PERCENT, "",
GeneXpertAnalyzerImplementation.LOINC_PMN_PERCENT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(GeneXpertAnalyzerImplementation.ANALYZER_TEST_TCBF_COUNT, "",
GeneXpertAnalyzerImplementation.LOINC_TCBF_COUNT));
getInstance().addAnalyzerDatabaseParts("GeneXpertAnalyzer", "GeneXpertAnalyzer", nameMapping, true);
getInstance().registerAnalyzer(this);
return true;
}

@Override
// this plugin does not work for flat files, so we disable it in that workflow
public boolean isTargetAnalyzer(List<String> lines) {
for (String line : lines) {
if (line.startsWith(GeneXpertAnalyzerImplementation.HEADER_RECORD_IDENTIFIER)) {
String[] headerRecord = line.split(Pattern.quote(GeneXpertAnalyzerImplementation.FD));
if (headerRecord.length < 5) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not GeneXpert: header record not long enough");
return false;
}
String[] senderNameFields = headerRecord[4].split(Pattern.quote(GeneXpertAnalyzerImplementation.CD));
if (senderNameFields.length < 2) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not GeneXpert: sender name field not long enough");
return false;
}
String systemName = senderNameFields[1].trim();

LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message analyzer name is " + systemName);
if (systemName.equalsIgnoreCase("GeneXpert")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is GeneXpert ");
return true;
}
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not GeneXpert: sender name doesn't match");
return false;
}
}
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not GeneXpert: no header line");
return false;
}

@Override
public boolean isAnalyzerResult(List<String> lines) {
for (String line : lines) {
if (line.startsWith(GeneXpertAnalyzerImplementation.RESULT_RECORD_IDENTIFIER)) {
return true;
}
}
LogEvent.logDebug(this.getClass().getSimpleName(), "isAnalyzerResult", "no result recoord identifier located");
return false;
}

Expand All @@ -61,4 +187,9 @@ public AnalyzerLineInserter getAnalyzerLineInserter() {
return new GeneXpertAnalyzerImplementation();
}

@Override
public AnalyzerResponder getAnalyzerResponder() {
return new GeneXpertAnalyzerImplementation();
}

}
Loading
Loading