70 lines
2.2 KiB
Plaintext
70 lines
2.2 KiB
Plaintext
import "lib/utilsLib" as utilsLib;
|
|
import "lib/stringLib" as stringLib;
|
|
import "lib/numberLib" as numberLib;
|
|
import "lib/journalLib" as journalLib;
|
|
|
|
def formatExperienceTitle:
|
|
. as $experience |
|
|
"\"\(.title)\": \(.creationDate / 1000 | strftime("%d-%m-%Y"))";
|
|
|
|
def formatDose($dose; $unit; $isEstimate; $standardDeviation):
|
|
if $dose == null then
|
|
"Unknown \($unit)"
|
|
else
|
|
(if $isEstimate then "~" else "" end) as $estimate |
|
|
(if $standardDeviation != null then "±\($standardDeviation)" else "" end) as $standardDeviation |
|
|
|
|
"\($estimate)\($dose | numberLib::round(2))\($standardDeviation) \($unit)"
|
|
end;
|
|
|
|
def formatIngestionDose($customUnits):
|
|
. as $ingestion |
|
|
(. | journalLib::ingestionDose($customUnits)) as $dose |
|
|
(. | journalLib::ingestionUnit($customUnits)) as $unit |
|
|
(. | journalLib::ingestionStandardDeviation($customUnits)) as $standardDeviation |
|
|
$customUnits | map(select(.id == $ingestion.customUnitId))[0] as $customUnit |
|
|
if $ingestion.dose == null then
|
|
"Unknown"
|
|
elif $customUnit == null then
|
|
formatDose($dose; $unit; $ingestion.isDoseAnEstimate; $standardDeviation)
|
|
else
|
|
formatDose($dose; $unit; $ingestion.isDoseAnEstimate; $standardDeviation) +
|
|
" (" +
|
|
formatDose($customUnit.dose; $unit; $customUnit.isEstimate; $customUnit.estimatedDoseStandardDeviation) +
|
|
" * " +
|
|
formatDose($ingestion.dose; $customUnit.unit; $ingestion.isDoseAnEstimate; $ingestion.estimatedDoseStandardDeviation) +
|
|
")"
|
|
end;
|
|
|
|
def formatIngestionTime:
|
|
. as $ingestion |
|
|
$ingestion.time / 1000 | strftime("%a %I:%M %p");
|
|
|
|
def formatIngestionROA($customUnits; $substitutions):
|
|
. as $ingestion |
|
|
$ingestion.administrationRoute as $roa |
|
|
|
|
(if
|
|
$substitutions | has($roa)
|
|
then
|
|
$substitutions | .[$roa]
|
|
else
|
|
$roa | stringLib::titleCase
|
|
end) as $roaText |
|
|
|
|
$ingestion.customUnitId as $customUnitId |
|
|
|
|
if
|
|
$customUnitId == null
|
|
then
|
|
$roaText
|
|
else
|
|
$customUnits | map(select(.id == $customUnitId))[0] as $customUnit |
|
|
"\($roaText) (\($customUnit.name))"
|
|
end;
|
|
|
|
def formatIngestionROA($customUnits): formatIngestionROA($customUnits; {});
|
|
|
|
def formatIngestionInfo:
|
|
. as $ingestionInfo |
|
|
formatDose(.dose; .unit; .isEstimate; .standardDeviation); |