Skip to content

Instantly share code, notes, and snippets.

@henrymazza
Last active December 17, 2021 11:27
Show Gist options
  • Save henrymazza/b5612c22ba18650073cf0cbc1e8d8097 to your computer and use it in GitHub Desktop.
Save henrymazza/b5612c22ba18650073cf0cbc1e8d8097 to your computer and use it in GitHub Desktop.

Payload for ML

PS: all data was anonymized

ClientReferralMember

File: sonder-rails/app/models/client_referral_member.rb

  • this holds the match pair
  • is a Join Table that holds (but not limited to) these associations:
    • client_referral
    • persona_client
    • persona_provider
  • for our purposes aasm_state will always be ‘member_selected’ (the initial state), which may become:
    • accepted
    • notification_delayed
    • notified
    • member_selected (initial)
    • scheduled
    • expired
    • declined
  • Attributes:
  [25] pry(main)> crm
#<ClientReferralMember:0x000000010810c990> {
                                 :id => 400,
                 :client_referral_id => 564,
                        :notified_at => Tue, 24 Apr 2018 16:13:51 UTC +00:00,
                        :declined_at => nil,
                        :accepted_at => nil,
                               :note => nil,
                         :aasm_state => "expired", 
                         :created_at => Tue, 24 Apr 2018 16:13:51 UTC +00:00,
                         :updated_at => Tue, 24 Apr 2018 17:20:13 UTC +00:00,
         :provider_rematch_reason_id => nil,
                         :patient_id => nil,
                       :block_number => 1,
                       :scheduled_at => nil,
                         :expired_at => Tue, 24 Apr 2018 17:20:13 UTC +00:00,
                       :referral_key => "2b63539f91fb0ac69dc9",
                :persona_provider_id => 137,
          :last_contact_attempted_at => nil,
                   :contact_attempts => 0,
                       :search_order => nil,
                       :timed_out_at => nil,
                   :persona_admin_id => nil,
            :notification_delayed_at => nil,
    :manual_match_client_notified_at => nil
}
[26] pry(main)>

ClientReferral

File: sonder-rails/app/models/client_referral.rb

  • filter are properties used to obtain a match from the DB (match info)
  • one filter results in many matches (CRMs)
  [6] pry(main)> ClientReferral.last(rand(100)).first # some random NCR

  ClientReferral Load (17.8ms)  SELECT "client_referrals".* FROM "client_referrals" ORDER BY "client_referrals"."id" DESC LIMIT $1  [["LIMIT", 100]]
  
#<ClientReferral:0x000000011dbb1250> {
                             :id => 318940,
                     :aasm_state => "processing",
                     :created_at => Thu, 18 Nov 2021 02:47:54 UTC +00:00,
                     :updated_at => Thu, 18 Nov 2021 02:48:12 UTC +00:00,
              :stripe_card_token => nil,
             :stripe_customer_id => nil,
                 :internal_match => false,
                         :filter => {
                            "query" => {
                         "ages" => [[0] 2798],
                    "associate" => false,
                    "locations" => [
                      [0] {
                            "lat" => "40.0149856",
                            "lng" => "-105.2705456",
                          "radius" => 25
                        }
                      ],
                    "specialties" => [
                      [0] 2881,
                      [1] 2877,
                      [2] 2869,
                      [3] 2846
                    ],
                                 "matching_enabled" => true,
                                "accepting_clients" => true,
                                "location_accesses" => true,
                             "telehealth_preferred" => false,
                        "enabled_matching_networks" => [[0] 19],
                      "exclude_past_notified_limit" => true,
            "any_provider_network_matching_enabled" => true
        }
    },
                      :form_data => {},
                          :issue => {},
                        :clients => {},
                         :config => {
                                "automatch" => true,
                                "time_zone" => "America/Denver",
                             "max_contacts" => 25,
                           "accept_timeout" => 60,
                         "auto_cancel_days" => 8,
                       "block_accept_count" => 5,
                       "block_notify_count" => 10,
                   "distance_search_expand" => 10,
                   "distance_search_radius" => 15,
                  "accept_schedule_timeout" => 24,
               "distance_search_expand_max" => 25,
            "automatch_providers_min_count" => 2,
        "pending_referral_auto_cancel_days" => 10
    },
             :contact_first_name => "Jess-313983",
              :contact_last_name => "Schoen-313983",
                  :contact_email => "[email protected]",
                  :contact_phone => "7205136681",
            :contact_sms_allowed => false,
                 :insurance_name => nil,
            :insurance_plan_name => nil,
               :insurance_number => nil,
                :insurance_group => nil,
    :insurance_holder_first_name => nil,
     :insurance_holder_last_name => nil,
                   :referral_key => "de4f78c66dd1502141b0",
              :persona_client_id => 307423,
              :contact_birthdate => Sat, 02 Oct 1993,
                      :gender_id => 222,
             :contact_cell_phone => "7205136681",
                    :notified_at => Thu, 18 Nov 2021 02:47:54 UTC +00:00,
                    :can_contact => false,
                    :canceled_at => nil,
                 :notified_count => 1,
                :referral_source => nil,
               :admin_touched_at => nil,
           :send_reminder_emails => true,
              :pending_stated_at => nil,
              :pending_reason_id => nil,
                      :ad_medium => nil,
                  :ad_track_date => nil,
        :form_wizard_response_id => 3012040,
              :external_referral => nil,
       :external_referral_search => nil,
         :external_referral_date => nil,
                    :lat_lng_zip => "72907-0537",
                   :lat_lng_city => "Caryton",
                  :lat_lng_state => "AK",
               :lat_lng_geo_data => {},
                           :tags => [],
                   :needs_review => false,
              :backfill_eligible => true
}
[7] pry(main)>

