Skip to content

hds-lib

LibraryGitHub

The core JavaScript/TypeScript library powering all HDS applications.

  • HDSModel — loads and provides access to the HDS data model (items, streams, event types, datasources)
  • appTemplates — AppManagingAccount, Collector, CollectorRequest patterns for doctor/researcher apps. Includes the AppTemplate JSON loader (Ajv + cross-field validation), custom-field declarations (template-private streams via clientData.hdsCustomField), system-stream messaging (message/system-{alert,ack} for operator → user notifications + acks), and (Plan 71, v1.10.0) the Questionnaire request/answer event pairQuestionnaire is a reusable form template with a questions map (each question references an existing HDS item via itemRef with a temporal scope and optional subField qualifier); CollectorRequest can addQuestionnaire(q) to pack one or more questionnaires into a first-contact request; static helpers Questionnaire.makeRequestEvent, Questionnaire.writeBundled, and Questionnaire.buildAnswerEvent materialize the events on the patient side. Patient answers carry an explicit status enum (answered / no / unknown / declined) so explicit-no / I-don’t-know / I-decline have first-class storage instead of being inferred from absence. Coverage check (Plan 71 Phase G): appTemplates.checkQuestionnaireCoverage(q, request) reports which question streams the request’s permissions[] cover vs are missing and proposes the minimal additions; CollectorRequest#checkQuestionnaireCoverage(q) (read-only) + CollectorRequest#applyQuestionnaireCoverage(q) (in-place mutator) are the ergonomic wrappers — use the mutator from a Builder UI to one-click resolve missing-permission warnings. See the data-model documentation and the design reference.
  • HDSSettings — user settings singleton (theme, locale, timezone, date format)
  • HDSProfile — user profile management
  • eventToShortText — shared event formatter for diary display
  • Pryv integration — re-exports and patches for Pryv.io client library
  • ESM module ("type": "module")
  • TypeScript source in ts/, compiled to js/ via prepare script
  • Published as git dependency: git+https://github.com/healthdatasafe/hds-lib-js.git