Skip to content

Commit

Permalink
REJECTLONGNAME, LIMITSIZENAME
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbeor committed Nov 6, 2024
1 parent 7eb61a2 commit 5028504
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.util.stream.Collectors;

public abstract class IncomingMessageHandler implements IIncomingMessageHandler {
public static final int NAME_SIZE_LIMIT = 15;
protected final Logger logger = LoggerFactory.getLogger(IncomingMessageHandler.class);
/**
* DYNAMIC VALUE SETS for validation
Expand Down Expand Up @@ -988,6 +989,11 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<Process
patientNameFirst = patientNameFirst.toUpperCase();
patientNameMiddle = patientNameMiddle.toUpperCase();
}
if (processingFlavorSet.contains(ProcessingFlavor.LIMITSIZENAME)) {
patientNameLast = patientNameLast.substring(0, NAME_SIZE_LIMIT);
patientNameFirst = patientNameFirst.substring(0, NAME_SIZE_LIMIT);
patientNameMiddle = patientNameMiddle.substring(0, NAME_SIZE_LIMIT);
}
PatientName patientName = new PatientName(patientNameLast, patientNameFirst, patientNameMiddle, nameType);


Expand All @@ -997,6 +1003,24 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<Process
}
}

if (legalName == null && processingFlavorSet.contains(ProcessingFlavor.MANDATORYLEGALNAME)) {
throw new ProcessingException("Patient legal name not found", "PID", 1, 5);
}
if (legalName != null && processingFlavorSet.contains(ProcessingFlavor.REJECTLONGNAME) && legalName.getNameLast().length() > NAME_SIZE_LIMIT) {
if (legalName.getNameLast().length() > NAME_SIZE_LIMIT ||
legalName.getNameFirst().length() > NAME_SIZE_LIMIT ||
legalName.getNameMiddle().length() > NAME_SIZE_LIMIT) {
throw new ProcessingException("Patient name is too long", "PID", 1, 5);

}
}
if (legalName != null && legalName.getNameLast().equals("")) {
throw new ProcessingException("Patient last name was not found, required for accepting patient and vaccination history", "PID", 1, 5);
}
if (legalName != null && legalName.getNameFirst().equals("")) {
throw new ProcessingException("Patient first name was not found, required for accepting patient and vaccination history", "PID", 1, 5);
}

String patientPhone = reader.getValue(13, 6) + reader.getValue(13, 7);
String telUseCode = reader.getValue(13, 2);
if (patientPhone.length() > 0) {
Expand Down Expand Up @@ -1039,15 +1063,6 @@ public PatientReported processPatientFhirAgnostic(HL7Reader reader, List<Process
patientPhone = "";
}

if (legalName == null && processingFlavorSet.contains(ProcessingFlavor.MANDATORYLEGALNAME)) {
throw new ProcessingException("Patient legal name not found", "PID", 1, 5);
}
if (legalName != null && legalName.getNameLast().equals("")) {
throw new ProcessingException("Patient last name was not found, required for accepting patient and vaccination history", "PID", 1, 5);
}
if (legalName != null && legalName.getNameFirst().equals("")) {
throw new ProcessingException("Patient first name was not found, required for accepting patient and vaccination history", "PID", 1, 5);
}


String zip = reader.getValue(11, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public enum ProcessingFlavor {
MEDLAR("Medlar", "Will only return errors but no warnings or informational error segments in ACK messages"),
APPLESAUCE("Applesauce", "Will activate detect Temporaray name detection including 'Babynames' and 'Test' and change the name type "),
SINGLENAME("Singlename", ""),
UPPERCASENAME("UPPERCASENAME", "Converts all incoming names to uppercase upon storing, regardless of the case sent by the EHR "),
UPPERCASENAME("UPPERCASENAME", "Converts all incoming names to uppercase upon storing, regardless of the case sent by the EHR"),
LIMITSIZENAME("LIMITSIZENAME", "Truncates names exceeding a set length (e.g., 15 characters) and stores them with a cutoff marker, simulating systems with limited name field lengths"),
REJECTLONGNAME("REJECTLONGNAME", "Flags and rejects names that exceed the length limit to demonstrate compliance with strict length constraints."),
MANDATORYLEGALNAME("MANDATORYLEGALNAME", "");

private String key = "";
Expand Down

0 comments on commit 5028504

Please sign in to comment.