Serve original patient chart lookup over EzDent API

This commit is contained in:
SantaSpeen committed 2026-11-22 03:58:05 +03:00
1 parent 96fb58fa4e
commit 5852266ed9
4 files changed
+38 -2

No files matched your search

+27 -1
View File
@@ -33,6 +33,7 @@ final class WebConsoleAPI {
("auth", "applogin", "POST"),
("e2ds", "useraccountsbynamer2", "GET"),
("e2ds", "useraccountsfornames", "GET"),
("e2ds", "patientsbychartno", "GET"),
("analytics", "eventsforsearch", "POST"),
("analytics", "eventsr2", "POST"),
("settings", "fileserversettings", "GET"),
@@ -57,12 +58,14 @@ final class WebConsoleAPI {
case (["auth", "apploginr2"], "POST"), (["auth", "applogin"], "POST"),
(["e2ds", "useraccountsbynamer2", "name", Self.admin.lowercased()], "GET"):
return true
case (let route, "GET") where route.starts(with: ["e2ds", "patientsbychartno"]):
return true
default:
return false
}
}
func reply(path: [String], method: String, body: Data, authorization: String?, store: ServerStore) -> Reply {
func reply(path: [String], method: String, body: Data, authorization: String?, query: [URLQueryItem], store: ServerStore) -> Reply {
if path == ["auth", "apploginr2"] || path == ["auth", "applogin"] {
return login(body)
}
@@ -78,6 +81,29 @@ final class WebConsoleAPI {
return Reply(status: "404 Not Found", errorCode: -100037)
}
return Reply(["accountInfo": ["strAccountName": Self.admin, "strGrade": "M"]])
case ("e2ds", "patientsbychartno", "GET"):
let argument = query.first(where: { $0.name == "chartno" })?.value
// CodeIgniter receives an already decoded query value and the controller calls urldecode again.
let chartNumber = argument
.map { $0.replacingOccurrences(of: "+", with: " ") }
.flatMap { $0.removingPercentEncoding ?? $0 } ?? ""
do {
guard !chartNumber.isEmpty, let patient = try store.patient(chartNumber: chartNumber) else {
return Reply(["patientInfo": []], errorCode: -100037)
}
// Imported Mac records store one display name without separate family / given names.
let emptyFields = ["strFirstName", "strMiddleName", "strGender", "strAge", "dtBirthdate",
"strEmail", "strSocialID", "strPhone", "strPhotoIDName", "dtRegisteredDateTime",
"strZipCode", "strAddress", "strMobile", "strRace", "strClassification", "strJob"]
var info: [String: Any] = Dictionary(uniqueKeysWithValues: emptyFields.map { ($0, "") })
info["strChartNo"] = patient.chartNumber
info["strLastName"] = patient.name
info["strlDoctor"] = [String]()
info["eSourceType"] = "eUnknownSourceType"
return Reply(["patientInfo": info])
} catch {
return Reply(status: "503 Service Unavailable", errorCode: -1005)
}
case ("e2ds", "useraccountsfornames", "GET"):
return Reply(["strlUserName": [Self.admin]])
case ("settings", "fileserversettings", "GET"):