emsi-lib
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

emsi-lib

Build Status Build Status Install Size

About

  • A EMSI (Emergency Management Shared Information) object model to manipulate emergency messages defined in ISO/TR 22351 document.

Main features

  • Provide high level abstraction of EMSI objects and types
  • Generate XML message from EMSI objects
  • Generate EMSI objects from XML
  • Check ISO rules (work in progress)

Usage

To use it install it first

Via npm:

npm install emsi-lib

Via yarn

yarn add emsi-lib

Generate XML EMSI (JS -> XML)

import { Emsi, Event, Mission, Context, ExternalInfo, Origin, /* ... */} from 'emsi-lib'

const extInfo = new ExternalInfo("https://secourir.eu/.../", InfoType.PHOTO, "Photos of the accident")

const origin = new Origin("43d38170-ce5d-4d8e-81d7-2bd4071d83f4", "58113", "SC/SDIS24")

const context = new Context(Mode.ACTUAL, MsgType.ALERT)
    .setFreeText("First message")
    .setLevel(Level.TACTICAL)
    .setSecurityClassification(SeClass.RESTRICTED)
    .setUrgency(Urgency.URGENT)
    .addExternalInfos([ extInfo ])
    .setOrigin(origin)

const mission = new Mission('Casualty search')
    .setStatus(MissionStatus.IN_PROGRESS, 30)
    .setPriority(MissionPriority.P3)
    .setStartTime(new Date())
    .setFreeText('Many victims')

const etype = new EType(['/TRP/COL'], ['/VEH/TRK', '/VEH/TRN'], ['/RAIL/TRK', 'ROAD'])

const event = new Event('FR-SC-24-0001', 'Railway accident')
    .setScale(Scale.LEVEL_1)
    .setEventType(etype)

const emsi = new Emsi()
    .setContext(context)
    .setEvent(event)
    .addMissions([mission])

const emsiXml = emsi.generateXml()

Populate EMSI object from XML (XML -> JS)

const target = new Emsi()
target.loadFromXml(emsiXml)

if (target.context?.urgency !== Urgency.URGENT) {

    if (target.context?.link?.[1].linkRole !== LinkRole.SUPERSEDE)
        target.context?.addLink([new Link('43d38170-ce5d-4d8e-81d7-2bd4071d83f4', LinkRole.SUPERSEDE)])

    emsi.mission?.[0].setEndTime(new Date())
    
    const newMessage = target.generateXml()
    /* Send newMessage */
}

Documentation

The documentation is available here (WIP).

Release History

A short list of features, fixes and changes for each release is available in CHANGELOG.md.

Contributing

Anyone is welcome to submit issues and pull requests

License

See LICENSE.

Package Sidebar

Install

npm i emsi-lib

Weekly Downloads

14

Version

0.1.5

License

ISC

Unpacked Size

94.3 kB

Total Files

88

Last publish

Collaborators

  • cpilatre