sfbrigade / bats-server

Routed is an app to help ambulances direct non-critical patients to hospital emergency rooms with the most availability.
https://routedapp.org/
GNU Affero General Public License v3.0
18 stars 12 forks source link

Separate `DeliveryStatus` value into multiple statuses? #210

Open fwextensions opened 2 years ago

fwextensions commented 2 years ago

There's a DeliveryStatus enum that tracks the state of the ringdown (whether it was sent or received) and the state of the patient (arrived or offloaded) and the unit (returned to service), as well as whether some of those states have been acknowledged by the hospital.

It's potentially confusing to have one value tracking the state of those different objects, and may be cleaner having them separated. For instance, if the acknowledgements are coming from people, they might arrive after the patient or unit has already changed state.

On the server, there's a PatientDelivery model that uses the DeliveryStatus values, and on the client there's a Ringdown model that uses a copy of those same values. So it's already confusing the status of delivering the patient and the status of the ringdown transmission.

There's also some code, like in RingdownCard that doesn't account for the acknowledged versions of the states, and would probably not show the right thing in those cases:

  const canBeDismissed =
    ringdown.currentDeliveryStatus === Ringdown.Status.OFFLOADED ||
    ringdown.currentDeliveryStatus === Ringdown.Status.CANCELLED ||
    ringdown.currentDeliveryStatus === Ringdown.Status.REDIRECTED;

  return (
    <div
      className={classNames('ringdown-card height-auto', className, {
        'ringdown-card--dismissable': canBeDismissed,
        'ringdown-card--expanded': isExpanded,
        'ringdown-card--cancelled': ringdown.currentDeliveryStatus === Ringdown.Status.CANCELLED,
        'ringdown-card--redirected': ringdown.currentDeliveryStatus === Ringdown.Status.REDIRECTED,
        'ringdown-card--offloaded': ringdown.currentDeliveryStatus === Ringdown.Status.OFFLOADED,
      })}
    >