npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vicentecalfo/ngx-insulin-calculator

v1.1.0

Published

This Angular component was created to show you how to calculate insulin dose with as little effort as possible.

Downloads

3

Readme

@vicentecalfo/ngx-insulin-calculator

This Angular component was created to show you how to calculate insulin dose with as little effort as possible.

This tool can never replace a professional medical advice.

Installation

First you need to install the npm module.

npm install @vicentecalfo/ngx-insulin-calculator

Usage

1. Import the module

import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { InsulinCalculatorModule } from '@vicentecalfo/ngx-insulin-calculator';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    InsulinCalculatorModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

2. Use the component

<insulin-calculator></insulin-calculator>

3. Change Styles

::ng-deep.ic-calculator {
	width: 450px;
    font-family: 'Raleway', sans-serif;
    display: block;
    margin:0 auto;
    .ic-title{
      font-weight: 900;
    }
  }

3.1 HTML Class anatomy

Class name | Description ---|--- ic-calculator | Wraps the entire component. ic-step | Represents a section of the calculator. ic-title | Section title. ic-field | Represents the entire row of a calculator field. ic-label | Field label. ic-input | Input field. ic-measure | Unit of measure field. round-top | Round the top corners. round-bottom | Round the bottom corners.

HTML markup structure.

<div class="ic-calculator round-top round-bottom">
  <div class="ic-step">
    <span class="ic-title round-top">
      Sensitivy factor 
    </span>
    <div class="ic-field">
      <div class="ic-label">
        Total daily insulin dose 
      </div>
      <div class="ic-input">
        <input type="number" min="0" value="18"/>
      </div>
      <div class="ic-measure">
        units
      </div>
    </div>
      <!-- others fields --->
  </div>
    <!-- others steps --->
</div>

4. API reference

4.1 Properties

Name | Description | Default value ---|---|--- @Input() targetGlucose: number | Target blood glucose in mg/dL. | 100 @Input() sensitivityFactorConst: number | Constant used for the calculation of insulin sensitivity factor. See "Rule of 1800". | 1800 @Input() mealBolusConst: number | Constant used for the calculation of the carbohydrate ratio. See "Rule of 500". | 500 @Input() labels | JSON structure for i18n. | See JSON structure. @Output() valuesChange: InsulinCalculatorOutput| Event emitted for each value changed in the calculator fields with all updated values. | See output structure.

JSON structure for i18n.

{
	sensitivityFactor: {
  	title: 'Sensitivy factor',
		label: 'Total daily insulin dose',
		measure: 'units'
	},
	correctionBolus: {
	  title: 'Correction bolus',
		currentGlucose: {
			label: 'Current blood glucose',
			measure: 'mg/dL'
		},
		targetGlucose: {
			label: 'Target blood glucose',
			measure: 'mg/dL'
		},
		sensitivityFactor: {
			label: 'Insulin sensitivity factor',
			measure: 'mg/dL'
		},
		result: {
			label: 'Insulin dose',
			measure: 'units'
		}
	},
	mealBolus: {
		title: 'Meal bolus',
		intakeCarbs: {
			label: 'Intake carbs',
			measure: 'g'
		},
		carbRatio: {
			label: 'Carb ratio',
			measure: 'g'
		},
		result: {
			label: 'Insulin dose',
			measure: 'units'
		}
	},
	totalResult: {
		title: 'Total insulin dose',
		label: 'Meal + Correction bolus',
		measure: 'units'
	}
}

Output structure.

{
	dailyInsulinDose: 18,
	intakeCarbs: 60,
	carbRatio: 28,
	mealBolus: 2,
	currentGlucose: 120,
	targetGlucose: 100,
	sensitivityFactor: 100,
	correctionBolus: 0,
	totalDosage: 2
}

5. Calculator inputs

Field | Description ---|--- Total daily insulin dose | The daily dose of insulin is used to calculate the carbohydrate ratio and then calculate the correction bolus and meal bolus. Intake carbohydrate | Total grams of carbohydrates to be eaten. Carbohydrate ratio | This is how many grams of carbohydrates are covered by one unit of insulin. Meal bolus | It is the amount (in units) of ultra-fast insulin needed to cover the grams of carbohydrates. Current blood glucose | Your current blood glucose concentration in mg/dL. Target blood glucose | Your target blood glucose concentration in mg/dL. Correction bolus | It is the amount (in units) of insulin needed to reduce glucose to the target. Insulin sensitivity factor | The insulin sensitivity factor tells you how many points, in mg/dL, your blood glucose will drop for each unit of insulin that you take.

6. Insulin calculator service

First, inject the service into the component.

constructor(private insulinCalculator: InsulinCalculatorService){}

6.1 Methods

Method | Description | Return ---|---|--- sensitivityFactorCalc(dailyInsulineDose: number, constant = 1800) | Calculates the value of the insulin sensitivity factor. | Number (in mg/dL) correctionBolusCalc(currentGlucose: number, targetGlucose: number, sensitivityFactor: number) | Calculates the correction bolus. | Number (insulin units) mealBolusCalc(intakeCarbs: number,dailyInsulineDose: number,constant = 500) | Calculates the meal bolus. | { carbCoveragePerUnit (carb ratio in mg/dL), mealBolus (insulin units) } mealBolusDefaultCalc(intakeCarbs: number, defaultCarbCoverage = 15) | Calculates the meal bolus by default carb coverage | { carbCoveragePerUnit (carb ratio in mg/dL), mealBolus (insulin units) } convertMgdlToMmoll(mgdlValue: number, constant = 18) | Convert milligrams per deciliter to millimoles per liter | Number (in mmol/L) convertMmollToMgdl(mmollValue: number, constant = 18)| Convert millimoles per liter to milligrams per deciliter | Number (in mg/dL)

7. Notice

This tool can never replace a professional medical advice.