Skip to content

Commit

Permalink
Profile extension support added
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbeor committed Nov 19, 2024
1 parent 2da6644 commit 9cc7e78
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ interface IIncomingMessageHandler {
String RSP_Z31_MULTIPLE_MATCH = "Z31";
String RSP_Z33_NO_MATCH = "Z33";
String Z23_ACKNOWLEDGEMENT = "Z23";
String Z22_ADVANCED_VXU = "Z22_ADV_ACK";
String Z23_ADVANCED_ACKNOWLEDGEMENT = "Z22_ADV_ACK";
String VXU_Z22 = "Z22^CDCPHINVS";
String Z22_ACK = "Z23^CDCPHINVS";
String ADVANCED_ACK = "ADVANCED_ACK";
String Z22_ADVANCED_VXU = VXU_Z22 + "~" + ADVANCED_ACK;
String Z23_ADVANCED_ACKNOWLEDGEMENT = "Z23^CDCPHINVS" + "~" + ADVANCED_ACK;
String QUERY_OK = "OK";
// TODO:
// Organize logic classes, need to have access classes for every object, maybe a new Access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,31 @@ public String buildAck(HL7Reader reader, List<ProcessingException> processingExc
return sb.toString();
}

public String buildAckMqe(MqeMessageServiceResponse mqeMessageServiceResponse, List<ProcessingException> processingExceptionList, Set<ProcessingFlavor> processingFlavorSet, List<IisReportable> validatorReportables) {
public String buildAckMqe(HL7Reader reader, MqeMessageServiceResponse mqeMessageServiceResponse, List<ProcessingException> processingExceptionList, Set<ProcessingFlavor> processingFlavorSet, List<IisReportable> validatorReportables) {
IisAckBuilder ackBuilder = IisAckBuilder.INSTANCE;
IisAckData data = new IisAckData();
MqeMessageHeader header = mqeMessageServiceResponse.getMessageObjects().getMessageHeader();
String profile = header.getMessageProfile();
if (profile.equals(Z22_ADVANCED_VXU)) {
data.setProfileId(Z23_ADVANCED_ACKNOWLEDGEMENT);
String profileId = header.getMessageProfile();
reader.resetPostion();
reader.advanceToSegment("MSH");
String profileExtension = null;
int count = reader.getRepeatCount(21);
if (count > 1) {
profileExtension = reader.getValueRepeat(21, 1, 2);
if (profileExtension.equals(ADVANCED_ACK)) {
data.setProfileExtension(ADVANCED_ACK);
} // else not supported
}
if (profileId.equals(VXU_Z22)) {
data.setProfileId(Z23_ACKNOWLEDGEMENT);
} else if (profileId.equals(QBP_Z34)) {
data.setProfileId(RSP_Z33_NO_MATCH);

} else {
data.setProfileId(Z23_ACKNOWLEDGEMENT);
}


List<ValidationRuleResult> resultList = mqeMessageServiceResponse.getValidationResults();
List<IisReportable> reportables = new ArrayList<>(validatorReportables);
reportables.addAll(processingExceptionList.stream().map(IisReportable::new).collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public String process(String message, Tenant tenant, String sendingFacilityName)
public String processVXU(Tenant tenant, HL7Reader reader, String message, Organization managingOrganization) throws Exception {
List<ProcessingException> processingExceptionList = new ArrayList<>();
Set<ProcessingFlavor> processingFlavorSet = tenant.getProcessingFlavorSet();
String profileIdentifier = reader.getValue(21);
MqeMessageServiceResponse mqeMessageServiceResponse = mqeMessageService.processMessage(message);
List<IisReportable> nistReportables = nistValidation(message);

Expand Down Expand Up @@ -377,14 +376,14 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi
if (processingFlavorSet.contains(ProcessingFlavor.BILBERRY) && (vaccinationCount == 0 && refusalCount == 0)) {
throw new ProcessingException("Patient vaccination history cannot be accepted without at least one administered, historical, or refused vaccination specified", "", 0, 0);
}
String ack = buildAckMqe(mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
recordMessageReceived(message, patientReported, ack, "Update", "Ack", tenant);
return ack;
} catch (ProcessingException e) {
if (!processingExceptionList.contains(e)) {
processingExceptionList.add(e);
}
String ack = buildAckMqe(mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
recordMessageReceived(message, null, ack, "Update", "Exception", tenant);
return ack;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi
if (processingFlavorSet.contains(ProcessingFlavor.BILBERRY) && (vaccinationCount == 0 && refusalCount == 0)) {
throw new ProcessingException("Patient vaccination history cannot be accepted without at least one administered, historical, or refused vaccination specified", "", 0, 0);
}
String ack = buildAckMqe(mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
recordMessageReceived(message, patientReported, ack, "Update", "Ack", tenant);
return ack;
} catch (ProcessingException e) {
if (!processingExceptionList.contains(e)) {
processingExceptionList.add(e);
}
String ack = buildAckMqe(mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables);
recordMessageReceived(message, null, ack, "Update", "Exception", tenant);
return ack;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.immregistries.iis.kernal.logic.ack;

import org.apache.commons.lang3.StringUtils;
import org.immregistries.mqe.hl7util.builder.AckResult;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -38,7 +39,7 @@ public String buildAckFrom(IisAckData ackDataIn) {
ackCode = AckResult.APP_ACCEPT.getCode();
}
StringBuilder ack = new StringBuilder();
makeHeader(ack, ackDataIn, "Z23", null);
makeHeader(ack, ackDataIn, StringUtils.defaultIfBlank(ackDataIn.getProfileId(), "Z23"), null);
// ack.append("SFT|" + SoftwareVersion.VENDOR + "|" +
// SoftwareVersion.VERSION + "|" + SoftwareVersion.PRODUCT + "|" +
// SoftwareVersion.BINARY_ID
Expand Down Expand Up @@ -109,6 +110,7 @@ private static boolean hasErrorSeverityType(IisAckData ackDataIn, String severit

public static void makeHeader(StringBuilder ack, IisAckData ackDataIn, String profileId,
String responseType) {
String profileExtension = ackDataIn.getProfileExtension();
String receivingApplication = ackDataIn.getSendingApplication();
String receivingFacility = ackDataIn.getSendingFacility();
String sendingApplication = ackDataIn.getReceivingApplication();
Expand Down Expand Up @@ -147,7 +149,11 @@ public static void makeHeader(StringBuilder ack, IisAckData ackDataIn, String pr
ack.append("|2.5.1"); // MSH-12 Version ID
ack.append("|");
if (profileId != null) {
ack.append("||NE|NE|||||" + profileId + "^CDCPHINVS|");
ack.append("||NE|NE|||||").append(profileId).append("^CDCPHINVS");
if (StringUtils.isNotBlank(profileExtension)) {
ack.append("~").append(profileExtension).append("^CDCPHINVS");
}
ack.append("|");
}
ack.append("\r");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class IisAckData {
private Date messageDate = new Date();
private String responseType = "";
private String profileId = "";
private String profileExtension = "";

public IisAckData() {
}
Expand Down Expand Up @@ -146,4 +147,12 @@ public String getProfileId() {
public void setProfileId(String profileId) {
this.profileId = profileId;
}

public String getProfileExtension() {
return profileExtension;
}

public void setProfileExtension(String profileExtension) {
this.profileExtension = profileExtension;
}
}

0 comments on commit 9cc7e78

Please sign in to comment.