New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@awell-health/awell-score

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@awell-health/awell-score - npm Package Compare versions

Comparing version 1.0.3-beta6 to 1.0.4-beta8

dist/lib/parseToApiResultFormat/index.d.ts

46

dist/classes/Score.d.ts
import { z } from 'zod';
import { type ScoreInputSchemaType, type ScoreOutputSchemaType, type ScoreType } from '../types';
import { type ScoreInputSchemaType, type ScoreOutputSchemaType, type ScoreType, type TerminologyType } from '../types';
/**

@@ -10,2 +10,6 @@ * Class representing a Score, which calculates results based on input and output schemas.

/**
* The ID of the score.
*/
id: string;
/**
* The name of the score.

@@ -31,2 +35,6 @@ */

/**
* The FHIR terminology of the score.
*/
terminology: TerminologyType | undefined;
/**
* The function to calculate the score.

@@ -46,2 +54,3 @@ */

constructor(score: ScoreType<InputSchema, OutputSchema> & {
id?: string;
inputSchema: InputSchema;

@@ -64,17 +73,10 @@ outputSchema: OutputSchema;

strictMode?: boolean;
/**
* Specifies the format of the output:
* - `simple`: Key-value where the key is the result ID and the value is the result.
* - `awell`: Enriched array format.
* @default 'simple'
*/
outputFormat?: 'simple' | 'awell';
};
}): Record<keyof OutputSchema, z.infer<OutputSchema[keyof OutputSchema]['type']> | null>;
/**
* Casts input values to their exact types based on the input schema.
* Tries to cast input values to their exact types based on the input schema.
* @param input - The input data to cast.
* @returns The cast input data.
*/
castInputsToExactTypes(data: Record<string, unknown>): Record<string, unknown>;
tryCastInputsToExactTypes(data: Record<string, unknown>): Record<string, unknown>;
/**

@@ -86,4 +88,26 @@ * Simulates input values based on the input schema.

simulatedInput: Record<string, unknown>;
simulatedOutput: Record<string, unknown>;
results: Record<keyof OutputSchema, z.infer<OutputSchema[keyof OutputSchema]['type']> | null>;
};
/**
* Formats the results of the score calculation.
* @param results - The results to format.
* @param opts - The options for formatting the results.
* @returns The formatted results.
*/
formatResults(results: Record<keyof OutputSchema, z.infer<OutputSchema[keyof OutputSchema]['type']> | null>, { opts, }: {
/**
* Specifies the format of the output:
* - `simple`: Key-value where the key is the result ID and the value is the result.
* - `awell`: Enriched array format.
* @default 'simple'
*/
opts?: {
format: 'simple' | 'awell';
};
}): import("../lib/parseToApiResultFormat/types").ApiResultType[] | Record<keyof OutputSchema, z.TypeOf<OutputSchema[keyof OutputSchema]["type"]> | null>;
/**
* Returns the API schema for the score.
* @returns The API schema for the score.
*/
get apiSchema(): import("../lib/parseToApiSchema/awell/types").ApiScoreType;
}

@@ -12,2 +12,3 @@ "use strict";

const simulation_1 = require("../lib/simulation");
const parseToApiResultFormat_1 = require("../lib/parseToApiResultFormat");
/**

@@ -24,2 +25,4 @@ * Class representing a Score, which calculates results based on input and output schemas.

constructor(score) {
var _a;
this.id = (_a = score.id) !== null && _a !== void 0 ? _a : score.name;
this.name = score.name;

@@ -30,2 +33,3 @@ this.readme_location = score.readme_location;

this.outputSchema = score.outputSchema;
this.terminology = score.terminology;
this._calculate = score.calculate;

@@ -41,15 +45,15 @@ this.inputSchemaAsObject = (0, lib_1.createZodObjectFromSchema)(this.inputSchema);

var _a;
const parsedData = this.inputSchemaAsObject.parse(((_a = params === null || params === void 0 ? void 0 : params.opts) === null || _a === void 0 ? void 0 : _a.strictMode) === true
const d = this.inputSchemaAsObject.parse(((_a = params === null || params === void 0 ? void 0 : params.opts) === null || _a === void 0 ? void 0 : _a.strictMode) === true
? params.payload
: this.castInputsToExactTypes(params.payload));
: this.tryCastInputsToExactTypes(params.payload));
return this._calculate({
data: parsedData,
data: d,
});
}
/**
* Casts input values to their exact types based on the input schema.
* Tries to cast input values to their exact types based on the input schema.
* @param input - The input data to cast.
* @returns The cast input data.
*/
castInputsToExactTypes(data) {
tryCastInputsToExactTypes(data) {
/**

@@ -151,7 +155,33 @@ * Casts a single input value to its exact type.

simulatedInput: lodash_1.default.pickBy(simulatedInput, value => value !== undefined),
simulatedOutput: this.calculate({ payload: simulatedInput }),
results: this.calculate({ payload: simulatedInput }),
};
}
/**
* Formats the results of the score calculation.
* @param results - The results to format.
* @param opts - The options for formatting the results.
* @returns The formatted results.
*/
formatResults(results, { opts, }) {
if ((opts === null || opts === void 0 ? void 0 : opts.format) === 'simple') {
return results;
}
return (0, parseToApiResultFormat_1.parseToApiResultFormat)(results, this.outputSchema);
}
/**
* Returns the API schema for the score.
* @returns The API schema for the score.
*/
get apiSchema() {
return (0, lib_1.parseToAwellApiSchema)({
scoreId: this.id,
scoreName: this.name,
scoreDescription: this.description,
inputSchema: this.inputSchema,
outputSchema: this.outputSchema,
terminology: this.terminology,
});
}
}
exports.Score = Score;
//# sourceMappingURL=Score.js.map
export * from './getUnionType';
export * from './parseReadmeToHtml';
export * from './createZodObjectFromInputSchema';
export * from './parseToApiSchema';

@@ -20,2 +20,3 @@ "use strict";

__exportStar(require("./createZodObjectFromInputSchema"), exports);
__exportStar(require("./parseToApiSchema"), exports);
//# sourceMappingURL=index.js.map

@@ -10,2 +10,15 @@ "use strict";

outputSchema: bmi_schema_1.BmiOutputSchema,
terminology: {
category: [
{
coding: [
{
system: 'http://terminology.hl7.org/CodeSystem/observation-category',
code: 'vital-signs',
display: 'Vital Signs',
},
],
},
],
},
calculate: ({ data }) => {

@@ -12,0 +25,0 @@ const numeric_height_in_m = data.height / 100;

@@ -11,2 +11,15 @@ "use strict";

outputSchema: bmi_schema_1.BmiOutputSchema,
terminology: {
category: [
{
coding: [
{
system: 'http://terminology.hl7.org/CodeSystem/observation-category',
code: 'vital-signs',
display: 'Vital Signs',
},
],
},
],
},
calculate: ({ data }) => {

@@ -13,0 +26,0 @@ const FEET_TO_INCHES_FACTOR = 12;

@@ -129,3 +129,6 @@ "use strict";

const createScoreLibrary = (scoreObjects) => {
return Object.fromEntries(Object.entries(scoreObjects).map(([key, value]) => [key, new classes_1.Score(value)]));
return Object.fromEntries(Object.entries(scoreObjects).map(([key, value]) => [
key,
new classes_1.Score({ ...value, id: key }),
]));
};

@@ -132,0 +135,0 @@ exports.ScoreLibrary = createScoreLibrary({

import { z } from 'zod';
import { type ScoreInputSchemaType } from './ScoreInput.types';
import { type ScoreOutputSchemaType } from './ScoreOutput.types';
export interface CategoryType {
coding: {
system: string;
code: string;
display: string;
}[];
}
export interface TerminologyType {
category?: CategoryType[];
}
export type ScoreType<InputSchema extends ScoreInputSchemaType = ScoreInputSchemaType, OutputSchema extends ScoreOutputSchemaType = ScoreOutputSchemaType> = {

@@ -9,2 +19,3 @@ name: string;

outputSchema: OutputSchema;
terminology?: TerminologyType;
calculate: CalculateFn<z.ZodObject<{

@@ -11,0 +22,0 @@ [K in keyof InputSchema]: InputSchema[K]['type'];

@@ -21,2 +21,5 @@ import { z } from 'zod';

type: z.ZodOptional<z.ZodNumber> | z.ZodNumber;
uiOptions?: {
component?: 'slider';
};
}

@@ -23,0 +26,0 @@ export interface EnumNumberInputType extends BaseInputType {

import { z } from 'zod';
import { type LabelType } from './Label.types';
export interface CodeType {
coding: {
system: string;
code: string;
display: string;
}[];
text: string;
}
export interface ScoreOutputType {
label: LabelType;
type: z.ZodTypeAny;
type: z.ZodString | z.ZodNumber | z.ZodBoolean;
unit?: LabelType;
interpretation?: LabelType;
terminology?: unknown;
terminology?: {
code: CodeType;
};
}
export type ScoreOutputSchemaType = Record<string, ScoreOutputType>;
{
"name": "@awell-health/awell-score",
"version": "1.0.3-beta6",
"version": "1.0.4-beta8",
"description": "Library of Medical Score functions",

@@ -48,3 +48,3 @@ "packageManager": "yarn@4.6.0",

},
"stableVersion": "1.0.3"
"stableVersion": "1.0.4"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc