Calculating values that have an unit of measure, like mass, time, volume etc.. is inherintly difficult when different units are involved. This specifically applies to the field of medical prescription calculations. For example calculating a drip rate can be awkward, like:
2 mL of dopamine 200 mg / 5 mL in 48 mL saline infused at a driprate of 2 mL/hour equals how ... mcg/kg/min
calculated for a body weight of 10 kg.
The concentration of dopamine is 40 mg/mL, dissolved in 50 mL, results in a concentration of 0.8 mg/mL, when infused at a rate of 2 mL/hour, this equals 1.6 mg /hour, which is 0.16 mg/kg/hour or 160 mcg/kg/hour, with 60 minutes in an hour, the resulting dose equals 2.67 mcg/kg/hour. The formula for this calculation is:
((((dopamin conc * quantity of dopamine) / quantity of salin) * drip rate) / body weight
So, (((mg/mL * mL) / mL) * mL / hour) / kg_weight = mcg/kg_weight/min
To complicate matters, different medical settings request the same calculations to be shown in different units within the same unit group. For example, in some hospitals morfine dose is measured in mg/kg/day, while in other hospitals mcg/kg/hour is prefered.
This library aims to allow for direct calculations with values and units. For example, when 2 mL/hour is multiplied with 1 hour to calulate administered fluid, GenUnits evaluates 2 mL/hour * 2 hour as 4 mL. It also provides the alternative unit options. So for mg/day, the same value can be shown as mcg/min or g/week or mg/hour.
| GitHub Actions |
|---|
| Package | Stable | Prerelease |
|---|---|---|
| Informedica.GenUnits.Lib |
Make sure the following requirements are installed on your system:
- dotnet SDK 3.0 or higher
- Mono if you're on Linux or macOS.
or
CONFIGURATIONwill set the configuration of the dotnet commands. If not set, it will default to Release.CONFIGURATION=Debug ./build.shwill result in-cadditions to commands such as indotnet build -c Debug
GITHUB_TOKENwill be used to upload release notes and Nuget packages to GitHub.- Be sure to set this before releasing
DISABLE_COVERAGEWill disable running code coverage metrics. AltCover can have severe performance degradation so it's worth disabling when looking to do a quicker feedback loop.DISABLE_COVERAGE=1 ./build.sh
> build.cmd <optional buildtarget> // on windows
$ ./build.sh <optional buildtarget>// on unixThe bin of your library should look similar to:
$ tree src/MyCoolNewLib/bin/
src/MyCoolNewLib/bin/
└── Debug
└── net50
├── MyCoolNewLib.deps.json
├── MyCoolNewLib.dll
├── MyCoolNewLib.pdb
└── MyCoolNewLib.xml
Clean- Cleans artifact and temp directories.DotnetRestore- Runs dotnet restore on the solution file.DotnetBuild- Runs dotnet build on the solution file.DotnetTest- Runs dotnet test on the solution file.GenerateCoverageReport- Code coverage is run duringDotnetTestand this generates a report via ReportGenerator.WatchTests- Runs dotnet watch with the test projects. Useful for rapid feedback loops.GenerateAssemblyInfo- Generates AssemblyInfo for libraries.DotnetPack- Runs dotnet pack. This includes running Source Link.SourceLinkTest- Runs a Source Link test tool to verify Source Links were properly generated.PublishToNuGet- Publishes the NuGet packages generated inDotnetPackto NuGet via paket push.GitRelease- Creates a commit message with the Release Notes and a git tag via the version in theRelease Notes.GitHubRelease- Publishes a GitHub Release with the Release Notes and any NuGet packages.FormatCode- Runs Fantomas on the solution file.BuildDocs- Generates Documentation fromdocsSrcand the XML Documentation Comments from your libraries insrc.WatchDocs- Generates documentation and starts a webserver locally. It will rebuild and hot reload if it detects any changes made todocsSrcfiles, libraries insrc, or thedocsToolitself.ReleaseDocs- Will stage, commit, and push docs generated in theBuildDocstarget.Release- Task that runs all release type tasks such asPublishToNuGet,GitRelease,ReleaseDocs, andGitHubRelease. Make sure to read Releasing to setup your environment correctly for releases.
git add .
git commit -m "Scaffold"
git remote add origin https://github.com/user/MyCoolNewLib.git
git push -u origin master-
paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a- or set the environment variable
NUGET_TOKENto your key
- or set the environment variable
-
- You can then set the environment variable
GITHUB_TOKENto upload release notes and artifacts to github - Otherwise it will fallback to username/password
- You can then set the environment variable
-
Then update the
CHANGELOG.mdwith an "Unreleased" section containing release notes for this version, in KeepAChangelog format.
NOTE: Its highly recommend to add a link to the Pull Request next to the release note that it affects. The reason for this is when the RELEASE target is run, it will add these new notes into the body of git commit. GitHub will notice the links and will update the Pull Request with what commit referenced it saying "added a commit that referenced this pull request". Since the build script automates the commit message, it will say "Bump Version to x.y.z". The benefit of this is when users goto a Pull Request, it will be clear when and which version those code changes released. Also when reading the CHANGELOG, if someone is curious about how or why those changes were made, they can easily discover the work and discussions.
Here's an example of adding an "Unreleased" section to a CHANGELOG.md with a 0.1.0 section already released.
## [Unreleased]
### Added
- Does cool stuff!
### Fixed
- Fixes that silly oversight
## [0.1.0] - 2017-03-17
First release
### Added
- This release already has lots of features
[Unreleased]: https://github.com/user/MyCoolNewLib.git/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/user/MyCoolNewLib.git/releases/tag/v0.1.0- You can then use the
Releasetarget, specifying the version number either in theRELEASE_VERSIONenvironment variable, or else as a parameter after the target name. This will:- update
CHANGELOG.md, moving changes from theUnreleasedsection into a new0.2.0section- if there were any prerelease versions of 0.2.0 in the changelog, it will also collect their changes into the final 0.2.0 entry
- make a commit bumping the version:
Bump version to 0.2.0and adds the new changelog section to the commit's body - publish the package to NuGet
- push a git tag
- create a GitHub release for that git tag
- update
macOS/Linux Parameter:
./build.sh Release 0.2.0macOS/Linux Environment Variable:
RELEASE_VERSION=0.2.0 ./build.sh Release