Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-31-2020 08:07 PM
Hello friends.
I have two questions for you.
1st.) Currently, I am modeling a new application and I need to relate a Patient node with several Measures (there are 13 types of those) nodes, as per the attached image
If my model defines the measurementDate is located in the HAS relationship, is it feasible to transverse the graph to retrieve all measures from a group of patients ordered by patientId and measurementDate? Or extract all nodes from a range of dates?
This is a classic example of a MxN relationship in a relational database and, in this case, I would model the measurementDate field in the MxN table.
Is this approach correct?
2nd.) Person and Patient nodes share lots of information and Patient node is a derivation from Person node - you must be a Person before being a Patient. In the image, I have a Person (node) who is responsible for a Patient (node) like a mother is responsible for her child, the Patient is also Person
Should I replicate all shared attributes for both nodes or the attributes are automatically inherited from Person to Patient somehow? Does it make sense?
Thanks for your attention.
Renato
Solved! Go to Solution.
08-05-2020 01:39 PM
Hello @PeteM
You confirmed my supposition. I really appreciate your support in these questions, you saved me time on research, which I´ll use to better model my graph.
Thank you very much.
07-31-2020 08:32 PM
I'm fairly new to neo4j but I think I can offer some help.
The relationships between nodes are first class citizens, meaning they are just as important as the nodes. So you could think of your MxN join table as the HAS relationship and add the measurementDate attribute to the relationship HAS.
(:Patient)-[:HAS {measurementDate: date()]->(:Measure)
Traversing the graph to retrieve all measure from a group of patients and ordered by patientId and measurementDate is certainly feasible in this way. You would need to decide what format to save the measurementDate in however.
MATCH (p:Patient)-[rel:HAS]->(m:Measure) WHERE p.patientId IN [12,14,16] RETURN (p)-[rel]->(m) ORDER BY p.patientId, rel.measurementDate
2nd)
Attributes are not inherited between nodes. I would say however, to treat them as separate entities and keep only Patient related attributes, in the Patient node, and any Person attributes only in the Person node.
Optionally you could actually treat them as a single node with two labels. So if a Person was also a Patient, you would just use one node with two labels. (p:Person:Patient)
08-05-2020 01:39 PM
Hello @PeteM
You confirmed my supposition. I really appreciate your support in these questions, you saved me time on research, which I´ll use to better model my graph.
Thank you very much.
08-07-2020 04:29 AM
No problem. One thing that I have found is you can easily adjust your graph model depending on your needs. You could also deploy a test graph you can chop and change until it fits your needs (i.e. queries you want to run against it).
08-20-2020 02:00 AM
Hi everyone,
I think there's a potential problem with time measurement.
In principle a patient is always a person, or rather being a patient is the temporary state of a person. At least I would insert in the Patient node the start and end date of the state.
Alessio
08-20-2020 08:59 AM
Sure @asperlinga, a Patient is always a Person but a Person is not always a Patient, he/she could be a mom or dad taking his/her child to the hospital or attending a medical appointment.
Regarding time measurement, I am researching Date Modeling and found this article which gave me a good idea about how to proceed with that.
Anyway, this is a matter I like to discuss with people. I would be glad to keep this conversation.
Regards,
08-20-2020 08:12 AM
Check this link for some more ideas:
All the sessions of the conference are now available online