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

(feature) Query the Client Registry to retrieve patient data and import it into OpenELIS #1219

Merged
merged 24 commits into from
Oct 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7614a39
Query the CR to retrieve patient data into OpenELIS
mherman22 Aug 6, 2024
48b0427
make searching work well
mherman22 Aug 16, 2024
e446a11
fix
mherman22 Aug 18, 2024
5861e7b
fixx
mherman22 Aug 18, 2024
4e4c002
ensures the patient is correctly searched and results got
mherman22 Aug 29, 2024
023a7ea
format
mherman22 Aug 30, 2024
37a2f55
add cr result to ui
mherman22 Aug 31, 2024
6ba8eb3
add fix
mherman22 Aug 31, 2024
0e835ac
fix url when crResult is toggled off
mherman22 Aug 31, 2024
6ec9795
transfer logic to fhirtransform
mherman22 Sep 2, 2024
da101d3
ensure search by other attributes aswell
mherman22 Sep 2, 2024
b65c9f9
add
mherman22 Sep 12, 2024
13fb06e
fix search to query opencr for unavailable patient(s) in openelis
mherman22 Sep 17, 2024
2328e3c
fix
mherman22 Sep 17, 2024
007dcc3
ensure results are not persisted until a user clicks the import button
mherman22 Sep 20, 2024
677aad0
ensure button is only available for opencr result
mherman22 Sep 20, 2024
eca8151
change button from ghost to tertiary
mherman22 Sep 20, 2024
ddf629a
format
mherman22 Sep 20, 2024
88cf0dc
Ensure import from opencr works perfectly
mherman22 Sep 22, 2024
1533fce
generate a dynamic national id for those who don't have them from the CR
mherman22 Sep 28, 2024
02bd0ba
make client registry search configurable
mherman22 Sep 29, 2024
b0fbac3
fix the nationalid generation
mherman22 Sep 29, 2024
94c4504
Add modifications according to reviews
mherman22 Oct 1, 2024
842c80e
minor fix
mozzy11 Oct 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import ca.uhn.fhir.rest.param.StringOrListParam;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.validator.GenericValidator;
Expand Down Expand Up @@ -208,11 +210,7 @@ private List<PatientSearchResults> searchPatientInClientRegistry(String lastName
// we can construct a dynamic National ID like "NID-{gender}-{dob}-{initials}"
if (transformedPatientSearchResult.getNationalId() == null
|| transformedPatientSearchResult.getNationalId().isEmpty()) {
String formattedDob = transformedPatientSearchResult.getBirthdate() != null
|| !transformedPatientSearchResult.getBirthdate().isEmpty()
? String.format(String.valueOf(DateTimeFormatter.ofPattern("yyyyMMdd")))
: "00000000";
String nationalId = generateDynamicID(transformedPatientSearchResult, formattedDob);
String nationalId = generateDynamicID(transformedPatientSearchResult);
log.info("dynamic national id: {}", nationalId);
transformedPatientSearchResult.setNationalId(nationalId);
}
Expand All @@ -225,27 +223,51 @@ private List<PatientSearchResults> searchPatientInClientRegistry(String lastName
}

// FIXME: get better fallback initials and gender
private static String generateDynamicID(PatientSearchResults transformedPatientSearchResult, String formattedDob) {
private static String generateDynamicID(PatientSearchResults transformedPatientSearchResult) {
String genderOfTransformedPatient = transformedPatientSearchResult.getGender() != null
|| !transformedPatientSearchResult.getGender().isEmpty()
&& !transformedPatientSearchResult.getGender().isEmpty()
? transformedPatientSearchResult.getGender().toUpperCase()
: "UNK";

String initials = getInitials(transformedPatientSearchResult);

String formattedDob = "00000000";
if (transformedPatientSearchResult.getBirthdate() != null
mozzy11 marked this conversation as resolved.
Show resolved Hide resolved
&& !transformedPatientSearchResult.getBirthdate().isEmpty()) {
try {
// Try to parse with "dd/MM/yyyy" format first
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
LocalDate birthdate = LocalDate.parse(transformedPatientSearchResult.getBirthdate(), dateFormatter);
formattedDob = birthdate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
} catch (DateTimeParseException e1) {
try {
LocalDate birthdate = LocalDate.parse(transformedPatientSearchResult.getBirthdate(),
DateTimeFormatter.ISO_DATE);
formattedDob = birthdate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
} catch (DateTimeParseException e2) {
LogEvent.logError(e2);
}
}
}

return String.format("NID-%s-%s-%s", genderOfTransformedPatient, formattedDob, initials);
}

private static String getInitials(PatientSearchResults transformedPatientSearchResult) {
String initials = "";
if (transformedPatientSearchResult.getFirstName() != null
|| !transformedPatientSearchResult.getFirstName().isEmpty()) {
&& !transformedPatientSearchResult.getFirstName().isEmpty()) {
initials = transformedPatientSearchResult.getFirstName().substring(0, 1).toUpperCase();
}
if (transformedPatientSearchResult.getLastName() != null
|| !transformedPatientSearchResult.getLastName().isEmpty()) {
&& !transformedPatientSearchResult.getLastName().isEmpty()) {
initials += transformedPatientSearchResult.getLastName().substring(0, 1).toUpperCase();
}

if (initials.isEmpty()) {
// Fallback if no initials can be determined
// hope we don't get this scenario
initials = "NAN";
}
return "NID-" + genderOfTransformedPatient + "-" + formattedDob + "-" + initials;
return initials;
}

private boolean isClientRegistryConfigInvalid() {
Expand Down
Loading