|
|
@ -18,18 +18,20 @@ import { |
|
|
|
import type { ObservationShape, PatientShape } from "./patientExampleData"; |
|
|
|
import type { ObservationShape, PatientShape } from "./patientExampleData"; |
|
|
|
import { |
|
|
|
import { |
|
|
|
patientData, |
|
|
|
patientData, |
|
|
|
patientContext, |
|
|
|
|
|
|
|
tinyPatientData, |
|
|
|
tinyPatientData, |
|
|
|
tinyArrayPatientData, |
|
|
|
tinyArrayPatientData, |
|
|
|
patientDataWithBlankNodes, |
|
|
|
patientDataWithBlankNodes, |
|
|
|
tinyPatientDataWithBlankNodes, |
|
|
|
tinyPatientDataWithBlankNodes, |
|
|
|
tinyPatientDataWithLanguageTags, |
|
|
|
tinyPatientDataWithLanguageTags, |
|
|
|
|
|
|
|
patientUnnestedContext, |
|
|
|
|
|
|
|
patientNestedContext, |
|
|
|
} from "./patientExampleData"; |
|
|
|
} from "./patientExampleData"; |
|
|
|
import { namedNode, quad, literal, defaultGraph } from "@rdfjs/data-model"; |
|
|
|
import { namedNode, quad, literal, defaultGraph } from "@rdfjs/data-model"; |
|
|
|
import type { Dataset, NamedNode } from "@rdfjs/types"; |
|
|
|
import type { Dataset, NamedNode } from "@rdfjs/types"; |
|
|
|
import type { ContextDefinition } from "jsonld"; |
|
|
|
import type { ContextDefinition } from "jsonld"; |
|
|
|
|
|
|
|
import type { LdoJsonldContext } from "../src/LdoJsonldContext"; |
|
|
|
|
|
|
|
|
|
|
|
describe("jsonldDatasetProxy", () => { |
|
|
|
const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => { |
|
|
|
async function getLoadedDataset(): Promise< |
|
|
|
async function getLoadedDataset(): Promise< |
|
|
|
[Dataset, ObservationShape, JsonldDatasetProxyBuilder] |
|
|
|
[Dataset, ObservationShape, JsonldDatasetProxyBuilder] |
|
|
|
> { |
|
|
|
> { |
|
|
@ -412,18 +414,20 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
describe("write", () => { |
|
|
|
describe("write", () => { |
|
|
|
it("sets a primitive value that doesn't exist yet", async () => { |
|
|
|
it("sets a primitive value that doesn't exist yet", async () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
|
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
observation.notes = "Cool Notes"; |
|
|
|
observation.notes = "Cool Notes"; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/notes> "Cool Notes" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/notes> "Cool Notes" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("sets primitive number and boolean values", async () => { |
|
|
|
it("sets primitive number and boolean values", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.age = 35; |
|
|
|
patient.age = 35; |
|
|
|
patient.isHappy = true; |
|
|
|
patient.isHappy = true; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/age> "35"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://example.com/Patient1> <http://hl7.org/fhir/isHappy> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/age> "35"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://example.com/Patient1> <http://hl7.org/fhir/isHappy> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -437,16 +441,21 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
|
|
|
|
|
|
|
|
it("replaces a primitive value that currently exists", async () => { |
|
|
|
it("replaces a primitive value that currently exists", async () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
dataset.add( |
|
|
|
dataset.addAll([ |
|
|
|
|
|
|
|
quad( |
|
|
|
|
|
|
|
namedNode("http://example.com/Observation1"), |
|
|
|
|
|
|
|
namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), |
|
|
|
|
|
|
|
namedNode("http://hl7.org/fhir/Observation"), |
|
|
|
|
|
|
|
), |
|
|
|
quad( |
|
|
|
quad( |
|
|
|
namedNode("http://example.com/Observation1"), |
|
|
|
namedNode("http://example.com/Observation1"), |
|
|
|
namedNode("http://hl7.org/fhir/notes"), |
|
|
|
namedNode("http://hl7.org/fhir/notes"), |
|
|
|
literal("Cool Notes"), |
|
|
|
literal("Cool Notes"), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
]); |
|
|
|
observation.notes = "Lame Notes"; |
|
|
|
observation.notes = "Lame Notes"; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/notes> "Lame Notes" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/notes> "Lame Notes" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -454,11 +463,13 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const patient: PatientShape = { |
|
|
|
const patient: PatientShape = { |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
birthdate: "2001-01-01", |
|
|
|
birthdate: "2001-01-01", |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
observation.subject = patient; |
|
|
|
observation.subject = patient; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/birthdate> "2001-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/birthdate> "2001-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -477,13 +488,14 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
observation.subject = undefined; |
|
|
|
observation.subject = undefined; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Creates a blank node if the id is blank during set", async () => { |
|
|
|
it("Creates a blank node if the id is blank during set", async () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
observation.subject = { name: ["Joe"] }; |
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
|
|
|
|
observation.subject = { type: { "@id": "Patient" }, name: ["Joe"] }; |
|
|
|
expect(observation.subject?.["@id"]).toBeUndefined(); |
|
|
|
expect(observation.subject?.["@id"]).toBeUndefined(); |
|
|
|
expect(observation.subject.name).toEqual(["Joe"]); |
|
|
|
expect(observation.subject.name).toEqual(["Joe"]); |
|
|
|
expect( |
|
|
|
expect( |
|
|
@ -500,12 +512,14 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const patient: PatientShape = { |
|
|
|
const patient: PatientShape = { |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
birthdate: "2001-01-01", |
|
|
|
birthdate: "2001-01-01", |
|
|
|
name: ["Jon", "Bon", "Jovi"], |
|
|
|
name: ["Jon", "Bon", "Jovi"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
observation.subject = patient; |
|
|
|
observation.subject = patient; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/birthdate> "2001-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Jon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Jovi" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/birthdate> "2001-01-01"^^<http://www.w3.org/2001/XMLSchema#date> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Jon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Jovi" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -513,41 +527,47 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const patient1: PatientShape = { |
|
|
|
const patient1: PatientShape = { |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["jon"], |
|
|
|
name: ["jon"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
const patient2: PatientShape = { |
|
|
|
const patient2: PatientShape = { |
|
|
|
"@id": "http://example.com/patient2", |
|
|
|
"@id": "http://example.com/patient2", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["jane"], |
|
|
|
name: ["jane"], |
|
|
|
roommate: [patient1], |
|
|
|
roommate: [patient1], |
|
|
|
}; |
|
|
|
}; |
|
|
|
patient1.roommate = [patient2]; |
|
|
|
patient1.roommate = [patient2]; |
|
|
|
|
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
observation.subject = patient1; |
|
|
|
observation.subject = patient1; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "jon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/patient2> .\n<http://example.com/patient2> <http://hl7.org/fhir/name> "jane" .\n<http://example.com/patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "jon" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/patient2> .\n<http://example.com/patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/patient2> <http://hl7.org/fhir/name> "jane" .\n<http://example.com/patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("adds a proxy object to the array", async () => { |
|
|
|
it("adds a proxy object to the array", async () => { |
|
|
|
const [, , builder] = await getTinyLoadedDataset(); |
|
|
|
const [, , builder] = await getTinyLoadedDataset(); |
|
|
|
const patient3 = builder.fromSubject( |
|
|
|
const patient3: PatientShape = builder.fromSubject( |
|
|
|
namedNode("http://example.com/Patient3"), |
|
|
|
namedNode("http://example.com/Patient3"), |
|
|
|
); |
|
|
|
); |
|
|
|
const patient1 = builder.fromSubject( |
|
|
|
patient3.type = { "@id": "Patient" }; |
|
|
|
|
|
|
|
const patient1: PatientShape = builder.fromSubject( |
|
|
|
namedNode("http://example.com/Patient1"), |
|
|
|
namedNode("http://example.com/Patient1"), |
|
|
|
); |
|
|
|
); |
|
|
|
patient3.roommate.push(patient1); |
|
|
|
patient3.roommate?.push(patient1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("sets a primitive on an array", async () => { |
|
|
|
it("sets a primitive on an array", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
(patient.name as string[])[0] = "jon"; |
|
|
|
(patient.name as string[])[0] = "jon"; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "jon" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "jon" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("sets a primitive on an array and overwrites one that already is there", async () => { |
|
|
|
it("sets a primitive on an array and overwrites one that already is there", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
dataset.add( |
|
|
|
dataset.add( |
|
|
|
quad( |
|
|
|
quad( |
|
|
|
namedNode("http://example.com/Patient1"), |
|
|
|
namedNode("http://example.com/Patient1"), |
|
|
@ -557,15 +577,16 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
); |
|
|
|
); |
|
|
|
(patient.name as string[])[0] = "not jon"; |
|
|
|
(patient.name as string[])[0] = "not jon"; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "not jon" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "not jon" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("sets an array", async () => { |
|
|
|
it("sets an array", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name = ["Joe", "Mama"]; |
|
|
|
patient.name = ["Joe", "Mama"]; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Joe" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Mama" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Joe" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Mama" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -573,19 +594,23 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Jackson"], |
|
|
|
name: ["Jackson"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
observation.subject = replacementPatient; |
|
|
|
observation.subject = replacementPatient; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/ReplacementPatient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n<http://example.com/ReplacementPatient> <http://hl7.org/fhir/name> "Jackson" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/ReplacementPatient> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n<http://example.com/ReplacementPatient> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/ReplacementPatient> <http://hl7.org/fhir/name> "Jackson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Does not overwrite the full object when a partial object is provided", async () => { |
|
|
|
it("Does not overwrite the full object when a partial object is provided", async () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
observation.subject = { "@id": "http://example.com/Patient2" }; |
|
|
|
observation.subject = { |
|
|
|
|
|
|
|
"@id": "http://example.com/Patient2", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
|
|
|
|
}; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient2> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient2> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -593,12 +618,13 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Jackson"], |
|
|
|
name: ["Jackson"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
const roommateArr = observation?.subject?.roommate as PatientShape[]; |
|
|
|
const roommateArr = observation?.subject?.roommate as PatientShape[]; |
|
|
|
roommateArr[0] = replacementPatient; |
|
|
|
roommateArr[0] = replacementPatient; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/ReplacementPatient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n<http://example.com/ReplacementPatient> <http://hl7.org/fhir/name> "Jackson" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/ReplacementPatient> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n<http://example.com/ReplacementPatient> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/ReplacementPatient> <http://hl7.org/fhir/name> "Jackson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -607,6 +633,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const roommateArr = observation.subject?.roommate as PatientShape[]; |
|
|
|
const roommateArr = observation.subject?.roommate as PatientShape[]; |
|
|
|
roommateArr[0] = { |
|
|
|
roommateArr[0] = { |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
"@id": "http://example.com/ReplacementPatient", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Jackson"], |
|
|
|
name: ["Jackson"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
expect(roommateArr.length).toBe(2); |
|
|
|
expect(roommateArr.length).toBe(2); |
|
|
@ -619,7 +646,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
patient["@id"] = "http://example.com/RenamedPatient"; |
|
|
|
patient["@id"] = "http://example.com/RenamedPatient"; |
|
|
|
expect(patient["@id"]).toBe("http://example.com/RenamedPatient"); |
|
|
|
expect(patient["@id"]).toBe("http://example.com/RenamedPatient"); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/RenamedPatient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/RenamedPatient> .\n<http://example.com/RenamedPatient> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/RenamedPatient> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/RenamedPatient> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/RenamedPatient> .\n<http://example.com/RenamedPatient> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/RenamedPatient> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/RenamedPatient> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -627,7 +654,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
delete observation.subject; |
|
|
|
delete observation.subject; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -635,7 +662,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
delete observation.subject?.name; |
|
|
|
delete observation.subject?.name; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -643,23 +670,23 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
delete observation.subject?.roommate?.[0]; |
|
|
|
delete observation.subject?.roommate?.[0]; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Removes all adjoining triples when garbage collection is indicated via the delete operator on an array with blank nodes", async () => { |
|
|
|
it("Removes all adjoining triples when garbage collection is indicated via the delete operator on an array with blank nodes", async () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDatasetWithBlankNodes(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDatasetWithBlankNodes(); |
|
|
|
|
|
|
|
const deletedBlankNode = |
|
|
|
|
|
|
|
observation.subject?.roommate?.[0][_getUnderlyingNode]; |
|
|
|
delete observation.subject?.roommate?.[0]; |
|
|
|
delete observation.subject?.roommate?.[0]; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.match(deletedBlankNode).size).toBe(0); |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> _:b26_Patient1 .\n_:b26_Patient1 <http://hl7.org/fhir/name> "Garrett" .\n', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Removes a literal in an array when using the delete operator", async () => { |
|
|
|
it("Removes a literal in an array when using the delete operator", async () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
delete observation.subject?.name?.[0]; |
|
|
|
delete observation.subject?.name?.[0]; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -670,7 +697,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
delete observation["@id"]; |
|
|
|
delete observation["@id"]; |
|
|
|
expect(observation).toEqual({ "@id": "http://example.com/Observation1" }); |
|
|
|
expect(observation).toEqual({ "@id": "http://example.com/Observation1" }); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -711,27 +738,29 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
const replacementPatient: PatientShape = { |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Mister Sneaky"], |
|
|
|
name: ["Mister Sneaky"], |
|
|
|
}; |
|
|
|
}; |
|
|
|
observation.subject = replacementPatient; |
|
|
|
observation.subject = replacementPatient; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Mister Sneaky" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Mister Sneaky" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("handles Object.assign", async () => { |
|
|
|
it("handles Object.assign", async () => { |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
const [dataset, observation] = await getTinyLoadedDataset(); |
|
|
|
Object.assign(observation, { |
|
|
|
Object.assign(observation.subject!, { |
|
|
|
age: 35, |
|
|
|
age: 35, |
|
|
|
isHappy: true, |
|
|
|
isHappy: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Observation1> <http://hl7.org/fhir/age> "35"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://example.com/Observation1> <http://hl7.org/fhir/isHappy> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
'<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/roommate> <http://example.com/Patient2> .\n<http://example.com/Patient1> <http://hl7.org/fhir/age> "35"^^<http://www.w3.org/2001/XMLSchema#integer> .\n<http://example.com/Patient1> <http://hl7.org/fhir/isHappy> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .\n<http://example.com/Patient2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient2> <http://hl7.org/fhir/name> "Rob" .\n<http://example.com/Patient2> <http://hl7.org/fhir/roommate> <http://example.com/Patient1> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Adds elements to the array even if they were modified by the datastore", async () => { |
|
|
|
it("Adds elements to the array even if they were modified by the datastore", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
dataset.add( |
|
|
|
dataset.add( |
|
|
|
quad( |
|
|
|
quad( |
|
|
@ -745,6 +774,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
|
|
|
|
|
|
|
|
it("Removes elements from the array even if they were modified by the datastore", async () => { |
|
|
|
it("Removes elements from the array even if they were modified by the datastore", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
dataset.delete( |
|
|
|
dataset.delete( |
|
|
|
quad( |
|
|
|
quad( |
|
|
@ -758,6 +788,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
|
|
|
|
|
|
|
|
it("Removes and adds from the array even if they were modified by the datastore", async () => { |
|
|
|
it("Removes and adds from the array even if they were modified by the datastore", async () => { |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
const [dataset, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
patient.name = ["Joe", "Blow"]; |
|
|
|
dataset.delete( |
|
|
|
dataset.delete( |
|
|
|
quad( |
|
|
|
quad( |
|
|
@ -793,7 +824,10 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
it("Prevents duplicates for Objects", async () => { |
|
|
|
it("Prevents duplicates for Objects", async () => { |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
|
const roommates = observation.subject?.roommate as PatientShape[]; |
|
|
|
const roommates = observation.subject?.roommate as PatientShape[]; |
|
|
|
roommates[0] = { "@id": "http://example.com/Patient3" }; |
|
|
|
roommates[0] = { |
|
|
|
|
|
|
|
"@id": "http://example.com/Patient3", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
|
|
|
|
}; |
|
|
|
expect(roommates.length).toBe(1); |
|
|
|
expect(roommates.length).toBe(1); |
|
|
|
expect(roommates[0].name?.[0]).toBe("Amy"); |
|
|
|
expect(roommates[0].name?.[0]).toBe("Amy"); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -824,12 +858,13 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
delete arr[5]; |
|
|
|
delete arr[5]; |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("Can set a triple object named node with just a string", async () => { |
|
|
|
it("Can set a triple object named node with just a string", async () => { |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
const [dataset, observation] = await getEmptyObservationDataset(); |
|
|
|
|
|
|
|
observation.type = { "@id": "Observation" }; |
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
observation.subject = "http://example.com/Patient1"; |
|
|
|
observation.subject = "http://example.com/Patient1"; |
|
|
@ -837,7 +872,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
"@id": "http://example.com/Patient1", |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
"<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n", |
|
|
|
"<http://example.com/Observation1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Observation> .\n<http://example.com/Observation1> <http://hl7.org/fhir/subject> <http://example.com/Patient1> .\n", |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -848,7 +883,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.copyWithin(0, 2, 3); |
|
|
|
arr.copyWithin(0, 2, 3); |
|
|
|
expect(arr).toEqual(["Ferguson", "Bobby"]); |
|
|
|
expect(arr).toEqual(["Ferguson", "Bobby"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -858,7 +893,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.copyWithin(0, 2); |
|
|
|
arr.copyWithin(0, 2); |
|
|
|
expect(arr).toEqual(["Ferguson", "Bobby"]); |
|
|
|
expect(arr).toEqual(["Ferguson", "Bobby"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -870,7 +905,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
expect(() => arr.copyWithin(0, undefined, 2)).not.toThrowError(); |
|
|
|
expect(() => arr.copyWithin(0, undefined, 2)).not.toThrowError(); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -880,7 +915,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.fill("Beepy", 2, 5); |
|
|
|
arr.fill("Beepy", 2, 5); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Beepy"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Beepy"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -890,7 +925,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
expect(arr.pop()).toBe("Ferguson"); |
|
|
|
expect(arr.pop()).toBe("Ferguson"); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -906,7 +941,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.push("Beepy"); |
|
|
|
arr.push("Beepy"); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson", "Beepy"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Bobby", "Ferguson", "Beepy"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -915,7 +950,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
patient.name?.reverse(); |
|
|
|
patient.name?.reverse(); |
|
|
|
expect(patient.name).toEqual(["Ferguson", "Bobby", "Garrett"]); |
|
|
|
expect(patient.name).toEqual(["Ferguson", "Bobby", "Garrett"]); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -925,7 +960,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
expect(arr.shift()).toEqual("Garrett"); |
|
|
|
expect(arr.shift()).toEqual("Garrett"); |
|
|
|
expect(arr).toEqual(["Bobby", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Bobby", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -942,7 +977,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
expect(patient.name).toEqual(["Bobby", "Garrett", "Ferguson"]); |
|
|
|
expect(patient.name).toEqual(["Bobby", "Garrett", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -974,7 +1009,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.splice(1, 0, "Beepy"); |
|
|
|
arr.splice(1, 0, "Beepy"); |
|
|
|
expect(arr).toEqual(["Garrett", "Beepy", "Bobby", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Beepy", "Bobby", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -1008,7 +1043,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.splice(1, 1); |
|
|
|
arr.splice(1, 1); |
|
|
|
expect(arr).toEqual(["Garrett", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Garrett", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -1018,7 +1053,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
arr.unshift("Beepy"); |
|
|
|
arr.unshift("Beepy"); |
|
|
|
expect(arr).toEqual(["Beepy", "Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(arr).toEqual(["Beepy", "Garrett", "Bobby", "Ferguson"]); |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
expect(dataset.toString()).toEqual( |
|
|
|
'<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
'<http://example.com/Patient1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Garrett" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Bobby" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Ferguson" .\n<http://example.com/Patient1> <http://hl7.org/fhir/name> "Beepy" .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1132,6 +1167,8 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
|
|
|
|
|
|
|
|
it("errors if an object is added without the correct parameters", async () => { |
|
|
|
it("errors if an object is added without the correct parameters", async () => { |
|
|
|
expect(() => |
|
|
|
expect(() => |
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
patients.push({ |
|
|
|
patients.push({ |
|
|
|
"@id": "http://example.com/Patient4", |
|
|
|
"@id": "http://example.com/Patient4", |
|
|
|
name: ["Dippy"], |
|
|
|
name: ["Dippy"], |
|
|
@ -1241,7 +1278,11 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
|
|
|
|
|
|
|
|
it("cannot write to a collection that matches the null, predicate, null pattern", () => { |
|
|
|
it("cannot write to a collection that matches the null, predicate, null pattern", () => { |
|
|
|
expect( |
|
|
|
expect( |
|
|
|
() => (patients[1] = { "@id": "http://example.com/Patient4" }), |
|
|
|
() => |
|
|
|
|
|
|
|
(patients[1] = { |
|
|
|
|
|
|
|
"@id": "http://example.com/Patient4", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
|
|
|
|
}), |
|
|
|
).toThrow( |
|
|
|
).toThrow( |
|
|
|
"A collection that does not specify a match for both a subject or predicate cannot be modified directly.", |
|
|
|
"A collection that does not specify a match for both a subject or predicate cannot be modified directly.", |
|
|
|
); |
|
|
|
); |
|
|
@ -1267,11 +1308,13 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
it("initializes a patient using the fromJSON method", async () => { |
|
|
|
it("initializes a patient using the fromJSON method", async () => { |
|
|
|
const [, , builder] = await getEmptyPatientDataset(); |
|
|
|
const [, , builder] = await getEmptyPatientDataset(); |
|
|
|
const patient = builder.fromJson<PatientShape>({ |
|
|
|
const patient = builder.fromJson<PatientShape>({ |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Jack", "Horner"], |
|
|
|
name: ["Jack", "Horner"], |
|
|
|
birthdate: "1725/11/03", |
|
|
|
birthdate: "1725/11/03", |
|
|
|
age: 298, |
|
|
|
age: 298, |
|
|
|
roommate: [ |
|
|
|
roommate: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Ethical", "Bug"], |
|
|
|
name: ["Ethical", "Bug"], |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
@ -1288,11 +1331,13 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const [, , builder] = await getEmptyPatientDataset(); |
|
|
|
const [, , builder] = await getEmptyPatientDataset(); |
|
|
|
const patient = builder.fromJson<PatientShape>({ |
|
|
|
const patient = builder.fromJson<PatientShape>({ |
|
|
|
"@id": "http://example.com/Patient13", |
|
|
|
"@id": "http://example.com/Patient13", |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Jack", "Horner"], |
|
|
|
name: ["Jack", "Horner"], |
|
|
|
birthdate: "1725/11/03", |
|
|
|
birthdate: "1725/11/03", |
|
|
|
age: 298, |
|
|
|
age: 298, |
|
|
|
roommate: [ |
|
|
|
roommate: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
type: { "@id": "Patient" }, |
|
|
|
name: ["Ethical", "Bug"], |
|
|
|
name: ["Ethical", "Bug"], |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
@ -1314,9 +1359,10 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const patient4 = builder |
|
|
|
const patient4 = builder |
|
|
|
.write(namedNode("http://example.com/Patient4Doc")) |
|
|
|
.write(namedNode("http://example.com/Patient4Doc")) |
|
|
|
.fromSubject<PatientShape>(namedNode("https://example.com/Patient4")); |
|
|
|
.fromSubject<PatientShape>(namedNode("https://example.com/Patient4")); |
|
|
|
|
|
|
|
patient4.type = { "@id": "Patient" }; |
|
|
|
patient4.name = ["Jackson"]; |
|
|
|
patient4.name = ["Jackson"]; |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
expect(dataset.toString()).toBe( |
|
|
|
'<https://example.com/Patient4> <http://hl7.org/fhir/name> "Jackson" <http://example.com/Patient4Doc> .\n', |
|
|
|
'<https://example.com/Patient4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://hl7.org/fhir/Patient> <http://example.com/Patient4Doc> .\n<https://example.com/Patient4> <http://hl7.org/fhir/name> "Jackson" <http://example.com/Patient4Doc> .\n', |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1399,6 +1445,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const doc3 = namedNode("http://example.com/Doc3"); |
|
|
|
const doc3 = namedNode("http://example.com/Doc3"); |
|
|
|
|
|
|
|
|
|
|
|
const [, patient] = await getEmptyPatientDataset(); |
|
|
|
const [, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name?.push("default"); |
|
|
|
patient.name?.push("default"); |
|
|
|
const end1 = write(doc1).using(patient); |
|
|
|
const end1 = write(doc1).using(patient); |
|
|
|
patient.name?.push("1"); |
|
|
|
patient.name?.push("1"); |
|
|
@ -1426,6 +1473,7 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
const doc1 = namedNode("http://example.com/Doc1"); |
|
|
|
const doc1 = namedNode("http://example.com/Doc1"); |
|
|
|
|
|
|
|
|
|
|
|
const [, patient] = await getEmptyPatientDataset(); |
|
|
|
const [, patient] = await getEmptyPatientDataset(); |
|
|
|
|
|
|
|
patient.type = { "@id": "Patient" }; |
|
|
|
patient.name?.push("Default"); |
|
|
|
patient.name?.push("Default"); |
|
|
|
const [patientOnDoc1] = write(doc1).usingCopy(patient); |
|
|
|
const [patientOnDoc1] = write(doc1).usingCopy(patient); |
|
|
|
patientOnDoc1.name?.push("Doc1"); |
|
|
|
patientOnDoc1.name?.push("Doc1"); |
|
|
@ -1676,4 +1724,14 @@ describe("jsonldDatasetProxy", () => { |
|
|
|
expect(enSet.size).toBe(0); |
|
|
|
expect(enSet.size).toBe(0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( |
|
|
|
|
|
|
|
"jsonldDatasetProxy - unnested context", |
|
|
|
|
|
|
|
testJsonldDatasetProxy(patientUnnestedContext), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe( |
|
|
|
|
|
|
|
"jsonldDatasetProxy - nested context", |
|
|
|
|
|
|
|
testJsonldDatasetProxy(patientNestedContext), |
|
|
|
|
|
|
|
); |
|
|
|