I love this thread.
I’ve been wondering for a while what it would look like to manage a complex data model on the network.
My first real client project as an intern was to build a health care management application for a youth counseling services provider. At the time I was instructed by my manager to build a database with MongoDB, which quickly became challenging when I needed to update documents for complex relationships, especially needing to ensure accuracy in medical records and for State billing. At the time I didn’t know any better but I quickly became familiarized with modeling complex relationships for key-value documents.
I’ve been thinking about what it would look like to migrate that MongoDB database to the SAFE network.
I’ve also wondered what it would be like to migrate a MySQL database to the SAFE network.
What I’m currently imagining is that everything is simply composed of MutableData structures and MD name references.
In the healthcare application, for example, I have the following models:
Client, Assessment, BillingInvoice, Casenote, Group, Site, Counselor, Treatment, Session
Taking Client as an example, entries could be like so:
created_on: {type: Date, default: Date.now},
active: {type: Boolean, default: true},
intake_date: {type: Date},
asi_date: String,
continue_treatment_date: String,
discharge_date: String,
deadline: {
date: Date,
form: String
},
first_name: String,
last_name: String,
age: Number,
ssn: Number,
birth_date: {type: Date},
address: {
street: String,
city: String,
zip: Number
},
phone: Number,
gender: String,
ethnicity: String,
marital_status: String,
disability: String,
primary_drug: String,
enrolled_school: Boolean,
highest_grade: Number,
secondary_drug: String,
treatment_service: String,
modality: String,
employment_status: String,
site_groups: String,
site_location: MD name of Site instance},
cin: String,
aid: String,
aid_update: {type: Date},
dsm: {type: Schema.Types.Mixed},
icd10: {type: Schema.Types.Mixed},
assessments: [<array of MutableData names that represent Assessment instances>],
case_notes: [<array of MutableData names that represent Casenote instances>],
intake: MD name of Intake,
treatments: [<array of MutableData names that represent Treatment instances>],
counselor: MD name of Counselor instance,
billable: {type: Boolean}
For retrieving an instance of Client, my first approach would be to fetch the MD, search for entries that are references to other MD’s, fetch them and search again, recursively…
I’ve been playing around with managing deeply nested data on the client, cleanest - npm.
I might use a similar recursive solution to migrate the current MongoDB over to the SAFE network. It may not be bad for migrating a SQL dbms if we could get it in JSON format.
Probably much better ideas and implementations out there but this is where I’ll start experimenting.