KPB-US / dispatch-display

Display 911 dispatch call details, timer, and map in a station, cycling through active calls.
MIT License
0 stars 1 forks source link

Background #1

Closed mfrederickson closed 7 years ago

mfrederickson commented 7 years ago

Handle

Possible Design

Web server runs node. Planetpress posts all information to server. Server uses websockets to notify station/update display.



# Questions

1. Can there be multiple call types, or just one per call?
1. Do stations need to register their display with the server?
1. How do we restrict displays to stations?  (ip segment)
1. When should the call be cleared from the display?
1. What should be on the display when no calls are active?
mfrederickson commented 7 years ago

See Seattles 911 info here: http://www2.seattle.gov/fire/realTime911/getDatePubTab.asp selection_233

mfrederickson commented 7 years ago

https://github.com/KPB-US/seattle-fire-dispatch

mfrederickson commented 7 years ago

PlanetPress code that processes the email that comes from the 911 system:

'Narrative Time Start Position

narrativeStartPos = instr(watch.getvariable("CallData"),"Narrative Time~")

'Watch.Log "Narrative Time Starte Pos = " + cstr(narrativeStartPos), 2

'Breathing Subfield Extracton

breathingStartPos = instr(narrativeStartPos,watch.getvariable("CallData"),"Breathing:")

if breathingStartPos > 0 then
  breathingStartPos = breathingStartPos + 10
  breathingEndPos = breathingStartPos + 4
  breathing = ucase(trim(mid(watch.getvariable("CallData"),breathingStartPos, breathingEndPos-breathingStartPos)))
else
  breathing = "Unknown"
end if

Watch.SetVariable "Breathing", breathing
'Watch.Log "Breathing Start Pos = " + cstr(breathingStartPos), 2
'Watch.Log "Breathing End Pos = " + cstr(breathingEndPos),2
'Watch.Log "Breathing = " + breathing, 2

'Conscious Subfield Extraction

consciousStartPos = instr(narrativeStartPos,watch.getvariable("CallData"),"Conscious:")

if consciousStartPos > 0 then
  consciousStartPos = consciousStartPos + 10
  consciousEndPos = consciousStartPos + 4
  conscious = ucase(trim(mid(watch.getvariable("CallData"),consciousStartPos,consciousEndPos-consciousStartPos)))
else
  conscious = "Unknown"
end if

Watch.SetVariable "Conscious", conscious
'Watch.Log "Conscious Start Pos = " + cstr(consciousStartPos), 2
'Watch.Log "Conscious End Pos = " + cstr(consciousEndPos), 2
'Watch.Log "Conscious = " + conscious, 2

'Dispatch Code Subfield Extraction

dispatchcodePos =instr(watch.getvariable("CallData"),"Dispatch Code:")
if dispatchcodePos > 0 then
  dispatchcode = ucase(trim(mid(watch.getvariable("CallData"),dispatchcodePos+15, 8)))
else
  dispatchcode = "Unknown"
end if

Watch.SetVariable "DispatchCode", dispatchcode
'Watch.Log "Dispatch Code Start Pos = " + cstr(dispatchcodePos), 2
'Watch.Log "Dispatch Code = " + dispatchcode, 2

'Call Number Extraction

callnumStartPos =instr(watch.getvariable("CallData"),"Call Number:~") + 13
callnumEndPos =instr(watch.getvariable("CallData"),"Call Type:~")
if callnumStartPOs < callnumEndPos then
  callnum = ucase(trim(mid(watch.getvariable("CallData"),callnumStartPos,callnumEndPos-callnumStartPos)))
else
  callnum = "Unknown"
end if

Watch.SetVariable "CallNum", callnum
'Watch.Log "Call Num Start Pos = " + cstr(callnumStartPos), 2
'Watch.Log "Call Num = " + callnum, 2

'Call Type Extraction

calltypeStartPos =instr(watch.getvariable("CallData"),"Call Type:~") + 11
calltypeEndPos =instr(watch.getvariable("CallData"),"Source:~")
if calltypeStartPOs < calltypeEndPos then
  calltype = ucase(trim(mid(watch.getvariable("CallData"),calltypeStartPos,calltypeEndPos-calltypeStartPos)))
else
  calltype = "Unknown"
end if

Watch.SetVariable "CallType", calltype
'Watch.Log "Call Type Start Pos = " + cstr(calltypeStartPos), 2
'Watch.Log "Call Type = " + calltype, 2

'Cross Streets Extraction

xstreetsStartPos = instr(1,watch.getvariable("CallData"),"Cross Streets~") + 14
xstreetsEndPos = instr(1,watch.getvariable("CallData"),"Phone:~")
if xstreetsStartPos < xstreetsEndPos then
  xstreets = ucase(trim(mid(watch.getvariable("CallData"),xstreetsStartPos,xstreetsEndPos-xstreetsStartPos)))
  xstreets = replace(xstreets,"~"," ")
else
  xstreets = "Unknown"
end if

Watch.SetVariable "Xstreets", xstreets
'Watch.Log "Cross Streets Start Pos = " + cstr(xstreetsStartPos), 2
'Watch.Log "Cross Streets End Pos = " + cstr(xstreetsEndPos), 2
'Watch.Log "Cross Streets = " + xstreets, 2

'Location Extraction

locationPos =instr(watch.getvariable("CallData"),"Location:~") + 10
if xstreetStartPos < locationPos then
  location = ucase(trim(mid(watch.getvariable("CallData"),locationPos, (xstreetsStartPos - 14)-locationPos))) + ", AK"
  location = replace(location,"~", " ")
  location = replace(location,"VENUE:"," ")
else
  location = "Unknown"
end if

Watch.SetVariable "Location", location
'Watch.Log "Location Start Pos = " + cstr(locationPos), 2
'Watch.Log "Location = " + location, 2

Email template that goes to third party to notify responders:

Location: 
%{Location}

Cross Streets: 
%{XStreets}

Call Type: 
%{CallType}

Conscious: 
%{Conscious}

Breathing:
%{Breathing}

Dispatch Code:
%{DispatchCode}
mfrederickson commented 7 years ago

VBScript to post form data: https://support.microsoft.com/en-us/help/290591/how-to-submit-form-data-by-using-xmlhttp-or-serverxmlhttp-object

var DataToSend = "id=1";
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST","http://<%=Request.ServerVariables("Server_Name")%>/Receiver.asp",false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(DataToSend);

Javascript:

// Sending and receiving data in JSON format using POST method
//
var xhr = new XMLHttpRequest();
var url = "url";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        var json = JSON.parse(xhr.responseText);
        console.log(json.email + ", " + json.password);
    }
};
var data = JSON.stringify({"email": "hey@mail.com", "password": "101010"});
xhr.send(data);

https://stackoverflow.com/questions/24468459/sending-a-json-to-server-and-retrieving-a-json-in-return-without-jquery

Need to include JSON2.js at the top of the script.

mfrederickson commented 7 years ago

postman sample data:

{
    "location": "144 N BINKLEY ST",
    "venue": "SOLDOTNA",
    "crossStreets": "N BINKLY ST / PARK ST",
    "district": "CES AMBULANCE",
    "callNumber": "4448",
    "callType": "43-Caffeine Withdrawal",
    "callDateTime": "09/29/2017 15:30:34",
    "dispatchDateTime": "09/29/2017 15:33:47",
    "dispatchCode": "25C01",
    "breathing": "Yes",
    "conscious": "No"
}
mfrederickson commented 7 years ago

image