D4H API

The D4H API (Application Programmer Interface) is a powerful way to access and interoperate with your organization’s D4H data, and enhance your organization’s D4H usage of it with your own developments.

For example you can create your own mobile application for D4H (in additional to the D4H mobile applications, that use the API.) That, or you can craft your own simple scripts, e.g. to provide a custom quiz to your users via the whiteboard.

The simplest way to get started is:

A more flexible (but marked as experimental, and quite likely soon changing) approach is to implement a user “login”, to gather a token on demand. Note: This isn’t quite as simple as it first appears, it is two step not one. ( When we log in to D4H first with an account it is second our membership in an organization/team that we then use for most API calls, and some accounts are members of multiple teams. ) The authentication API grants an account token, and to call the main APIs one needs to use the account token to acquire a membership token from that account token. (The generated token above – from the team website – is already a membership token.)

Once you have a working token you can access most of the team data; and update some.

  • Activities (past and future)
  • Duty records
  • Member records
  • Groups
  • Equipment (and more)
  • Tasks
  • … and more

What do you want your D4H data to do?

You might want to create a simple an app or webpage to allow your membership to submit maintenance reports your way, or you might want to display call statistics or some recent incident information (or available tasks) on a display in your building. The D4H API allows you to decide what is important to you, and enhance D4H towards that goal. (I’d love to hear your thoughts and ideas. Let me know.)

Powerful, but still ‘Work In Progress’, I hope…

Much as the D4H API is very powerful, the API is incomplete in a few key areas: incident updating, qualifications, tags, custom fields, and more.

Hopefully those will be coming because without them activities can be created, but not updated in any way (not adding a location, a tag, a description, nothing.) This limits any field-based tools for incidents.

No access to qualifications means we cannot create our own qualification reminder systems, and qualifications (we have many tens for every member) are a key challenge for our membership.

Your D4H Calendar…

Subscribing to your D4H calendar is a must for staying connected to your organization’s upcoming activities. I doubt too many D4H users know they can, and fewer do, hence I’m repeating/reiterating the helpful D4H guide on how to subscribe to your calendar.

Visit your calendar at https://%5BYOUR SERVER].d4h.org/team/calendar/month/ – which you can get to from the Planning menu. Scroll down to the bottom and turn on “iCal” (Internet Calendar) support.

Subscribe-To-D4H-Calendar
Copy your URL (web address)…

Once you have your URL/web address (with the gobbledegook key at the end, which I’ve hidden here … and you should protect yours ) then copy that into a copy-n-paste buffer.

If you don’t know how to “subscribe to a remote calendar” for your calendar client or service, then revisit D4H’s help on “exporting a calendar”, it gives you good examples.

Once you’ve subscribed to the calendar it will fill in the upcoming exercises and events you are attending. (It might take a little time to settle down, after having been added, but once settled it’ll update automatically & regularly.) You can even get automatic calendar reminders / notifications for those activities.

If you are out and about (on the road or otherwise not logged in to D4H on your computer to check) your calendar is what keeps you connected to your organization’s activities. Subscribe to your D4H calendar.

Inviting Groups in D4H…

We are a mountain fire department with both a community and significant wildland potential (with urban interface.) Our firefighters train for structural firefighting and wildland firefighting (and more.) We also have a wildland team for additional firefighters that respond to wildland fires.

We’ve created four D4H groups:

  • Full Firefighters (FFF)
  • Wildland Team Firefighter (WLT)
  • (Incident-only) Active Full Firefighters (AFFF)
  • (Incident-only) Active Wildland Team Firefighter (AWLT)

For structure fires, medical incidents, hazardous materials, and such only our AFFF respond. For wildland fires, illegal / unattended campfires, smoke reports both AFFF and AWLT respond. We manage their “requested” status in D4H by adding the appropriate group.

Group-Invitations

This keeps our memberships’ percentages correctly representing their standing. They are invited (requested) to the incidents they can attend and not those they cannot, nor those they are temporarily unavailable for.

(More precisely – when creating an incident report – we add the personnel that attended and mark them as attended, then use “Quick Add” to add the correct “Active” response groups. Note that the newly added members are added and left “selected”. We then use “Bulk Action” to “Set Status” to “Absent”. )

Our membership are operational (our responders) or non-operational (administration, support.) When a firefighter has to take an absence we do NOT change their operational status but we temporarily move them out of their “Active” group. (We do have a “Temporary non-Operational” group, but that is less important.)

Combining/processing D4H reports

D4H comes with a powerful reporting capability to analyse your team data. Much of the data your organization has gathered in D4H is available via reports. That said, we have custom logic that we need to apply for our firefighter’s annual requirements.  We gather the firefighter’s fire training hours, their medical training hours, their station training hours and more. Each of these come from a separate D4H report. Eight of them. We combine the outputs from a number of D4H reports into one combined report – with our logic and our presentation – for ease of use by our firefighters. That takes a bit of processing…

We use the “Download to Spreadsheet” option on the report page (see below) which creates and downloads a CSV (comma separated variable) text file that can be easily processed by Excel (and other spreadsheet programs) or by scripting languages:

Exporting-CSV

We download the output and rename the file as (say) fire.csv (with one named for each of the others.) We then process these files using a ruby script…

require 'csv';
# Fire
puts "---------------------------------------------------------------------- Fire"
CSV.foreach("fire.csv", :encoding => 'bom|utf-8') do |row|
    if $. > 1
        # Skipped header line...
        raw_name = row[1]     # Name in column 1
        name = raw_name.strip # Trimmed spaces from name
        fire_hours = ( row[5].to_f / 60 ) # Fire hours...
        ...

In order to speed the process of generating the report data … by removing the manual steps of selecting the report, selecting the date range (and not making a mistake), remembering to press ‘GO’ to re-run it with the date range, then downloading … we created a local HTML file called edit-to-download-reports.html with links to each report.

To download we (1) login to D4H in a browser (2) open the HTML file with links (anchor tags) for each of these, where you would replace:

  1. The subdomain to your D4H subdomain
  2. The report identifier (get it from the URL of the report)
  3. The start and end dates. We typically have the start of year and the end of the month we are reporting to.

Extract the report ID from the end of the report web address:

https://{YOUR SUBDOMAIN}.d4h.org/team/reports/custom/view/{REPORT_ID}

Remember to edit the “endDate” if you are running these for (say) a new month:

https://{YOUR SUBDOMAIN}.d4h.org/team/oldexport/?category=reports_custom&format=csv&param%5Breport_id%5D={REPORT_ID}&param%5BstartDate%5D=2018-01-01&param%5BendDate%5D=2018-12-31

We’ve found that by using D4H reporting and then exporting to CSV file format we can extend the functionality to our custom needs.

Response Utilities for D4H (iOS)

I am a volunteer firefighter in the mountains of Colorado, USA. We use D4H – Readiness & Response for managing many aspects of the department. We record incidents, exercises, events and attendance in D4H. We manage our inventory (for multiple stations, apparatus and personnel) and we maintain individual certifications / qualifications, and more, in D4H. Our members use D4H a lot.

D4H is a very powerful system with a lot of features, and its website is somewhat overwhelming on any mobile device, especially a mobile phone. Our membership needed something less powerful, an application for the tasks they perform on the go; viewing activities, setting attendance, communicating with other members, and updating off duty.

I created Response Utilities to allow our membership to interact with D4H. Response Utilities is a simple interface targeted at individual members, allowing them to view upcoming activities (and set their attendance), review past activities (incidents and more), and communicate with other members of the agency. Members who default to “on duty” (e.g. volunteers) are also able to easily set their “off duty” times.

Find out more here:

https://www.neukadye.com/mobile-applications/response-utilities/

Response-Utilities

Beta Testing – please help me improve faster…

I hate breaking apps, especially when I know they are being used in the field. A crash in the field can mean significant lost time and data. Not good! That said, as platforms continually change under the application (and their languages mature) even rebuilding an app (with no changes from me) can break it. I don’t release often enough because of the fear of breaking a production app. Beta testers help reduce that stress, and allow me to make progress. Please participate in beta testing, when you can afford:

Timestamped Field Notes iOS:

https://testflight.apple.com/join/y4BCm9Rk

Field Triangulate iOS:

https://testflight.apple.com/join/EUHgZByN

Field Triangulate Android:

https://play.google.com/apps/testing/com.neukadye.triangulation

Notes Collector iOS:

https://testflight.apple.com/join/cSifs1s5

Notes Collector Android:

https://play.google.com/apps/testing/com.neukadye.notescollector

Android Triangulate Rebuilt

Triangulate-Rebuild

I’ve been working to update Triangulate on Android, and that include porting it to Kotlin (Google / Android replacement for Java.) In sort, I’ve changed every line.

Further I’ve worked to improve handling for offline (it was not as simple as I’d first considered, and testing did not uncover that.) Finally I’ve added a first attempt at allowing the devices sensors to help determine a (rough) bearing, enabling some usage even without the (more accurate) handheld compass.

I would appreciate some help checking it out before I overwrite the existing application with this version. Please check it out at:

https://play.google.com/apps/testing/com.neukadye.triangulation

What next for Notes Collector?

Notes Collector is progressing for basic usage, both on iOS and on Android. (Beta testers still welcome, and appreciated.)

That said, Notes Collector was developed based on Timestamped Field Notes in order to migrate to more flexible internal infrastructure, to allow some experimentation on new features (without destabilizing TFN), and to more easily support more platforms (iOS, Android and Web.)

Here are some suggestions/requests I’ve heard from you over the years:

  • Allow an optional photograph to be added to a note item.
  • Allow an optional location (latitude / longitude) to be added to a note item.
  • Sharing an event (a set of notes) with other users, in real-time.
  • Create “icon/photo” based keyword buttons.

Please let me know your thoughts on the features / improvements you’d like to see for Notes Collector.