I have a business model in a Spring Application where Drugs exist. The theory behind this is, that the user has a global search function(like Google) with just one input field.
Drugs got a TradingName, expireDate.
Drugs are in physical Slots.
Drugs contain Substances.
(d:Drug), (s:Slot), (sub:Substances)
d.tradingName, d.expireDate, sub.substanceName are Strings.
s.number is a Long
Examples for search from a user in the input field.
Depon (is a trading name for a Drug)
Paracetamol (Substance Name)
355 (He wants to know which Drug is in Slot 355)
2021-02 (He wants to see what Drugs are expiring at February 2021)
The point is, that whatever the user searches for, the output should be the same. A list of the Drugs with all its information, but I am handling this in my frontend.
Now I have 3 queries.
1)
MATCH (d:Drug)
WHERE toLower(d.tradingName) CONTAINS toLower({0}) OR toLower(d.expire) CONTAINS toLower({0})
WITH d, datetime(d.expire) as expireDate
RETURN (d)-[]-()
ORDER BY expireDate
this one is working perfectly and is also ordering outputs, but its not searching in Slot und Substance.
2)
MATCH (s:Slot), (d:Drug) WHERE s.number = ({0}) return (d)-[]-(s)
MATCH (sub:Substances), (d:Drug)
WHERE toLower(sub.substanceName) CONTAINS toLower({0})
RETURN (sub)-[]-(d)
How is it possible to combine all this queries to one and in the end output the ordered to expire date Drugs with its relations to Slot and Substance?
Output in the end should look something like that.
d.tradingName - d.expire - sub.substanceName - s.number