Skip to content

Commit

Permalink
modify sysmex analyzers under development
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebSLane committed Jun 14, 2024
1 parent b93a71c commit c227043
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 127 deletions.
2 changes: 1 addition & 1 deletion analyzers/SysmexXN-L/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>

<version>0.3</version>
<version>0.5</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hapi.version>2.3</hapi.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@

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 oe.plugin.analyzer.SysmexXNLAnalyzerImplementation;
import org.openelisglobal.analyzerimport.analyzerreaders.AnalyzerResponder;
import org.openelisglobal.common.log.LogEvent;

public class SysmexXNLAnalyzer implements AnalyzerImporterPlugin {

public static final String ANALYZER_NAME = "SysmexXNLAnalyzer";

@Override
public boolean connect() {
List<PluginAnalyzerService.TestMapping> nameMapping = new ArrayList<>();
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_WBC, "White Blood Cells Count",
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_WBC, "White Blood Cells Count (WBC)",
SysmexXNLAnalyzerImplementation.LOINC_WBC));
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_RBC, "Red Blood Cells Count",
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_RBC, "Red Blood Cells Count (RBC)",
SysmexXNLAnalyzerImplementation.LOINC_RBC));
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_HGB, "Hemoglobin",
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_HGB, "Hemoglobin",
SysmexXNLAnalyzerImplementation.LOINC_HGB));
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_HCT, "Hematocrit",
Expand All @@ -67,7 +69,7 @@ public boolean connect() {
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_MPV, "",
SysmexXNLAnalyzerImplementation.LOINC_MPV));
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_NEUT_COUNT, "Neutrophiles",
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_NEUT_COUNT, "Neutrophiles",
SysmexXNLAnalyzerImplementation.LOINC_NEUT_COUNT));
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_NEUT_PERCENT, "Neutrophiles (%)",
Expand Down Expand Up @@ -135,7 +137,7 @@ public boolean connect() {
nameMapping.add(
new PluginAnalyzerService.TestMapping(SysmexXNLAnalyzerImplementation.ANALYZER_TEST_TCBF_COUNT, "",
SysmexXNLAnalyzerImplementation.LOINC_TCBF_COUNT));
getInstance().addAnalyzerDatabaseParts("SysmexXNLAnalyzer", "SysmexXNLAnalyzer", nameMapping, true);
getInstance().addAnalyzerDatabaseParts(ANALYZER_NAME, ANALYZER_NAME, nameMapping, true);
getInstance().registerAnalyzer(this);
return true;
}
Expand All @@ -144,39 +146,41 @@ public boolean connect() {
public boolean isTargetAnalyzer(List<String> lines) {
for (String line : lines) {
if (line.startsWith(SysmexXNLAnalyzerImplementation.HEADER_RECORD_IDENTIFIER)) {
String[] headerRecord = line.split(SysmexXNLAnalyzerImplementation.DEFAULT_FIELD_DELIMITER);
String[] headerRecord = line.split(Pattern.quote(SysmexXNLAnalyzerImplementation.FD));
if (headerRecord.length < 5) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not SysmexXN: header record not long enough");
return false;
}
String[] senderName = headerRecord[4].split(SysmexXNLAnalyzerImplementation.DEFAULT_SUBFIELD_DELIMITER);
if (senderName.length < 1) {
String[] senderNameFields = headerRecord[4].split(Pattern.quote(SysmexXNLAnalyzerImplementation.CD));
if (senderNameFields.length < 1) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is not SysmexXN: sender name field not long enough");
return false;
}
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message analyzer name is " + senderName[0]);
if (senderName[0].equalsIgnoreCase("XN-550")) {
String senderName = senderNameFields[0].trim();

LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message analyzer name is " + senderName);
if (senderName.equalsIgnoreCase("XN-550")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-530")) {
} else if (senderName.equalsIgnoreCase("XN-530")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-450")) {
} else if (senderName.equalsIgnoreCase("XN-450")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-430")) {
} else if (senderName.equalsIgnoreCase("XN-430")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-350")) {
} else if (senderName.equalsIgnoreCase("XN-350")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-330")) {
} else if (senderName.equalsIgnoreCase("XN-330")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-150")) {
} else if (senderName.equalsIgnoreCase("XN-150")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
} else if (senderName[0].equalsIgnoreCase("XN-110")) {
} else if (senderName.equalsIgnoreCase("XN-110")) {
LogEvent.logTrace(this.getClass().getSimpleName(), "isTargetAnalyzer", "incoming message is SysmexXN (XN-350)");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import java.util.regex.Pattern;
import java.util.Optional;

import org.apache.commons.validator.GenericValidator;
Expand Down Expand Up @@ -144,9 +144,10 @@ public class SysmexXNLAnalyzerImplementation extends AnalyzerLineInserter implem
protected static final String ORDER_RECORD_IDENTIFIER = "O";
protected static final String RESULT_RECORD_IDENTIFIER = "R";
protected static final String END_RECORD_IDENTIFIER = "L";
protected static final String DEFAULT_FIELD_DELIMITER = "\\|";
protected static final String DEFAULT_SUBFIELD_DELIMITER = "\\^";
protected static final String DEFAULT_REPEATER_DELIMITER = "\\\\";
protected static final String FD = "|"; //DEFAULT_FIELD_DELIMITER
protected static final String CD = "^"; //DEFAULT_COMPONENT_DELIMITER
protected static final String RD = "\\"; //DEFAULT_REPEATER_DELIMITER
protected static final String ED = "&"; //DEFAULT_ESCAPE_DELIMITER
protected static final String TEST_COMMUNICATION_IDENTIFIER = "M|1|106";

private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Expand Down Expand Up @@ -213,7 +214,7 @@ public SysmexXNLAnalyzerImplementation() {
testCodeToTestsMap.put(entry.getKey(), testService.getTestsByLoincCode(entry.getValue()));
}

Analyzer analyzer = analyzerService.getAnalyzerByName("SysmexXNLAnalyzer");
Analyzer analyzer = analyzerService.getAnalyzerByName(SysmexXNLAnalyzer.ANALYZER_NAME);
ANALYZER_ID = analyzer.getId();
}

Expand Down Expand Up @@ -270,7 +271,7 @@ public boolean insert(List<String> lines, String currentUserId) {

@Override
public String getError() {
return "SysmexXNLAnalyzer analyzer unable to write to database";
return SysmexXNLAnalyzer.ANALYZER_NAME + " analyzer unable to write to database";
}

private Test findMatchingTest(Sample sample, String resultTestCode) {
Expand Down Expand Up @@ -301,16 +302,16 @@ private Test findMatchingTest(Sample sample, String resultTestCode) {
// R|1|^^^^WBC^1|7.80|10*3/uL||N||||||20011116101000<CR>
private void addRecordsToResults(String patientRecord, String orderRecord, String resultRecord,
List<AnalyzerResults> results, String currentUserId) {
String[] patientRecordFields = patientRecord.split(DEFAULT_FIELD_DELIMITER);
String[] orderRecordFields = orderRecord.split(DEFAULT_FIELD_DELIMITER);
String[] orderTestIdFields = orderRecordFields[4].split(DEFAULT_REPEATER_DELIMITER);
String[] orderIdFields = orderRecordFields[3].split(DEFAULT_SUBFIELD_DELIMITER);
String[] resultRecordFields = resultRecord.split(DEFAULT_FIELD_DELIMITER);
String[] resultTestIdField = resultRecordFields[2].split(DEFAULT_SUBFIELD_DELIMITER);
String[] patientRecordFields = patientRecord.split(Pattern.quote(FD));
String[] orderRecordFields = orderRecord.split(Pattern.quote(FD));
String[] orderTestIdFields = orderRecordFields[4].split(Pattern.quote(RD));
String[] orderIdFields = orderRecordFields[3].split(Pattern.quote(CD));
String[] resultRecordFields = resultRecord.split(Pattern.quote(FD));
String[] resultTestIdField = resultRecordFields[2].split(Pattern.quote(CD));
String resultRecordAbnormalFlag = resultRecordFields[6];
List<String> orderTestIds = new ArrayList<>();
for (String orderIdField : orderTestIdFields) {
String[] orderIds = orderIdField.split(DEFAULT_SUBFIELD_DELIMITER);
String[] orderIds = orderIdField.split(Pattern.quote(CD));
String orderTestId = orderIds.length >= 5 ? orderIds[4] : "";
if (GenericValidator.isBlankOrNull(orderTestId)) {
LogEvent.logWarn(this.getClass().getSimpleName(), "addRecordsToResults", "order analysis parameter name is not present");
Expand Down Expand Up @@ -427,7 +428,7 @@ public String buildResponse(List<String> lines) {

for (String line : lines) {
if (line.startsWith(TEST_COMMUNICATION_IDENTIFIER)) {
LogEvent.logInfo(this.getClass().getName(), "buildResponse", "this is a test communication record for Sysmex-XNL");
LogEvent.logInfo(this.getClass().getName(), "buildResponse", "this is a test communication record for " + SysmexXNLAnalyzer.ANALYZER_NAME);
}
if (line.startsWith(QUERY_RECORD_IDENTIFIER)) {
LogEvent.logDebug(this.getClass().getName(), "buildResponse", "request contains query record");
Expand All @@ -441,10 +442,10 @@ public String buildResponse(List<String> lines) {

private String generateQueryResponse(String queryRecord) {
LogEvent.logDebug(this.getClass().getSimpleName(), "generateQueryResponse", "generating query response");
String[] queryRecordFields = queryRecord.split(DEFAULT_FIELD_DELIMITER);
String[] queryRecordFields = queryRecord.split(Pattern.quote(FD));

String[] startingRangeIdNumber = queryRecordFields[3].split(DEFAULT_SUBFIELD_DELIMITER);
String sampleIdNo = startingRangeIdNumber[2];
String[] startingRangeIdNumber = queryRecordFields[2].split(Pattern.quote(CD));
String sampleIdNo = startingRangeIdNumber[2].trim();
String sampleNoAttribute = startingRangeIdNumber[3];

StringBuilder msgBuilder = new StringBuilder();
Expand All @@ -456,8 +457,8 @@ private String generateQueryResponse(String queryRecord) {
//return could not find sample messager
return msgBuilder.append("H|\\^&|\r\n")
.append("P|1|\r\n")
.append("O|1||||||||||||||||||||||||Y/r/n") //"Y" is no order exists marker
.append("L|1|N/r/n").toString();
.append("O|1||||||||||||||||||||||||Y\r\n") //"Y" is no order exists marker
.append("L|1|N\r\n").toString();
}
Patient patient = sampleHumanService.getPatientForSample(sample);
Person person = patient.getPerson();
Expand Down Expand Up @@ -487,8 +488,8 @@ private String generateQueryResponse(String queryRecord) {
}
msgBuilder.append("||")
.append(sample.getEnteredDate() == null ? "" : dateTimeFormat.format(sample.getEnteredDate()))
.append("|||||N||||||||||||||Q/r/n");
msgBuilder.append("L|1|N/r/n");
.append("|||||N||||||||||||||Q\r\n");
msgBuilder.append("L|1|N\r\n");
return msgBuilder.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ protected void insertMenu() {
// The order this analyzer will show on the menu relative to other analyzers
menu.setPresentationOrder(10);
// The id needs to be unique in the system
menu.setElementId("httpanalyzer_plugin");
menu.setElementId(SysmexXNLAnalyzer.ANALYZER_NAME + "_plugin");
// This will always be "/AnalyzerResults?type=<The name of the analyzer in
// the database as specified in then Analyzer class call to
// addAnalyzerDatabaseParts(....)
menu.setActionURL("/AnalyzerResults?type=SysmexXNLAnalyzer");
menu.setActionURL("/AnalyzerResults?type=" + SysmexXNLAnalyzer.ANALYZER_NAME);
// The key used for the name of the analyzer on the menu. Should not already
// exist in MessageResource.properties.
menu.setDisplayKey("banner.menu.results.SysmexXNLanalyzer");
menu.setDisplayKey("banner.menu.results." + SysmexXNLAnalyzer.ANALYZER_NAME);
menu.setOpenInNewWindow(false);

service.addMenu(menu);
// Analyzer name in English
service.insertLanguageKeyValue("banner.menu.results.SysmexXNLAnalyzer", "SysmexXNLAnalyzer",
service.insertLanguageKeyValue("banner.menu.results." + SysmexXNLAnalyzer.ANALYZER_NAME, SysmexXNLAnalyzer.ANALYZER_NAME,
Locale.ENGLISH.toLanguageTag());
// Analyzer name in French
service.insertLanguageKeyValue("banner.menu.results.SysmexXNLAnalyzer", "SysmexXNLAnalyzer",
service.insertLanguageKeyValue("banner.menu.results." + SysmexXNLAnalyzer.ANALYZER_NAME, SysmexXNLAnalyzer.ANALYZER_NAME,
Locale.FRENCH.toLanguageTag());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class SysmexXNLAnalyzerPermission extends PermissionPlugin {
@Override
protected boolean insertPermission(){
IPluginPermissionService service = SpringContext.getBean(IPluginPermissionService.class);
SystemModule module = service.getOrCreateSystemModule("AnalyzerResults", "SysmexXNLAnalyzer",
"Results->Analyzer->SysmexXNLAnalyzer");
SystemModule module = service.getOrCreateSystemModule("AnalyzerResults", SysmexXNLAnalyzer.ANALYZER_NAME,
"Results->Analyzer->" + SysmexXNLAnalyzer.ANALYZER_NAME);
Role role = service.getSystemRole( "Results" );
return service.bindRoleToModule( role, module );
}
Expand Down
2 changes: 1 addition & 1 deletion analyzers/SysmexXP/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>

<version>0.3</version>
<version>0.5</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<hapi.version>2.3</hapi.version>
Expand Down
Loading

0 comments on commit c227043

Please sign in to comment.