Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Six digit ID support #1

Merged
merged 15 commits into from
Dec 12, 2018
Merged

Six digit ID support #1

merged 15 commits into from
Dec 12, 2018

Conversation

ssrihari
Copy link
Contributor

No description provided.

(defn six-digit-ids [patient]
(or (:six-digit-ids patient)
(set (repeatedly (rand-int 3) spec/random-sdid))))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Shouldn't this be related to the UUIDs? Ideally, I'd have the structure: :patient {:cards [{:uuid "", :six-digit-id ""}]}}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will need not so trivial refactoring. Let's do this once we are done with the features?

(take 100)
shuffle
(take 6)
(apply str)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@divs1210 divs1210 Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doen't change the code much, and uses a lesser known fn instead of what we use everyday in clojure land. wouldn't like to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generation is different from the functionality that clojure.core is meant to do. I would embrace test.check as a core library in this case. See https://clojure.org/guides/spec#_custom_generators.

(let [six-digit-ids (set (concat (:six-digit-ids patient)
(map ->six-digit-id
(:card-uuids patient))))]
(contains? six-digit-ids six-digit-id)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't need to check in both uuids and six-digit-ids. Ideally, the six-digit-ids is just a cached conversion of UUIDs, and potentially some unmapped ones. But we would need to look up only in six-digit-ids. Not for performance reasons, but for simplicity.

Copy link
Contributor

@divs1210 divs1210 Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intertwining six digits and uuids would make it more complex, not simpler. you are already talking about caching and what not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not implying that we do caching, just that that's the perspective we should take.

UUIDs and six-digit IDs are both representations of the same thing: The card. And we should model that.

vals
(filter #(has-six-digit-id? % six-digit-id))))

(defn handle-six-digit-keyboard [{:keys [db]} [_ six-digit-id]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this and assumed the function had something to do with the android keyboard :). Which, doesn't appear to be the case. Have you seen assoc-into-db in events?

Copy link
Contributor

@divs1210 divs1210 Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We are already following this convention:
(defn handle-bp-keyboard [{:keys [db]} [_ kind value]]
  (cond
    (and (= kind :systolic)
         (or (and (re-find #"^[12]" value)
                  (= 3 (count value)))
             (and (not (re-find #"^[12]" value))
                  (= 2 (count value)))))
    (.focus (get-in db [:ui :bp :diastolic :ref])))
  {:db (assoc-in db [:ui :bp :value kind] value)})
  1. assoc-into-db returns a fn, is not super composable, and is used once in in the codebase. not sure if it should exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do this when we're writing a full handler anyway. assoc-into-db is not meant to be composed. It's meant to be a simple replacement for the full event handler.

(let [uuid (:uuid card)
sdid (:six-digit-id card)
field-to-update (if uuid :card-uuids :six-digit-ids)
update-with-value (or uuid sdid)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update-with-value shouldn't be independent from the previous decision of the field to update. We should use something in the lines of:

(case field-to-update
  :card-uuids uuid
  :six-digit-ids sdid)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in a couple of places, so we could extract this into a function too.

Copy link
Contributor

@divs1210 divs1210 Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will make this change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, i did try abstracting this out, and couldn't settle on the 'right' way to do this. let's pair on this.


:else
:pending)]
[:set-active-card uuid six-digit-id status]))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract this cond into a function :) Also, this doesn't feel exhaustive to me. Let's go over this together.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

@divs1210 divs1210 merged commit 7902738 into master Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants