From 490d0b019cd86a4fcb3a904e3c57c87605135083 Mon Sep 17 00:00:00 2001 From: Clement Hennequin Date: Wed, 20 Nov 2024 15:31:19 -0500 Subject: [PATCH] Infrastrucutre progress for ERR-5 code --- .../InternalClient/FhirRequesterR4.java | 9 +- .../kernal/logic/IIncomingMessageHandler.java | 5 +- .../kernal/logic/IncomingMessageHandler.java | 92 +++++++++---------- .../logic/IncomingMessageHandlerR4.java | 42 ++++----- .../logic/IncomingMessageHandlerR5.java | 47 +++++----- .../iis/kernal/logic/ProcessingException.java | 15 ++- .../logic/ack/Err5ApplicationCodes.java | 4 + .../iis/kernal/logic/ack/IisReportable.java | 8 ++ 8 files changed, 122 insertions(+), 100 deletions(-) create mode 100644 src/main/java/org/immregistries/iis/kernal/logic/ack/Err5ApplicationCodes.java diff --git a/src/main/java/org/immregistries/iis/kernal/InternalClient/FhirRequesterR4.java b/src/main/java/org/immregistries/iis/kernal/InternalClient/FhirRequesterR4.java index 1de20ad6..f1c3a9a9 100644 --- a/src/main/java/org/immregistries/iis/kernal/InternalClient/FhirRequesterR4.java +++ b/src/main/java/org/immregistries/iis/kernal/InternalClient/FhirRequesterR4.java @@ -203,10 +203,15 @@ public RelatedPerson searchRelatedPerson(SearchParameterMap searchParameterMap) return relatedPerson; } - public PatientReported savePatientReported(PatientReported patientReported) { + public MethodOutcome savePatientReportedMethodOutcome(PatientReported patientReported) { Patient patient = patientMapper.getFhirResource(patientReported); - MethodOutcome outcome = save(patient, + return save(patient, Patient.IDENTIFIER.exactly().systemAndIdentifier(patientReported.getPatientReportedAuthority(), patientReported.getExternalLink())); + } + + public PatientReported savePatientReported(PatientReported patientReported) { + MethodOutcome outcome = savePatientReportedMethodOutcome(patientReported); + logger.info("created {} resource {}", outcome.getCreated(), outcome.getResource()); if (!outcome.getResource().isEmpty()) { patientReported.setPatientId(outcome.getResource().getIdElement().getIdPart()); return patientMapper.getReportedWithMaster((Patient) outcome.getResource()); diff --git a/src/main/java/org/immregistries/iis/kernal/logic/IIncomingMessageHandler.java b/src/main/java/org/immregistries/iis/kernal/logic/IIncomingMessageHandler.java index dd7ac604..dbcd3a82 100644 --- a/src/main/java/org/immregistries/iis/kernal/logic/IIncomingMessageHandler.java +++ b/src/main/java/org/immregistries/iis/kernal/logic/IIncomingMessageHandler.java @@ -1,5 +1,6 @@ package org.immregistries.iis.kernal.logic; +import org.immregistries.iis.kernal.logic.ack.IisReportable; import org.immregistries.iis.kernal.model.PatientMaster; import org.immregistries.iis.kernal.model.ProcessingFlavor; import org.immregistries.iis.kernal.model.Tenant; @@ -23,8 +24,6 @@ public interface IIncomingMessageHandler { String Z23_ACKNOWLEDGEMENT = "Z23"; String VXU_Z22 = "Z22"; 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 @@ -39,6 +38,6 @@ public interface IIncomingMessageHandler { List getVaccinationMasterList(PatientMaster patient); - String buildAck(HL7Reader reader, List processingExceptionList, Set processingFlavorSetå); + String buildAck(HL7Reader reader, List processingExceptionList, Set processingFlavorSetå); } diff --git a/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandler.java b/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandler.java index 02fc5bf6..fba6eabb 100644 --- a/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandler.java +++ b/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandler.java @@ -131,14 +131,15 @@ public IncomingMessageHandler() { } } - public void verifyNoErrors(List processingExceptionList) throws ProcessingException { - for (ProcessingException pe : processingExceptionList) { - if (pe.isError()) { - throw pe; + public void verifyNoErrors(List processingExceptionList) throws ProcessingException { + for (IisReportable pe : processingExceptionList) { + if (pe.getSeverity().equals(IisReportableSeverity.ERROR)) { + throw new ProcessingException(pe); } } } + public boolean hasErrors(List reportables) { for (IisReportable pe : reportables) { if (pe.getSeverity().equals(IisReportableSeverity.ERROR)) { @@ -216,7 +217,7 @@ public List doForecast(PatientMaster patient, CodeMap codeMap, L return forecastActualList; } - public String buildAck(HL7Reader reader, List processingExceptionList, Set processingFlavorSet) { + public String buildAck(HL7Reader reader, List processingExceptionList, Set processingFlavorSet) { StringBuilder sb = new StringBuilder(); { String messageType = "ACK^V04^ACK"; @@ -226,8 +227,8 @@ public String buildAck(HL7Reader reader, List processingExc // if processing flavor contains MEDLAR then all the non E errors have to removed from the processing list if (processingFlavorSet != null && processingFlavorSet.contains(ProcessingFlavor.MEDLAR)) { - List tempProcessingExceptionList = new ArrayList(); - for (ProcessingException pe : processingExceptionList) { + List tempProcessingExceptionList = new ArrayList(); + for (IisReportable pe : processingExceptionList) { if (pe.isError()) { tempProcessingExceptionList.add(pe); } @@ -246,7 +247,7 @@ public String buildAck(HL7Reader reader, List processingExc sendersUniqueId = "MSH-10 NOT VALUED"; } String overallStatus = "AA"; - for (ProcessingException pe : processingExceptionList) { + for (IisReportable pe : processingExceptionList) { if (pe.isError() || pe.isWarning()) { overallStatus = "AE"; break; @@ -254,13 +255,13 @@ public String buildAck(HL7Reader reader, List processingExc } sb.append("MSA|").append(overallStatus).append("|").append(sendersUniqueId).append("\r"); - for (ProcessingException pe : processingExceptionList) { - sb.append(IisHL7Util.makeERRSegment(new IisReportable(pe), false)); + for (IisReportable pe : processingExceptionList) { + sb.append(IisHL7Util.makeERRSegment(pe, false)); } return sb.toString(); } - public String buildAckMqe(HL7Reader reader, MqeMessageServiceResponse mqeMessageServiceResponse, List processingExceptionList, Set processingFlavorSet, List validatorReportables) { + public String buildAckMqe(HL7Reader reader, MqeMessageServiceResponse mqeMessageServiceResponse, List processingExceptionList, Set processingFlavorSet, List validatorReportables) { IisAckBuilder ackBuilder = IisAckBuilder.INSTANCE; IisAckData data = new IisAckData(); MqeMessageHeader header = mqeMessageServiceResponse.getMessageObjects().getMessageHeader(); @@ -287,7 +288,7 @@ public String buildAckMqe(HL7Reader reader, MqeMessageServiceResponse mqeMessage List resultList = mqeMessageServiceResponse.getValidationResults(); List reportables = new ArrayList<>(validatorReportables); - reportables.addAll(processingExceptionList.stream().map(IisReportable::new).collect(Collectors.toList())); + reportables.addAll(processingExceptionList); /* This code needs to get put somewhere better. */ for (ValidationRuleResult result : resultList) { reportables.addAll(result.getValidationDetections().stream().map(IisReportable::new).collect(Collectors.toList())); @@ -359,18 +360,6 @@ public Date parseDateWarn(String dateString, String errorMessage, String segment return null; } - public Date parseDateWarnOld(String dateString, String errorMessage, String segmentId, int segmentRepeat, int fieldPosition, boolean strict, List processingExceptionList) { - try { - return parseDateInternal(dateString, strict); - } catch (ParseException e) { - if (errorMessage != null) { - ProcessingException pe = new ProcessingException(errorMessage + ": " + e.getMessage(), segmentId, segmentRepeat, fieldPosition).setWarning(); - processingExceptionList.add(pe); - } - } - return null; - } - public Date parseDateError(String dateString, String errorMessage, String segmentId, int segmentRepeat, int fieldPosition, boolean strict) throws ProcessingException { try { Date date = parseDateInternal(dateString, strict); @@ -943,7 +932,7 @@ public String buildRSP(HL7Reader reader, String messageReceived, PatientMaster p return messageResponse; } - public int readAndCreateObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination) { + public int readAndCreateObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination) { while (reader.advanceToSegment("OBX", "ORC")) { obxCount++; String identifierCode = reader.getValue(3); @@ -956,19 +945,19 @@ public int readAndCreateObservations(HL7Reader reader, List if (contraCode == null) { ProcessingException pe = new ProcessingException("Unrecognized contraindication or precaution", "OBX", obxCount, 5); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } if (observationReported.getObservationDate() != null) { Date today = new Date(); if (observationReported.getObservationDate().after(today)) { ProcessingException pe = new ProcessingException("Contraindication or precaution observed in the future", "OBX", obxCount, 5); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } if (patientReported.getBirthDate() != null && observationReported.getObservationDate().before(patientReported.getBirthDate())) { ProcessingException pe = new ProcessingException("Contraindication or precaution observed before patient was born", "OBX", obxCount, 14); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } } @@ -983,7 +972,7 @@ public int readAndCreateObservations(HL7Reader reader, List return obxCount; } - public abstract ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode); + public abstract ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode); public List nistValidation(String message, String profileId) throws Exception { @@ -1057,7 +1046,7 @@ public void addErrorLocation(IisReportable reportable, String path) { } - public PatientReported processPatientFhirAgnostic(HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, String patientReportedExternalLink, String patientReportedAuthority, String patientReportedType) throws ProcessingException { + public PatientReported processPatientFhirAgnostic(HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, String patientReportedExternalLink, String patientReportedAuthority, String patientReportedType) throws ProcessingException { if (processingFlavorSet.contains(ProcessingFlavor.APPLESAUCE)) { @@ -1168,7 +1157,7 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List groupPatientIds = (ArrayList) request.getAttribute("groupPatientIds"); diff --git a/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandlerR4.java b/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandlerR4.java index b1930e9e..9aca91fc 100644 --- a/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandlerR4.java +++ b/src/main/java/org/immregistries/iis/kernal/logic/IncomingMessageHandlerR4.java @@ -72,7 +72,7 @@ public String process(String message, Tenant tenant, String sendingFacilityName) break; default: ProcessingException pe = new ProcessingException("Unsupported message", "", 0, 0); - List processingExceptionList = List.of(pe); + List processingExceptionList = List.of(new IisReportable(pe)); responseMessage = buildAck(reader, processingExceptionList, processingFlavorSet); recordMessageReceived(message, null, responseMessage, "Unknown", "NAck", tenant); break; @@ -80,8 +80,8 @@ public String process(String message, Tenant tenant, String sendingFacilityName) } catch (Exception e) { e.printStackTrace(System.err); - List processingExceptionList = new ArrayList<>(); - processingExceptionList.add(new ProcessingException("Internal error prevented processing: " + e.getMessage(), null, 0, 0)); + List processingExceptionList = new ArrayList<>(); + processingExceptionList.add(new IisReportable(new ProcessingException("Internal error prevented processing: " + e.getMessage(), null, 0, 0))); responseMessage = buildAck(reader, processingExceptionList, processingFlavorSet); } return responseMessage; @@ -89,7 +89,7 @@ public String process(String message, Tenant tenant, String sendingFacilityName) @SuppressWarnings("unchecked") public String processVXU(Tenant tenant, HL7Reader reader, String message, Organization managingOrganization) throws Exception { - List processingExceptionList = new ArrayList<>(); + List processingExceptionList = new ArrayList<>(); Set processingFlavorSet = tenant.getProcessingFlavorSet(); MqeMessageServiceResponse mqeMessageServiceResponse = mqeMessageService.processMessage(message); List nistReportables = nistValidation(message, "VXU"); @@ -191,7 +191,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code cvxCode = codeMap.getRelatedCode(ndcCode, CodesetType.VACCINATION_CVX_CODE); if (cvxCode == null) { ProcessingException pe = new ProcessingException("Unrecognized NDC " + vaccineNdcCode, "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { if (vaccineCvxCode.equals("")) { vaccineCvxCode = cvxCode.getValue(); @@ -199,7 +199,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi // NDC doesn't map to the CVX code that was submitted! ProcessingException pe = new ProcessingException("NDC " + vaccineNdcCode + " maps to " + cvxCode.getValue() + " but CVX " + vaccineCvxCode + " was also reported, preferring CVX code", "RXA", rxaCount, 5); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } } @@ -210,14 +210,14 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code cvxCode = codeMap.getRelatedCode(cptCode, CodesetType.VACCINATION_CVX_CODE); if (cvxCode == null) { ProcessingException pe = new ProcessingException("Unrecognized CPT " + cptCode, "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { if (vaccineCvxCode.equals("")) { vaccineCvxCode = cvxCode.getValue(); } else if (!vaccineCvxCode.equals(cvxCode.getValue())) { // CPT doesn't map to the CVX code that was submitted! ProcessingException pe = new ProcessingException("CPT " + vaccineCptCode + " maps to " + cvxCode.getValue() + " but CVX " + vaccineCvxCode + " was also reported, preferring CVX code", "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } } @@ -296,7 +296,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi vaccinationReported.setAdministeredAmount(reader.getValue(6)); vaccinationReported.setInformationSource(reader.getValue(9)); vaccinationReported.setLotnumber(reader.getValue(15)); - vaccinationReported.setExpirationDate(parseDateWarnOld(reader.getValue(16), "Invalid vaccination expiration date", "RXA", rxaCount, 16, strictDate, processingExceptionList)); + vaccinationReported.setExpirationDate(parseDateWarn(reader.getValue(16), "Invalid vaccination expiration date", "RXA", rxaCount, 16, strictDate, processingExceptionList)); vaccinationReported.setVaccineMvxCode(reader.getValue(17)); vaccinationReported.setRefusalReasonCode(reader.getValue(18)); vaccinationReported.setCompletionStatus(reader.getValue(20)); @@ -306,7 +306,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi if (refusalCode == null) { ProcessingException pe = new ProcessingException("Unrecognized refusal reason", "RXA", rxaCount, 18); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } vaccinationReported.setActionCode(reader.getValue(21)); @@ -346,7 +346,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code fundingEligibilityCode = codeMap.getCodeForCodeset(CodesetType.FINANCIAL_STATUS_CODE, fundingEligibility); if (fundingEligibilityCode == null) { ProcessingException pe = new ProcessingException("Funding eligibility '" + fundingEligibility + "' was not recognized", "OBX", tempObxCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { vaccinationReported.setFundingEligibility(fundingEligibilityCode.getValue()); } @@ -357,7 +357,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code fundingSourceCode = codeMap.getCodeForCodeset(CodesetType.VACCINATION_FUNDING_SOURCE, fundingSource); if (fundingSourceCode == null) { ProcessingException pe = new ProcessingException("Funding source '" + fundingSource + "' was not recognized", "OBX", tempObxCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { vaccinationReported.setFundingSource(fundingSourceCode.getValue()); } @@ -383,7 +383,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi return ack; } catch (ProcessingException e) { if (!processingExceptionList.contains(e)) { - processingExceptionList.add(e); + processingExceptionList.add(new IisReportable(e)); } String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables); recordMessageReceived(message, null, ack, "Update", "Exception", tenant); @@ -393,24 +393,24 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi } @SuppressWarnings("unchecked") - public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, Organization managingOrganization) throws ProcessingException { + public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, Organization managingOrganization) throws ProcessingException { String patientReportedExternalLink = ""; String patientReportedAuthority = ""; String patientReportedType = "MR"; if (reader.advanceToSegment("PID")) { patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { patientReportedAuthority = ""; patientReportedType = "PT"; patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { patientReportedAuthority = ""; patientReportedType = "PI"; patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { throw new ProcessingException("MRN was not found, required for accepting vaccination report", "PID", 1, 3); } } @@ -435,7 +435,7 @@ public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList = new ArrayList<>(); + List processingExceptionList = new ArrayList<>(); Set processingFlavorSet = tenant.getProcessingFlavorSet(); try { CodeMap codeMap = CodeMapManager.getCodeMap(); @@ -458,7 +458,7 @@ public String processORU(Tenant tenant, HL7Reader reader, String message, Organi return ack; } catch (ProcessingException e) { if (!processingExceptionList.contains(e)) { - processingExceptionList.add(e); + processingExceptionList.add(new IisReportable(e)); } String ack = buildAck(reader, processingExceptionList, processingFlavorSet); recordMessageReceived(message, null, ack, "Update", "Exception", tenant); @@ -467,7 +467,7 @@ public String processORU(Tenant tenant, HL7Reader reader, String message, Organi } @SuppressWarnings("unchecked") - public ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode) { + public ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode) { // ObservationMaster observationMaster = null; ObservationReported observationReported = null; if (vaccination == null) { @@ -507,7 +507,7 @@ public ObservationReported readObservations(HL7Reader reader, List processingExceptionList = new ArrayList<>(); - processingExceptionList.add(pe); + List processingExceptionList = List.of(new IisReportable(pe)); responseMessage = buildAck(reader, processingExceptionList, processingFlavorSet); recordMessageReceived(message, null, responseMessage, "Unknown", "NAck", tenant); break; @@ -81,8 +80,8 @@ public String process(String message, Tenant tenant, String sendingFacilityName) } catch (Exception e) { e.printStackTrace(System.err); - List processingExceptionList = new ArrayList<>(); - processingExceptionList.add(new ProcessingException("Internal error prevented processing: " + e.getMessage(), null, 0, 0)); + List processingExceptionList = new ArrayList<>(); + processingExceptionList.add(new IisReportable(new ProcessingException("Internal error prevented processing: " + e.getMessage(), null, 0, 0))); responseMessage = buildAck(reader, processingExceptionList, processingFlavorSet); } return responseMessage; @@ -90,7 +89,7 @@ public String process(String message, Tenant tenant, String sendingFacilityName) @SuppressWarnings("unchecked") public String processVXU(Tenant tenant, HL7Reader reader, String message, Organization managingOrganization) throws Exception { - List processingExceptionList = new ArrayList<>(); + List processingExceptionList = new ArrayList<>(); Set processingFlavorSet = tenant.getProcessingFlavorSet(); MqeMessageServiceResponse mqeMessageServiceResponse = mqeMessageService.processMessage(message); List nistReportables = nistValidation(message, "VXU"); @@ -192,7 +191,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code cvxCode = codeMap.getRelatedCode(ndcCode, CodesetType.VACCINATION_CVX_CODE); if (cvxCode == null) { ProcessingException pe = new ProcessingException("Unrecognized NDC " + vaccineNdcCode, "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { if (vaccineCvxCode.equals("")) { vaccineCvxCode = cvxCode.getValue(); @@ -200,7 +199,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi // NDC doesn't map to the CVX code that was submitted! ProcessingException pe = new ProcessingException("NDC " + vaccineNdcCode + " maps to " + cvxCode.getValue() + " but CVX " + vaccineCvxCode + " was also reported, preferring CVX code", "RXA", rxaCount, 5); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } } @@ -211,14 +210,14 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code cvxCode = codeMap.getRelatedCode(cptCode, CodesetType.VACCINATION_CVX_CODE); if (cvxCode == null) { ProcessingException pe = new ProcessingException("Unrecognized CPT " + cptCode, "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { if (vaccineCvxCode.equals("")) { vaccineCvxCode = cvxCode.getValue(); } else if (!vaccineCvxCode.equals(cvxCode.getValue())) { // CPT doesn't map to the CVX code that was submitted! ProcessingException pe = new ProcessingException("CPT " + vaccineCptCode + " maps to " + cvxCode.getValue() + " but CVX " + vaccineCvxCode + " was also reported, preferring CVX code", "RXA", rxaCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } } @@ -297,7 +296,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi vaccinationReported.setAdministeredAmount(reader.getValue(6)); vaccinationReported.setInformationSource(reader.getValue(9)); vaccinationReported.setLotnumber(reader.getValue(15)); - vaccinationReported.setExpirationDate(parseDateWarnOld(reader.getValue(16), "Invalid vaccination expiration date", "RXA", rxaCount, 16, strictDate, processingExceptionList)); + vaccinationReported.setExpirationDate(parseDateWarn(reader.getValue(16), "Invalid vaccination expiration date", "RXA", rxaCount, 16, strictDate, processingExceptionList)); vaccinationReported.setVaccineMvxCode(reader.getValue(17)); vaccinationReported.setRefusalReasonCode(reader.getValue(18)); vaccinationReported.setCompletionStatus(reader.getValue(20)); @@ -307,7 +306,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi if (refusalCode == null) { ProcessingException pe = new ProcessingException("Unrecognized refusal reason", "RXA", rxaCount, 18); pe.setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } } vaccinationReported.setActionCode(reader.getValue(21)); @@ -331,6 +330,10 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi refusalCount++; } + if (ProcessingFlavor.HOTSAUCE.isActive() && random.nextBoolean()) { + throw new ProcessingException("Vaccination randomly rejected, Patient Accepted", "RXR", 0, 0, "N"); + } + reader.gotoSegmentPosition(segmentPosition); int tempObxCount = obxCount; @@ -343,7 +346,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code fundingEligibilityCode = codeMap.getCodeForCodeset(CodesetType.FINANCIAL_STATUS_CODE, fundingEligibility); if (fundingEligibilityCode == null) { ProcessingException pe = new ProcessingException("Funding eligibility '" + fundingEligibility + "' was not recognized", "OBX", tempObxCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { vaccinationReported.setFundingEligibility(fundingEligibilityCode.getValue()); } @@ -354,7 +357,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi Code fundingSourceCode = codeMap.getCodeForCodeset(CodesetType.VACCINATION_FUNDING_SOURCE, fundingSource); if (fundingSourceCode == null) { ProcessingException pe = new ProcessingException("Funding source '" + fundingSource + "' was not recognized", "OBX", tempObxCount, 5).setWarning(); - processingExceptionList.add(pe); + processingExceptionList.add(new IisReportable(pe)); } else { vaccinationReported.setFundingSource(fundingSourceCode.getValue()); } @@ -380,7 +383,7 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi return ack; } catch (ProcessingException e) { if (!processingExceptionList.contains(e)) { - processingExceptionList.add(e); + processingExceptionList.add(new IisReportable(e)); } String ack = buildAckMqe(reader, mqeMessageServiceResponse, processingExceptionList, processingFlavorSet, nistReportables); recordMessageReceived(message, null, ack, "Update", "Exception", tenant); @@ -390,24 +393,24 @@ public String processVXU(Tenant tenant, HL7Reader reader, String message, Organi } @SuppressWarnings("unchecked") - public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, Organization managingOrganization) throws ProcessingException { + public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList, Set processingFlavorSet, CodeMap codeMap, boolean strictDate, PatientReported patientReported, Organization managingOrganization) throws ProcessingException { String patientReportedExternalLink = ""; String patientReportedAuthority = ""; String patientReportedType = "MR"; if (reader.advanceToSegment("PID")) { patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { patientReportedAuthority = ""; patientReportedType = "PT"; patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { patientReportedAuthority = ""; patientReportedType = "PI"; patientReportedExternalLink = reader.getValueBySearchingRepeats(3, 1, patientReportedType, 5); patientReportedAuthority = reader.getValueBySearchingRepeats(3, 4, patientReportedType, 5); - if (patientReportedExternalLink.equals("")) { + if (StringUtils.isBlank(patientReportedExternalLink)) { throw new ProcessingException("MRN was not found, required for accepting vaccination report", "PID", 1, 3); } } @@ -432,7 +435,7 @@ public PatientReported processPatient(Tenant tenant, HL7Reader reader, List processingExceptionList = new ArrayList<>(); + List processingExceptionList = new ArrayList<>(); Set processingFlavorSet = tenant.getProcessingFlavorSet(); try { CodeMap codeMap = CodeMapManager.getCodeMap(); @@ -455,7 +458,7 @@ public String processORU(Tenant tenant, HL7Reader reader, String message, Organi return ack; } catch (ProcessingException e) { if (!processingExceptionList.contains(e)) { - processingExceptionList.add(e); + processingExceptionList.add(new IisReportable(e)); } String ack = buildAck(reader, processingExceptionList, processingFlavorSet); recordMessageReceived(message, null, ack, "Update", "Exception", tenant); @@ -464,7 +467,7 @@ public String processORU(Tenant tenant, HL7Reader reader, String message, Organi } @SuppressWarnings("unchecked") - public ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode) { + public ObservationReported readObservations(HL7Reader reader, List processingExceptionList, PatientReported patientReported, boolean strictDate, int obxCount, VaccinationReported vaccinationReported, VaccinationMaster vaccination, String identifierCode, String valueCode) { // ObservationMaster observationMaster = null; ObservationReported observationReported = null; if (vaccination == null) { @@ -504,7 +507,7 @@ public ObservationReported readObservations(HL7Reader reader, List