Implement EzDent patient search and original file transfers
This commit is contained in:
1 parent
69f70d0325
commit
017553f3db
4 files changed
+308
-13
No files matched your search
@@ -48,6 +48,7 @@ final class WebConsoleAPI {
|
||||
("e2ds", "patientsbychartno", "GET"),
|
||||
("e2ds", "patients", "POST"),
|
||||
("e2ds", "imagesbychartno", "POST"),
|
||||
("e2ds", "patientsforcondition", "POST"),
|
||||
("e2ds", "imagesbystudyuid", "GET"),
|
||||
("fs", "sysfilesnoconversionbytypeandpath", "GET"),
|
||||
("e2ds", "patientsbychartnoforimage", "POST"),
|
||||
@@ -79,7 +80,8 @@ final class WebConsoleAPI {
|
||||
switch (path, method) {
|
||||
case (["auth", "apploginr2"], "POST"), (["auth", "applogin"], "POST"),
|
||||
(["e2ds", "patientsbynumlistforrecentlyacquired"], "POST"), (["e2ds", "patients"], "POST"),
|
||||
(["e2ds", "patientsbychartnoforimage"], "POST"), (["e2ds", "imagesbychartno"], "POST"):
|
||||
(["e2ds", "patientsbychartnoforimage"], "POST"), (["e2ds", "imagesbychartno"], "POST"),
|
||||
(["e2ds", "patientsforcondition"], "POST"):
|
||||
return true
|
||||
case (let route, "GET"):
|
||||
return route.starts(with: ["e2ds", "patientsbychartno"]) || isBootstrapRead(route)
|
||||
@@ -98,6 +100,12 @@ final class WebConsoleAPI {
|
||||
path == ["e2ds", "doctors"]
|
||||
}
|
||||
|
||||
func isSignedIn(_ authorization: String?) -> Bool {
|
||||
guard let authorization, authorization.hasPrefix("Bearer "),
|
||||
let session = sessions[String(authorization.dropFirst(7))] else { return false }
|
||||
return session.expiry > Date()
|
||||
}
|
||||
|
||||
func reply(path: [String], method: String, body: Data, authorization: String?, query: [URLQueryItem], queryPathLast: String?, store: ServerStore) -> Reply {
|
||||
if path == ["auth", "apploginr2"] || path == ["auth", "applogin"] {
|
||||
return login(body)
|
||||
@@ -111,7 +119,7 @@ final class WebConsoleAPI {
|
||||
|| (method == "GET" && path.starts(with: ["e2ds", "patientsbychartno"]))
|
||||
|| (method == "POST" && (path == ["e2ds", "patientsbynumlistforrecentlyacquired"]
|
||||
|| path == ["e2ds", "patients"] || path == ["e2ds", "patientsbychartnoforimage"]
|
||||
|| path == ["e2ds", "imagesbychartno"]))
|
||||
|| path == ["e2ds", "imagesbychartno"] || path == ["e2ds", "patientsforcondition"]))
|
||||
guard session.administrator || applicationBootstrap else {
|
||||
return Reply(["errorMessage": "Administrator login required"],
|
||||
status: "403 Forbidden", errorCode: -1013)
|
||||
@@ -159,6 +167,30 @@ final class WebConsoleAPI {
|
||||
} catch {
|
||||
return Reply(status: "503 Service Unavailable", errorCode: -1005)
|
||||
}
|
||||
case ("e2ds", "patientsforcondition", "POST") where path.count == 2:
|
||||
let page = input["pageNum"] as? Int ?? (input["pageNum"] as? String).flatMap(Int.init) ?? 0
|
||||
let limit = input["numItems"] as? Int ?? (input["numItems"] as? String).flatMap(Int.init) ?? 50
|
||||
guard let search = input["searchCondition"] as? [String: Any],
|
||||
search["eModality"] as? String == "eAnyModality",
|
||||
(search["dtAcquisitionTime"] as? String ?? "").isEmpty,
|
||||
let doctor = input["pairDoctorType"] as? [String: String],
|
||||
["eDoctorAccountAll", "eDoctorAccountNone", "eDoctorAccountName"].contains(doctor["second"] ?? ""),
|
||||
page >= 0, (1...1000).contains(limit), page <= Int.max / limit else {
|
||||
return Reply(status: "400 Bad Request", errorCode: -1021)
|
||||
}
|
||||
let term = (search["strCondition"] as? String ?? "").trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
do {
|
||||
let matches = doctor["second"] == "eDoctorAccountName" ? [] : try store.patients().filter {
|
||||
term.isEmpty || $0.chartNumber.localizedStandardContains(term) || $0.name.localizedStandardContains(term)
|
||||
}
|
||||
let items = matches.dropFirst(page * limit).prefix(limit).map {
|
||||
["strChartNo": $0.chartNumber, "strLastName": $0.name, "strFirstName": "",
|
||||
"strMiddleName": "", "dtBirthdate": "", "strGender": ""]
|
||||
}
|
||||
return Reply(["searchedPatientList": items, "nCnt": items.count], errorCode: items.isEmpty ? -100037 : 0)
|
||||
} catch {
|
||||
return Reply(status: "503 Service Unavailable", errorCode: -1005)
|
||||
}
|
||||
case ("e2ds", "imagesbychartno", "POST") where path.count == 2:
|
||||
let page = input["pageNum"] as? Int ?? (input["pageNum"] as? String).flatMap(Int.init) ?? 0
|
||||
let limit = input["numItems"] as? Int ?? (input["numItems"] as? String).flatMap(Int.init) ?? 50
|
||||
@@ -333,9 +365,12 @@ final class WebConsoleAPI {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
let items: [[String: Any]] = images.compactMap { image in
|
||||
let metadata = LegacyDICOMMetadata(file: image.firstFile)
|
||||
if let studyUID, metadata.studyUID != studyUID { return nil }
|
||||
let uid = image.studyUID.isEmpty ? metadata.studyUID : image.studyUID
|
||||
if let studyUID, uid != studyUID { return nil }
|
||||
let modality: String
|
||||
switch (metadata.modality, image.dicomCount ?? 0) {
|
||||
case _ where !image.modality.isEmpty: modality = image.modality
|
||||
case _ where image.wireName.uppercased().hasSuffix(".CT"): modality = "eCT"
|
||||
case ("CT", _), ("CBCT", _), (_, 2...): modality = "eCT"
|
||||
case ("PX", _): modality = "ePanorama"
|
||||
case ("CR", _), ("DX", _):
|
||||
@@ -344,8 +379,8 @@ final class WebConsoleAPI {
|
||||
}
|
||||
return [
|
||||
"nImageID": image.id, "nPatID": image.patientID, "nRecordID": 0,
|
||||
"strChartNo": image.chartNumber, "strImgFileName": image.name, "modality": modality,
|
||||
"dtAcqTime": formatter.string(from: image.importedAt), "strStudyInstanceUID": metadata.studyUID,
|
||||
"strChartNo": image.chartNumber, "strImgFileName": image.wireName, "modality": modality,
|
||||
"dtAcqTime": formatter.string(from: image.importedAt), "strStudyInstanceUID": uid,
|
||||
"strAcqMode": "", "strRawFileName": "", "strVPanoFileName": "", "dtUpdateDateTime": "",
|
||||
"strModelName": "", "strDeviceInfo": "", "strNote": "", "strDeviceSerialNumber": "",
|
||||
"fKvp": 0, "fMa": 0, "fDose": 0, "fExposureTime": 0,
|
||||
|
||||
Reference in new issue
Block a user