Persona::Provider

File: sonder-rails/app/models/persona/provider.rb

  • Represents a provider, more data into its user association
  [23] pry(main)> crm.persona_provider
  
  Persona::Provider Load (7.3ms)  SELECT "persona_providers".* FROM "persona_providers" WHERE "persona_providers"."id" = $1 LIMIT $2  [["id", 137], ["LIMIT", 1]]

#<Persona::Provider:0x00000001088cab28>
  {
                                :id => 137,
                           :user_id => 137,
                        :created_at => Wed, 16 Mar 2016 23:00:40 UTC +00:00,
                        :updated_at => Tue, 03 Aug 2021 18:17:51 UTC +00:00,
                               :npi => "1245319599",
                 :accepting_clients => false,
             :availability_last_set => Fri, 30 Oct 2020 17:32:52 UTC +00:00,
                :remittance_address => "15818 W 83rd Ave",
                :education_level_id => 2688,
                  :payout_method_id => 2700,
                  :matching_enabled => true,
                         :associate => false,
       :ach_w9_information_recevied => false,
           :client_portals_required => true,
                 :training_complete => true,
             :freshsales_contact_id => "5004176537",
                     :login_allowed => true,
                      :push_enabled => false,
                    :pay_guaranteed => true,
             :pick_as_own_therapist => false,
                    :practice_state => "CO",
            :telehealth_attested_at => Wed, 18 Mar 2020 04:15:32 UTC +00:00,
    :telehealth_last_attestation_ip => #<IPAddr: IPv4:71.33.150.124/255.255.255.255>,
                       :search_rank => 49,
              :telehealth_preferred => true,
             :accepting_sam_clients => false,
                              :ptan => nil,
     :total_referral_notified_today => 0
}

Persona::Client

File: sonder-rails/app/models/persona/client.rb

  • Represents a client, more data into its user association
#[24] pry(main)> crm.persona_client
#   Persona::Client Load (30.6ms)  SELECT "persona_clients".* FROM "persona_clients" INNER JOIN "client_referrals" ON "persona_clients"."id" = "client_referrals"."persona_client_id" WHERE "client_referrals"."id" = $1 LIMIT $2  [["id", 564], ["LIMIT", 1]]
#<Persona::Client:0x0000000108af7e00>
                                {
                              :id => 149251,
                         :user_id => 1,
                      :created_at => Wed, 02 Jun 2021 02:42:09 UTC +00:00,
                      :updated_at => Wed, 02 Jun 2021 02:42:09 UTC +00:00,
              :stripe_customer_id => nil,
                   :login_allowed => true,
                 :disallow_claims => false,
                :allow_scheduling => true,
                    :push_enabled => false,
                       :ad_medium => nil,
                   :ad_track_date => nil,
      :notify_of_scheduled_charge => false,
        :send_first_nps_survey_at => nil,
    :send_four_week_nps_survey_at => nil,
                            :tags => [],
                :allow_multipayor => false,
              :financial_owner_id => "priv.billing.client:149251"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment