Generate Thing in Dataset with @inrupt/solid-client


I am currently building an application for saving health-data entries (one entry is the data of one day). I am using the FHIR Observation vocabulary for an entry, and I create those entries with the help of @inrupt/solid-client. While creating this, a few questions came up, and I would be really happy to get some help here :slight_smile:

1. How should the data be structured?
I could create a folder (container) called “health-data” and then just create a Dataset for every daily entry. And one entry is a Thing that contains e.g. the body temperature of the day.

Or should all data (entries of one day) be written inside one .ttl file?

2. How do I create “a Thing in a Thing”?
So currently I create a Thing like that:

  const periodEntry = buildThing(
    createThing({ url: '' }),
    .addUrl(RDF.type, FHIR.Observation)
    .addStringNoLocale(FHIR.value, '38.5Cel')
    .addStringNoLocale(FHIR.value, date)

I define the type of the Thing as Observation but the value should actually be not of the string type but of another type called Quantity. How can I define this “thing in a thing”?

3. Is using the @inrupt/solid-client library enough?
I am aware that the data in solid pods is saved in turtle format. But I am not actively creating a turtle file that I would later send to the pod. I have seen a lot of repositories where people write queries or code in turtle notation that is then sent to the pod. Is using the @inrupt/solid-client library enough for read/write operations?

I am really happy for getting pushed in the right direction. I don’t need an exact answer to every question, I am also happy if you could help me with one point :slight_smile:

1. How should the data be structured?
That is really your choice. It depends on what you need to do with the data. If you need speed you can choose to put all entries in one file, if you don’t need all the data of an entry you could have summary fields on an entry in a list and put every actual entry in a new file

How do I create “a Thing in a Thing”?
I have a Golf game with a golf course that has golf holes.
So I create a GolfGame SolidDataset.
I create I Game Thing gameThing with a gameCourse property
I create a Thing a Course named courseThing which has an url
I add the Course Thing to the game Solid Dataset
setThing(GolfGame, courseThing)
and I add the url of the course thing to the game on the game thing
setUrl(game, gameCoursePropertyUrl, asUrl(courseThing))

I add the Game Thing to the game Solid Dataset
setThing(GolfGame, game)
and I save the GolfGame SolidDataset
saveSolidDataset(GolfGame, {fetch, session.fetch}
so you add the thing you want to add to a thing by adding it to the solid dataset and then referencing it by url

3. Is using the @inrupt/solid-client library enough?
A SolidDataset is a representation of a Turtle file. By creating and saving a SolidDataset at an Url @inrupt/solid-client creates a turtle file at that url for you.


Thank you for your answer!

Do you maybe have some example code for that? I am not sure where you get the property url from.

The resulting turtle file should look somewhat like that:

@prefix fhir: <> .

<#Observation01> a fhir:Observation;

fhir:Observation.status [ 
    fhir:value "final"

fhir:Obervation.effectiveDateTime [ 
    fhir:value "<dateTime>" 

Here, the effectiveDateTime and status have a nested property (which is the “thing in a thing” right?). How do I achieve that with @inrupt/solid-client?

That “Thing within a Thing” is technically a Thing represented by a “blank node” rather than a URL - and solid-client doesn’t support blank nodes.

That said, you can achieve something similar by creating a regular Thing, e.g. like this:

const effectiveDateTimeThing = buildThing()
  .addDatetime("", new Date("<dateTime>"))

const statusThing = buildThing()
  .addStringNoLocale("", "final")

const observationThing = buildThing({ name: "Observation01" })
  .addUrl("", "")
  .addUrl("", statusThing)
  .addUrl("", effectiveDateTimeThing)

If you then add those three Things to the same SolidDataset, you should get what you’re looking for.