# Mashlib databrowser + HL7 FHIR

**URL:** <https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118>\
**Category:** Solid data browser\
**Created:** [February 4, 2023, 1:46pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118 "2023-02-04T13:46:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mornemaritz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/mornemaritz/32/3701_2.png) [@mornemaritz](https://forum.solidproject.org/u/mornemaritz)\
**Post date:** [February 4, 2023, 1:46pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/1 "2023-02-04T13:46:24Z")

</div>

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:

- Clone [CommunitySolidServer/Recipes: Example configurations for the Community Solid Server (github.com)](https://github.com/CommunitySolidServer/Recipes)
- cd mashlib
- npm ci --production
- npx community-solid-server -c config-mashlib.json -f /pod-folder
- navigate to [http://localhost:3000](http://localhost:3000)
- Click on Logn in (top right corner)
- authenticate with the locally running instance of solid server and consent for the client to do authorized requests on my behalf
- Retrieve a Patient FHIR resources from a FHIR server  
curl --location --request GET ‘[http://fhirserver.hl7fundamentals.org/fhir/Patient/3](http://fhirserver.hl7fundamentals.org/fhir/Patient/3)’ --header ‘Accept: application/fhir+turtle’
- save the response as file called patient.ttl
- in the mashlib browser navigate to Your Storage
- drag & drop the patient.ttl file onto the big green “+” sign
- click in the patient.ttl thing
- expected result: patient resource content is displayed
- actual result: Outline.expand: Unable to fetch [http://localhost:3000/mornemaritz/patient.ttl](http://localhost:3000/mornemaritz/patient.ttl): Failed to load [http://localhost:3000/mornemaritz/patient.ttl](http://localhost:3000/mornemaritz/patient.ttl) Fetcher: Error trying to parse [http://localhost:3000/mornemaritz/patient.ttl](http://localhost:3000/mornemaritz/patient.ttl) as Notation3:  
SyntaxError: Line 9 of [http://localhost:3000/mornemaritz/patient.ttl](http://localhost:3000/mornemaritz/patient.ttl): Bad syntax: EOF found in middle of path syntax  
at: “” status: 200  
 ![PatientTtlUpload](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/e/ec038941a02da990593704c6cfbe70ad03f9e473.jpeg)  
 ![PatientTtlView](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/7/78b9f194cf3d6c2f582de397fb55daab7b7ff5ea.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [February 4, 2023, 4:10pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/2 "2023-02-04T16:10:54Z")

</div>

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

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

```auto
@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:

```auto
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>" ;

```

---

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [February 4, 2023, 4:12pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/3 "2023-02-04T16:12:18Z")

</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

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [February 5, 2023, 6:44am UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/4 "2023-02-05T06:44:12Z")

</div>

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

```plaintext
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.

---

<div class="post-metadata">

**Author:** ![bourgeoa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/bourgeoa/32/291_2.png) [@bourgeoa](https://forum.solidproject.org/u/bourgeoa)\
**Post date:** [February 5, 2023, 8:13am UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/5 "2023-02-05T08:13:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [February 5, 2023, 10:50am UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/6 "2023-02-05T10:50:44Z")

</div>

@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](https://www.w3.org/TR/turtle/#grammar-production-PN_LOCAL)); and N3.js seems to parse it fine as [http://hl7.org/fhir/Patient.birthDate](http://hl7.org/fhir/Patient.birthDate).

---

<div class="post-metadata">

**Author:** ![bourgeoa](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/bourgeoa/32/291_2.png) [@bourgeoa](https://forum.solidproject.org/u/bourgeoa)\
**Post date:** [February 5, 2023, 11:47am UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/7 "2023-02-05T11:47:02Z")

</div>

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

Then you could open an issue with [rdflib](https://github.com/linkeddata/rdflib.js)

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [February 5, 2023, 11:26pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/9 "2023-02-05T23:26:40Z")

</div>

Opened issue ([turtle parsing not correctly handling `.` in suffix · Issue #601 · linkeddata/rdflib.js · GitHub](https://github.com/linkeddata/rdflib.js/issues/601))

_Above post is deleted as I made incorrect statements about the internals of rdflib_

---

<div class="post-metadata">

**Author:** ![mornemaritz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/mornemaritz/32/3701_2.png) [@mornemaritz](https://forum.solidproject.org/u/mornemaritz)\
**Post date:** [March 22, 2023, 6:35pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/10 "2023-03-22T18:35:16Z")

</div>

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

```auto
@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](http://solidcommunity.net).

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

---

<div class="post-metadata">

**Author:** ![mornemaritz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/mornemaritz/32/3701_2.png) [@mornemaritz](https://forum.solidproject.org/u/mornemaritz)\
**Post date:** [March 22, 2023, 6:39pm UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/11 "2023-03-22T18:39:04Z")

</div>

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](http://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. 🙂

Kind Regards,  
Morné

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [March 25, 2023, 3:10am UTC](https://forum.solidproject.org/t/mashlib-databrowser-hl7-fhir/6118/12 "2023-03-25T03:10:08Z")

</div>

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

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

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

```
