Mashlib databrowser + HL7 FHIR

Hi, solid n00b here. I’m busy trying to proof a concept of integration between FHIR server and a SOLID pod. Where I’m stuck at the moment is directly uploading the response from a Patient query submitted to a FHIR server as a Thing into a SOLID POD on locally hosted SOLID server

Here is what I’ve done:

  1. This file oploads fine to a blazegraph server as a turtle file. Are there different turtle standards?
  2. Is there a turlte parsing tool that would provide more detailed feedback so I can debug the issue?
  3. Is there a more up to date way of doing low-code exploration of SOLID?

Any pointers would be greatly appreciated.

1 Like

I’m not familiar with this issue, but to simplify debugging:

Here’s the same file: https://oaie.solidweb.org/public/patient.ttl
With the content:

@prefix fhir:  <http://hl7.org/fhir/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sct:   <http://snomed.info/id#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<http://fhirserver.hl7fundamentals.org/fhir/Patient/3/_history/32>
        a                         fhir:Patient ;
        fhir:DomainResource.text  [ fhir:Narrative.div     "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Patient L00_1_T04 giv <b>PATIENT L00_1_T04 FAM </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>L00_1_T04</td></tr><tr><td>Date of birth</td><td><span>23 July 1968</span></td></tr></tbody></table></div>" ;
                                    fhir:Narrative.status  [ fhir:value  "generated" ]
                                  ] ;
        fhir:Patient.birthDate    [ fhir:value  "1965-12-17"^^xsd:date ] ;
        fhir:Patient.gender       [ fhir:value  "male" ] ;
        fhir:Patient.identifier   [ fhir:Identifier.system  [ fhir:value  "http://fhirintermediate.org/patient_id"^^xsd:anyURI ] ;
                                    fhir:Identifier.value   [ fhir:value  "L00_1_T04" ] ;
                                    fhir:index              0
                                  ] ;
        fhir:Patient.name         [ fhir:HumanName.family  [ fhir:value  "Anderson" ] ;
                                    fhir:HumanName.given   [ fhir:index  0 ;
                                                             fhir:value  "Quenter"
                                                           ] ;
                                    fhir:index             0
                                  ] ;
        fhir:Resource.id          [ fhir:value  "3" ] ;
        fhir:Resource.meta        [ fhir:Meta.lastUpdated  [ fhir:value  "2022-11-23T18:08:00.151+00:00"^^xsd:dateTime ] ;
                                    fhir:Meta.source       [ fhir:value  "#iaDt1XQwiMuIa046"^^xsd:anyURI ] ;
                                    fhir:Meta.versionId    [ fhir:value  "32" ]
                                  ] ;
        fhir:nodeRole             fhir:treeRoot .

According to the error description this line is (the first) with an error:

fhir:DomainResource.text  [ fhir:Narrative.div     "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">Patient L00_1_T04 giv <b>PATIENT L00_1_T04 FAM </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Identifier</td><td>L00_1_T04</td></tr><tr><td>Date of birth</td><td><span>23 July 1968</span></td></tr></tbody></table></div>" ;

@mornemaritz If you have time to debug, simply try to remove entries from the turtle file and simplify strings until it’s valid. This way you will know which line, symbols or chars cause the problem

The file itself seems to be valid turtle (this can be validated by running the following javascript code snippet)

import { Parser } from "n3";

const parser = new Parser({ format: 'text/turtle' });

async function main() {
  const text = await (await fetch("http://fhirserver.hl7fundamentals.org/fhir/Patient/3?_format=ttl")).text()
  console.log('file content', text)
  const quads = parser.parse(text)
  console.log(quads)
}

main();

and noting the the CSS server is parsing turtle using n3 under the hood.

I suspect the problem is that you or mashlib may be applying some incorrect escaping of the quotes or backslashes inside the literal on line 9 prior to saving.

From what I understand the issue is with the dots in minimized predicates.
Turtle is a flavor of RDF. Among other things it uses , ; . to parse the text

It look like you parsed a json file to make it turtle.
Do you made your ontology ?

fhir:Patient.name is not valid ttl
<http://hl7.org/fhir/Patient.name> is valid

You must add more prefixes like : @prefix patient: <http://hl7.org/fhir/Patient.>.
with this patient:name is valid turtle.

This may be wrong (the prefix may not be valid ?) :

You must add more prefixes like : @prefix patient: <http://hl7.org/fhir/Patient.>.
with this patient:name is valid turtle.

@bourgeoa Whilst fhir:Patient.name is fairly malicious as a term I think it is valid turtle (if I am interpreting correctly it is permitted in the suffix according to RDF 1.1 Turtle); and N3.js seems to parse it fine as http://hl7.org/fhir/Patient.birthDate.

Looking at the spec. You may be right
I shall edit my response

Then you could open an issue with rdflib

Opened issue (turtle parsing not correctly handling `.` in suffix · Issue #601 · linkeddata/rdflib.js · GitHub)

Above post is deleted as I made incorrect statements about the internals of rdflib

1 Like

Hi @A_A, thank you very much for taking the time to respond so quickly. Apologies for the delay in my response. Because this is a side-project, I have very little time to spend on it.

I did try a while ago to trim the document down to the bare minimum which ended up being the only the prefix statements and the first line.
Something like this

@prefix fhir:  <http://hl7.org/fhir/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sct:   <http://snomed.info/id#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<http://fhirserver.hl7fundamentals.org/fhir/Patient/3/_history/32>  a fhir:Patient ;

That unfortunately did not succeed either. I do not recall the error and I did want to retry this approach but I somehow managed to completely destroy the pod I was hosting locally.

I’ve abandoned mashlib and I’m now attempting to make rest calls directly from insomnia (rest client UI) to a pod that I’ve registered on solidcommunity.net.

So far I’ve managed to authenticate. next step is to retrieve and update datasets,

hi @jeswr, thank you for taking the time to respond to my query.

I’ve abandoned mashlib and I’m now attempting to make rest calls directly from insomnia (rest client UI) to a pod that I’ve registered on solidcommunity.net.

I’ve taken note of your posted js code for when I need to parse turtle with the N3 parser though. I’m sure it will come in handy. :slight_smile:

Kind Regards,
Morné

This minified file is not valid turtle; you should terminate the triple with a .; i.e.

@prefix fhir:  <http://hl7.org/fhir/> .

<http://fhirserver.hl7fundamentals.org/fhir/Patient/3/_history/32>  a fhir:Patient .
1 Like