Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Model updates #1880

Merged
merged 11 commits into from
Mar 5, 2020
Merged

Model updates #1880

merged 11 commits into from
Mar 5, 2020

Conversation

jackcmeyer
Copy link
Member

@jackcmeyer jackcmeyer commented Mar 4, 2020

Fixes #1876
Fixes #1877
Fixes #1879

Changes proposed in this pull request:

  • change patient friendly id to be patient code and change it from sequentially generating number to randomly generated string
  • change database model ids from timestamp based ids to randomly generated uuids
  • adds created date and last updated date to database models

Newly added dependencies with Bundlephobia links:

BREAKING CHANGE: Any patient saved with friendly id will no longer map friendly id to the patient
object, thus not displaying it in the UI or have it available for search

fix #1876
@jackcmeyer jackcmeyer added 🐛bug issue/pull request that documents/fixes a bug 🚀enhancement an issue/pull request that adds a feature to the application patients issue/pull request that interacts with patients module scheduling issue/pull request that interacts with scheduling module labels Mar 4, 2020
@jackcmeyer jackcmeyer added this to the v2.0.0 milestone Mar 4, 2020
@jackcmeyer jackcmeyer requested review from fox1t and matteovivona March 4, 2020 03:11
@vercel
Copy link

vercel bot commented Mar 4, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/hospitalrun/hospitalrun-frontend/io02fx1v0
✅ Preview: https://hospitalrun-frontend-git-model-updates.hospitalrun.now.sh

@github-actions
Copy link

github-actions bot commented Mar 4, 2020

Size Change: 0 B

Total Size: 0 B

compressed-size-action

@@ -1,7 +1,10 @@
import { patients } from 'config/pouchdb'
import PatientRepository from 'clients/db/PatientRepository'
import Patient from 'model/Patient'
import { fromUnixTime } from 'date-fns'
import * as shortid from 'shortid'
Copy link
Member

Choose a reason for hiding this comment

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

I think we might not need * as shortid syntax since we have esModuleIntrop. Try with just import shortid from 'shortid'

@@ -1,17 +1,11 @@
import * as shortid from 'shortid'
Copy link
Member

Choose a reason for hiding this comment

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

same as before.

@@ -47,8 +48,15 @@ export default class Repository<T extends AbstractDBModel> {
}

async save(entity: T): Promise<T> {
const currentTime = getTime(new Date())
Copy link
Member

Choose a reason for hiding this comment

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

I really prefer saving dates in ISOString. It has same properties of ordering like unix timestamp but it is more readable. Can you change it to toISOString everywhere?

const savedEntity = await this.db.put({
_id: uuidv4(),
...valuesToSave,
createdDate: currentTime,
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use what is the standard defacto for naming these fields:

  • createdDate -> createdAt
  • lastUpdatedDate ->updatedAt

And use ISOString as format, as I already pointed out.

@fox1t
Copy link
Member

fox1t commented Mar 5, 2020

LGTM! Nicely done.

@fox1t fox1t merged commit 1c61301 into master Mar 5, 2020
@fox1t fox1t deleted the model-updates branch March 5, 2020 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛bug issue/pull request that documents/fixes a bug 🚀enhancement an issue/pull request that adds a feature to the application patients issue/pull request that interacts with patients module scheduling issue/pull request that interacts with scheduling module
Projects
None yet
3 participants