Skip to content

Commit

Permalink
renamed yaderCli to yaderConf; changed sqlite db name to yader.db; ch…
Browse files Browse the repository at this point in the history
…anged configure file to reference.conf; msg changes - Category => Scheme, Summary => Graph
  • Loading branch information
nineclue committed Jan 30, 2024
1 parent bf2884a commit 73d54a0
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ lazy val yader = crossProject(JSPlatform, JVMPlatform)
),
)

lazy val yaderCli = (project in file("cli"))
lazy val yaderConf = (project in file("cli"))
.settings(
jvmSettings,
assembly / mainClass := Some("YaderCli"),
assembly / mainClass := Some("YaderConf"),
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-nop" % "2.0.10",
"org.apache.commons" % "commons-text" % "1.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.dcm4che3.io.DicomInputStream
import net.sourceforge.tess4j.*
import org.apache.commons.text.StringEscapeUtils

object YaderCli extends IOApp:
object YaderConf extends IOApp:
private def config(host: String, port: Int, called: String, calling: String, encoding: String, tpath: String, insts: Seq[String]) =
s"""host = "$host"
|port = $port
Expand All @@ -18,7 +18,7 @@ object YaderCli extends IOApp:
|# encoding of PACS system
|encoding = "$encoding"
|
|# optional, if not given use SQLite with file name of 'ctdose.db'
|# optional, if not given use SQLite with file name of 'yader.db'
|# postgres-db = ""
|# postgres-user = ""
|# postgres-password = ""
Expand All @@ -37,21 +37,22 @@ object YaderCli extends IOApp:
|# process-day-behind = 1
|
|# optional, default 0, interval in seconds between each day's job processing
|# pause-interval = 10
|pause-interval = 10
|
|# optional, cron mode - runs in server mode
|# calendar-event = "*-*-* 08:30:00"
|
|calendar-event = "*-*-* 08:30:00"
|
|# optional, stores png images of dose report series to (value of store-png-path) / yyyymmdd / accessionNumber.png with extracted dose value
|# store-png-path = "doseimg"
|
|# web server port number
|# web server port number, administrator pemission is needed to use port number less than 1024
|# web-port-number = 7878
|
|# ip filter for editing drl value change
|# empty list permits editing from any ips
|# drl-edit-ips = []
|
|# permits editing from current server
|drl-edit-ips = ["::1"]
|
|# show studies unassigned as 'NONE' in DRL tab
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ object Configuration:
req.remoteAddr.map(ip => drlEditIps.isEmpty || drlEditIps.contains(ip.toString)).getOrElse(false)

def ctInfo() =
val ctConf = Try(ConfigFactory.load("ct-info").getConfig("CTINFO"))
.toEither.left.map(e => List(s"Can't find ct-info.conf file or Config does not have CTINFO ${e.getMessage()}"))
val ctConf = Try(ConfigFactory.load().getConfig("CTINFO"))
.toEither.left.map(e => List(s"Can't find configure file or Config does not have CTINFO, check configure file or use -Dconfig.file option"))
ctConf.flatMap(conf =>
val (convergedMap, errs) = conf.entrySet.asScala.foldLeft((Map.empty[(String, String), CTDoseSeriesInfo], List.empty[String]))({ case ((dim, errs), e) =>
val ks = e.getKey().split('.').map(_.trim)
Expand Down Expand Up @@ -125,8 +125,10 @@ object Configuration:
val c = Configuration().flatMap(c => ctInfo().map((c, _)))
for
r <- c match
case Left(value) =>
case Left(value: String) =>
IO(println(value))
case Left(values: List[String]) =>
IO(println(values.mkString(",")))
case Right((cdc, m)) =>
Tesseract.setTesseractPath(cdc.tpath)
f(cdc, m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.time.format.DateTimeFormatter

case class SQLite() extends DB:
val xa = Transactor.fromDriverManager[IO](
"org.sqlite.JDBC", "jdbc:sqlite:ctdose.db", None
"org.sqlite.JDBC", "jdbc:sqlite:yader.db", None
)

def datetimeType: String = "DATETIME"
Expand Down
25 changes: 13 additions & 12 deletions yader/jvm/src/main/scala/net/maryknollrad/httpserver/CTDRL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object CTDRL:

private def catSelects(targetFName: String, sId: String, ss: List[String], sValue: String) =
div(id := "category", cls := "flex flex-row items-center",
h3(cls := "text-2xl mr-20", "Categories"),
h3(cls := "text-2xl mr-20", "Scheme"),
selects(targetFName, sId, ss, sValue, true))

def editCT(db: DB, catIndex: Int = 0) =
Expand All @@ -30,7 +30,7 @@ object CTDRL:
nonrs <- db.getNonMatchedStudies(catName)
_ <- if nonrs.nonEmpty then {
db.matchToNone(catName, nonrs) *>
db.log(s"Matched ${nonrs.length} studies to NONE at DRL category $catName", DB.LogType.Info)
db.log(s"Matched ${nonrs.length} studies to NONE at DRL scheme from '${catName.toUpperCase()}'", DB.LogType.Info)
} else
IO(0)
yield
Expand Down Expand Up @@ -64,7 +64,7 @@ object CTDRL:
thead(tr(th("Label"), th("Time"), th("less than DRL"), th("Trend"), th("Count"))),
tbody(
s.map({ case (label, time, count, total, ratio, trend) =>
tr(td(label), td(time), td(f"$ratio%.1f%%"), td(f"$trend%.1f%%"), td(s"$count/$total"))
tr(td(label), td(time), td(f"$ratio%.1f%%"), td(f"$trend%+.1f%%"), td(s"$count/$total"))
})))

private def showBpartCoverage(s: DrlSummary) =
Expand All @@ -88,11 +88,11 @@ object CTDRL:
div(cls := "text-2xl", "Exams under DRL"),
// div(drlRatio.mkString("<BR />")),
// div("-" * 30),
showDrlStats(summarize(drlFiltered, Some(todaysegment))),
showDrlStats(summarize(drlFiltered, todaysegment)),
div(cls := "text-2xl mt-2", "Bodypart Coverage"),
// div(bpartCover.mkString("<BR />")),
// div("-" * 30),
showBpartCoverage(summarize(bpartCover, Some(todaysegment))),
showBpartCoverage(summarize(bpartCover, todaysegment)),
button(cls := "text-2xl btn grow-0 justify-self-end", onclick := "JS.getcsv();", "Download CSV")
).toString

Expand All @@ -101,8 +101,9 @@ object CTDRL:

// assumes two datasets with different times
// input : (label, timespan (as string), flag, count) - label & timespan must be grouped and ordered
// timeFilter : filter for time value (same unit as timespan), otherwise past label with one row is included in result
// output : (label, timespan (as integer), count, total, ratio, trendratio)
def summarize(r: DrlResult, timeFilter: Option[Int]): DrlSummary =
def summarize(r: DrlResult, timeFilter: Int): DrlSummary =
def h(r: DrlResult, p: Option[(String, Int, Int, Int, Double)], acc: DrlSummary): DrlSummary =
r match
case Nil =>
Expand All @@ -111,14 +112,14 @@ object CTDRL:
(plbl, pts, pcount, ptotal, pratio, pratio) :: acc
case None =>
acc
case (lbl1, ts1, flag1, count1) :: (lbl2, ts2, flag2, count2) :: tail if lbl1 == lbl2 && ts1 == ts2 =>
case (lbl1, ts1, flag1, count1) :: (lbl2, ts2, flag2, count2) :: tail if lbl1 == lbl2 && ts1 == ts2 => // true && false
val (tcount, fcount) = if flag1 then (count1, count2) else (count2, count1)
val total = tcount + fcount
val ratio = ((tcount.toDouble / total) * 1000).round / 10.0
p match
case Some((plbl, pts, pcount, ptotal, pratio)) if plbl == lbl1 => // different time
case Some((plbl, pts, pcount, ptotal, pratio)) if plbl == lbl1 => // previous data => different time
h(tail, None, (lbl1, ts1.toInt, tcount, total, ratio, ratio - pratio) :: acc)
case Some((plbl, pts, pcount, ptotal, pratio)) => // different label
case Some((plbl, pts, pcount, ptotal, pratio)) => // previous data => different label
h(tail, Some(lbl1, ts1.toInt, tcount, total, ratio), (plbl, pts, pcount, ptotal, pratio, pratio) :: acc)
case None =>
h(tail, Some(lbl1, ts1.toInt, tcount, total, ratio), acc)
Expand All @@ -127,12 +128,12 @@ object CTDRL:
val tsi = ts.toInt
p match
case Some((plbl, pts, pcount, ptotal, pratio)) if plbl == lbl => // different time
val rtrend = if pts < tsi then ratio - pratio else pratio - ratio
val rtrend = if pts < tsi then ratio - pratio else pratio - ratio // check which time is earlier
h(tail, None, (lbl, tsi, adjCount, total, ratio, rtrend) :: acc)
case Some((plbl, pts, pcount, ptotal, pratio)) => // different label
case Some((plbl, pts, pcount, ptotal, pratio)) => // different label
h(tail, Some(lbl, tsi, adjCount, total, ratio), (plbl, pts, pcount, ptotal, pratio, pratio) :: acc)
case None =>
h(tail, Some(lbl, tsi, adjCount, total, ratio), acc)
h(r, None, List.empty)
.filter(t6 => timeFilter.map(_ == t6._2).getOrElse(true))
.filter(t6 => t6._2 == timeFilter)
.reverse
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ object Constants:
val drlSummaryCategoryId = "drlCategory"

val queryIntervals = Seq("Day", "Week", "Month", "Year")
val jobTabs = Seq("Summary", "DRL", "DRL Edit")
val jobTabs = Seq("Graph", "DRL", "DRL Edit")

0 comments on commit 73d54a0

Please sign in to comment.