Create new vocabulary + Authorization

Hi guys,

My project is to build a solid server and then build a client app (with Node.js) to interact with that server. My server will store data with FHIR (a health data standard).

I reused the Community Solid Server and configured it for the server, but when I tried to build a client app, I had some questions:

  1. FHIR data:
  • The HL7 company provides a FHIR vocabulary, but I don’t know how to import and use it to create data, like some rdf-common-vocabularies.
  • Are there any npm packages/projects that can help convert FHIR Json ↔ FHIR turtle (or just Json ↔ turtle)? I need it because when other client apps interact with my server, they usually use the JSON format, but Solid server must store RDF data.
  1. I have seen many solid client apps, but in these apps, users have to enter a webID to give access to their data to client apps. However, I want users to just receive a notification and choose the option to accept/deny. Any suggestions?

Thank you so much, guys!

1 Like

As far as 1. goes, converting between JSON and Turtle is doable, though it’s more common to convert JSON-LD between turtle, using a library like this : GitHub - frogcat/ttl2jsonld: Turtle to JSON-LD converter for node.js and browser, no library dependencies. . There are also other tools published by SOLID community members. Also see here: Vocabularies overview · Solid to understand vocabularies better.

For 2. the SOLID spec is about explicit consent of data sharing to allow applications to interact with user data. For just notifications, the notifications specification defines some ways to use notifications with static client credentials on the Inrupt server and the Community Solid server^6.0.0.

2 Likes

Actually, according to Solid protocol, you can get JSON-LD representation of RDF documents directly.

// in browser
// authenticated fetch
import { fetch } from '@inrupt/solid-client-authn-browser'

// within async function
// fetch document
const response = await fetch(uri, {
  headers: { accept: 'application/ld+json' } // this is important
})
// get body in JSON format
const data = await response.json()

I tried it with both NSS and CSS and it works.

Depending on your needs, also check out LDO library. Especially useful if you build app that consumes RDF documents from Solid server. It allows you to read and write RDF data as TypeScript/JavaScript objects.

2 Likes

Thank you so much.
I read Vocabularies overview :Solid and i found that ArtifactGenerator can hepl but when i try it follow the document, it doesn’t work, just creating a js file with some name definition and no classes or properties like: const OBELISK = {
PREFIX: “obelisk”,
NAMESPACE: _NAMESPACE,
PREFIX_AND_NAMESPACE: { “obelisk”: “http://w3id.org/obelisk/” },
NS: _NS,
Have you ever try it and dit it work?

Thank you so much.
I read Vocabularies overview :Solid and i found that ArtifactGenerator can hepl but when i try it follow the document, it doesn’t work, just creating a js file with some name definition and no classes or properties like: const OBELISK = {
PREFIX: “obelisk”,
NAMESPACE: _NAMESPACE,
PREFIX_AND_NAMESPACE: { “obelisk”: “http://w3id.org/obelisk/” },
NS: _NS,
Have you ever try it and dit it work?

I tried that once, and apparently succeeded, but i remember setting it up was a pain. Are your source files in proper RDF+XML or Turtle or similar format? (i didn’t find a way to get that from FHIR)
I’m guessing the vocabulary may also need to be in a single file. Hard to say.

edit: @Vincent found that file. Very cool

Hopefully, folks from Inrupt may be able to help you more here.

Or, for other solution, maybe @Vincent, who maintains rdf-namespaces would be able to share some of his magic. Or you can have a look into the repo of the project.

Anyways, this is a great question, and i’m hoping to find better solutions for custom vocabularies, too. Currently, i setup the terms i need manually.

Honestly, all it does is create convenience variables like:

// foaf.js
export const knows = 'http://xmlns.com/foaf/0.1/knows';

You can then use it like:

import { foaf } from "rdf-namespaces";

console.log(foaf.knows); // "http://xmlns.com/foaf/0.1/knows"

I don’t know of the specific use case here, but just using the URLs of the vocabulary directly as plain strings is probably fine too.

But in case it’s helpful, I added the FHIR vocabulary, so if you install rdf-namespaces 1.11.0 or higher, you can now do

import { fhir } from "rdf-namespaces";

console.log(fhir.Medication); // "http://hl7.org/fhir/Medication"
1 Like

"You can download the FHIR ontology from https://www.hl7.org/fhir/downloads.html. However, it includes many ontologies, and my database is quite simple. Therefore, I think I can try to set it up manually, like you suggested. But if I do that, although it can help my users create and modify their data, I cannot specify which terms or resources the client apps use when they send their data, even if it’s FHIR data. Thank you again for your help

Thank you so much for your help! I will try it

Using fhir from rdf-namespaces solves the same problem as my manual method, only better. So please kindly ignore my solution in favor of rdf-namespaces. :slightly_smiling_face:

If your needs go beyond exporting terms from the vocabulary, this won’t help much, unfortunately. If that’s the case, sorry for misunderstanding.

It should be possible through an extra app that handles the requests. I could imagine that following works:

  1. create a server-side application
  2. give this application control access to the users pod(s)
  3. create a UI where other users can send access requests to this application
  4. somehow notify the user (not sure how exactly would be nice, but eg sending an email)
  5. when the user accepts, the application grants the requested permissions

I think all of this would also work in a client-side app, but not sure how you would handle the notifications (step 4) in this case.

I’ll try.
Thank you a lot

My team is trying to handle that
Pls give me any idea if you have
Thank you a lot

For step 4, if you wanted to associate some contact information with a user’s pod, I’d just use something like a Twilio API to send requests, and then consume those responses and have the server-side application determine what to do depending on the response to a text message, but there are definitely other solutions

thank you so much