diff --git a/Dockerfile b/Dockerfile index 8a3e4c9..6eec29a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-slim as buildstage +FROM node:20-slim as buildstage WORKDIR /usr/src/app diff --git a/README.md b/README.md index 928e6bb..ccda32e 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,8 @@ limitations under the License. ## Authors and history - Guillermo Mejías ([@gmej](https://github.com/gmej)) -- Alejo Esteban ([@10alejopain](https://github.com/)) +- Alejo Esteban ([@10alejospain](https://github.com/10alejospain)) +- Alejandro Alonso ([@aalonsolopez](https://github.com/aalonsolopez)) --- diff --git a/kubernetes/002_lens-selector-example-deployment.yaml b/kubernetes/002_lens-selector-example-deployment.yaml index 60eb41d..3fbaeac 100644 --- a/kubernetes/002_lens-selector-example-deployment.yaml +++ b/kubernetes/002_lens-selector-example-deployment.yaml @@ -28,14 +28,16 @@ spec: app: lens-selector-mvp2 spec: containers: - - name: lens-selector-mvp2 - image: gravitate-registry.cr.de-fra.ionos.com/lens-selector-mvp2:latest - imagePullPolicy: Always - env: - - name: ENVIRONMENT - value: "prod" - ports: - - containerPort: 3000 - protocol: TCP + - name: lens-selector-mvp2 + image: gravitate-registry.cr.de-fra.ionos.com/lens-selector-mvp2:dev + imagePullPolicy: Always + env: + - name: ENVIRONMENT + value: "prod" + - name: BASE_URL + value: "http://gravitate-health.lst.tfo.upm.es" + ports: + - containerPort: 3000 + protocol: TCP restartPolicy: Always status: {} diff --git a/openapi.yaml b/openapi.yaml index 0d6879f..9a40d1e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -5,12 +5,12 @@ info: description: Gravitate Health Focusing Service. Focuses a Focused ePI. contact: {} servers: - - url: https://fosps.gravitatehealth.eu +- url: https://fosps.gravitatehealth.eu paths: /lenses: get: tags: - - Lenses + - Lenses description: Returns all lenses IDs. responses: "200": @@ -26,10 +26,10 @@ paths: type: string example: ["lense1", "lense2", "lense3"] - /lenses/{id}: + /lenses/{name}: get: tags: - - Lenses + - Lenses description: Returns the lense itself. responses: "200": @@ -39,9 +39,83 @@ paths: schema: type: object properties: - metadata: + resourceType: + type: string + example: "Library" + id: + type: string + example: "588" + meta: + type: object + extension: + type: array + items: + type: object + url: + type: string + example: "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib" + identifier: + type: array + items: + type: object + version: + type: string + example: "0.0.1" + name: + type: string + example: "pregnancy-lens" + title: + type: string + example: "pregnancy-lens" + status: + type: string + example: "draft" + experimental: + type: boolean + example: true + type: type: object - lense: + date: + type: string + example: "2024-06-12T12:23:10.005Z" + publisher: type: string - example: "console.log('Hello World!')" + example: "Gravitate Health Project - UPM Team" + contact: + type: array + items: + type: object + description: + type: string + example: "Lens that highlight or collapses pregnancy related information" + jurisdiction: + type: array + items: + type: object + purpose: + type: string + example: "Collapse or highlight pregnancy related information on a preprocessed ePI." + usage: + type: string + example: "You can import this lens directly to your FHIR Server which suports Library Resource type." + copiright: + type: string + example: "© 2024 Gravitate Health" + parameter: + type: array + items: + type: object + content: + type: array + items: + type: object + + parameters: + - name: name + in: path + required: true + schema: + type: string + description: The name of the lense to return. + diff --git a/package.json b/package.json index f482a3d..3d54e98 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "ts-node-dev ./src/index.ts", - "build": "if [ -d \"$PWD/build\" ]; then rm -r \"$PWD/build\"; fi && tsc --incremental && cp -r ./src/lenses ./build", + "build": "if [ -d \"$PWD/build\" ]; then rm -r \"$PWD/build\"; fi && tsc --incremental", "start": "node build/index.js" }, "repository": { diff --git a/src/controllers/lensesController.ts b/src/controllers/lensesController.ts index 916078c..bb2931c 100644 --- a/src/controllers/lensesController.ts +++ b/src/controllers/lensesController.ts @@ -1,52 +1,40 @@ import { Response, Request } from "express"; import { Logger } from "../utils/Logger"; -import fs, { readFile, readdir } from "fs" -const readLensesDir = async () => { - try { - let path = `${process.cwd()}/build/lenses/` - console.log(`Looking for lenses in path: ${path}`); - let discoveredLenses = await fs.promises.readdir(path); - console.log(`Discovered the following files in dir: ${discoveredLenses || "None"}`); - return discoveredLenses - } catch (err) { - console.error('Error occurred while reading directory!', err); - } -} - -const readLensFile = async (path: string) => { - try { - return await fs.promises.readFile(path, 'utf-8'); - } catch (err) { - console.error('Error occurred while reading file!', err); - } -} +const fhirIpsURL = process.env.BASE_URL + "/ips/api/fhir" const retrieveLensesNames = async () => { try { - let lensesNames = await readLensesDir() - console.log(`Found the following lenses: ${lensesNames || "None"}`); - return await lensesNames + let response = [] + let lensPath = "/Library" + let lenses = await fetch(`${fhirIpsURL}${lensPath}`) + + let lensesBundle = await lenses.json() + if (lensesBundle.total === 0) { + return [] + } + for (let entry of lensesBundle.entry) { + response.push(entry.resource.name) + } + return response } catch (error) { console.log(error); return null } } -const retrieveLense = async (lenseId: string) => { - let lensFilename: string = lenseId + ".js" - let lensPath = `${process.cwd()}/build/lenses/${lensFilename}` - - let lensesNames = await retrieveLensesNames() - console.log(`Looking for lens: ${lensFilename}`); - if (lensesNames?.includes(lensFilename)) { - try { - return await readLensFile(lensPath) - } catch (error) { - console.log(error); +const retrieveLense = async (lenseId: string): Promise => { + let lensPath = `/Library?name:exact=${lenseId}` + try { + let lenses = await fetch(`${fhirIpsURL}${lensPath}`) + let lensesBundle = await lenses.json() + if (lensesBundle.total === 0) { + return `No lens found with ${lenseId} name` } - } else { - return null + return lensesBundle.entry[0].resource + } catch (error) { + console.log(error); + return null } } @@ -60,12 +48,15 @@ export const getLens = async (req: Request, res: Response) => { } try { let lens = await retrieveLense(reqlens) - let lensObject = { - metadata: {}, - lens: lens + + if (lens === null) { + console.log(`Lens ${reqlens} not found.`); + res.status(404).send({ + message: `Lens ${reqlens} not found.` + }) } - console.log(`Sending lens: ${JSON.stringify(lensObject)}`); - res.status(200).send(lensObject) + console.log(`Sending lens: ${JSON.stringify(lens)}`); + res.status(200).send(lens) return } catch (error) { console.log(error); diff --git a/src/lenses/lens-selector-mvp2_allergyintollerance.js b/src/lenses/lens-selector-mvp2_allergyintollerance.js deleted file mode 100644 index 76f6c06..0000000 --- a/src/lenses/lens-selector-mvp2_allergyintollerance.js +++ /dev/null @@ -1,136 +0,0 @@ -let pvData = pv; -let htmlData = html; - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0"; -}; - -let enhance = async () => { - // Proves that IPS exists - if (ips == "" || ips == null) { - throw new Error("Failed to load IPS: the LEE is getting a empty IPS"); - } - - // Instantiates the array of condition codes - let arrayOfConditionCodes = []; - - // Iterates through the IPS entry searching for conditions - ips.entry.forEach((element) => { - if (element.resource.resourceType == "AllergyIntolerance") { - if (element.resource.code != undefined) { - element.resource.code.coding.forEach((coding) => { - arrayOfConditionCodes.push({ - code: coding.code, - system: coding.system, - }); - }); - } - } - }); - - // If there are no conditions, return the ePI as it is - if (arrayOfConditionCodes.length == 0) { - return htmlData; - } - - // ePI traslation from terminology codes to their human redable translations in the sections - let compositions = 0; - let categories = []; - epi.entry.forEach((entry) => { - if (entry.resource.resourceType == "Composition") { - compositions++; - //Iterated through the Condition element searching for conditions - entry.resource.extension.forEach((element) => { - - // Check if the position of the extension[1] is correct - if (element.extension[1].url == "concept") { - // Search through the different terminologies that may be avaible to check in the condition - if (element.extension[1].valueCodeableReference.concept != undefined) { - element.extension[1].valueCodeableReference.concept.coding.forEach( - (coding) => { - console.log("Extension: " + element.extension[0].valueString + ":" + coding.code + " - " + coding.system) - // Check if the code is in the list of categories to search - if (equals(arrayOfConditionCodes, { code: coding.code, system: coding.system })) { - // Check if the category is already in the list of categories - categories.push(element.extension[0].valueString); - } - } - ); - } - } - }); - } - }); - - if (compositions == 0) { - throw new Error('Bad ePI: no category "Composition" found'); - } - - if (categories.length == 0) { - return htmlData; - } - - //Focus (adds highlight class) the html applying every category found - return await annotateHTMLsection(categories, "highlight"); -}; - -let annotationProcess = (listOfCategories, enhanceTag, document, response) => { - listOfCategories.forEach((check) => { - if (response.includes(check)) { - let elements = document.getElementsByClassName(check); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.add(enhanceTag); - } - if (document.getElementsByTagName("head").length > 0) { - document.getElementsByTagName("head")[0].remove(); - } - if (document.getElementsByTagName("body").length > 0) { - response = document.getElementsByTagName("body")[0].innerHTML; - console.log("Response: " + response); - } else { - console.log("Response: " + document.documentElement.innerHTML); - response = document.documentElement.innerHTML; - } - } - }); - - if (response == null || response == "") { - throw new Error( - "Annotation proccess failed: Returned empty or null response" - ); - //return htmlData - } else { - console.log("Response: " + response); - return response; - } -} - -let annotateHTMLsection = async (listOfCategories, enhanceTag) => { - let response = htmlData; - let document; - - if (typeof window === "undefined") { - let jsdom = await import("jsdom"); - let { JSDOM } = jsdom; - let dom = new JSDOM(htmlData); - document = dom.window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } else { - document = window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } -}; - -let equals = (array, object) => { - return array.some((element) => { - return (element.code === object.code) && (element.system === object.system); - }); -} - -return { - enhance: enhance, - getSpecification: getSpecification, -}; diff --git a/src/lenses/lens-selector-mvp2_conditions.js b/src/lenses/lens-selector-mvp2_conditions.js deleted file mode 100644 index f5b92dd..0000000 --- a/src/lenses/lens-selector-mvp2_conditions.js +++ /dev/null @@ -1,136 +0,0 @@ -let pvData = pv; -let htmlData = html; - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0"; -}; - -let enhance = async () => { - // Proves that IPS exists - if (ips == "" || ips == null) { - throw new Error("Failed to load IPS: the LEE is getting a empty IPS"); - } - - // Instantiates the array of condition codes - let arrayOfConditionCodes = []; - - // Iterates through the IPS entry searching for conditions - ips.entry.forEach((element) => { - if (element.resource.resourceType == "Condition") { - if (element.resource.code != undefined) { - element.resource.code.coding.forEach((coding) => { - arrayOfConditionCodes.push({ - code: coding.code, - system: coding.system, - }); - }); - } - } - }); - - // If there are no conditions, return the ePI as it is - if (arrayOfConditionCodes.length == 0) { - return htmlData; - } - - // ePI traslation from terminology codes to their human redable translations in the sections - let compositions = 0; - let categories = []; - epi.entry.forEach((entry) => { - if (entry.resource.resourceType == "Composition") { - compositions++; - //Iterated through the Condition element searching for conditions - entry.resource.extension.forEach((element) => { - - // Check if the position of the extension[1] is correct - if (element.extension[1].url == "concept") { - // Search through the different terminologies that may be avaible to check in the condition - if (element.extension[1].valueCodeableReference.concept != undefined) { - element.extension[1].valueCodeableReference.concept.coding.forEach( - (coding) => { - console.log("Extension: " + element.extension[0].valueString + ":" + coding.code + " - " + coding.system) - // Check if the code is in the list of categories to search - if (equals(arrayOfConditionCodes, { code: coding.code, system: coding.system })) { - // Check if the category is already in the list of categories - categories.push(element.extension[0].valueString); - } - } - ); - } - } - }); - } - }); - - if (compositions == 0) { - throw new Error('Bad ePI: no category "Composition" found'); - } - - if (categories.length == 0) { - return htmlData; - } - - //Focus (adds highlight class) the html applying every category found - return await annotateHTMLsection(categories, "highlight"); -}; - -let annotationProcess = (listOfCategories, enhanceTag, document, response) => { - listOfCategories.forEach((check) => { - if (response.includes(check)) { - let elements = document.getElementsByClassName(check); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.add(enhanceTag); - } - if (document.getElementsByTagName("head").length > 0) { - document.getElementsByTagName("head")[0].remove(); - } - if (document.getElementsByTagName("body").length > 0) { - response = document.getElementsByTagName("body")[0].innerHTML; - console.log("Response: " + response); - } else { - console.log("Response: " + document.documentElement.innerHTML); - response = document.documentElement.innerHTML; - } - } - }); - - if (response == null || response == "") { - throw new Error( - "Annotation proccess failed: Returned empty or null response" - ); - //return htmlData - } else { - console.log("Response: " + response); - return response; - } -} - -let annotateHTMLsection = async (listOfCategories, enhanceTag) => { - let response = htmlData; - let document; - - if (typeof window === "undefined") { - let jsdom = await import("jsdom"); - let { JSDOM } = jsdom; - let dom = new JSDOM(htmlData); - document = dom.window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } else { - document = window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } -}; - -let equals = (array, object) => { - return array.some((element) => { - return (element.code === object.code) && (element.system === object.system); - }); -} - -return { - enhance: enhance, - getSpecification: getSpecification, -}; diff --git a/src/lenses/lens-selector-mvp2_diabetes.js b/src/lenses/lens-selector-mvp2_diabetes.js deleted file mode 100644 index 181a66d..0000000 --- a/src/lenses/lens-selector-mvp2_diabetes.js +++ /dev/null @@ -1,88 +0,0 @@ - -let pvData = pv -let htmlData = html - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0" -} - -let annotationProcess = (listOfCategories, enhanceTag, document, response) => { - listOfCategories.forEach((check) => { - if (response.includes(check)) { - let elements = document.getElementsByClassName(check); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.add(enhanceTag); - } - if (document.getElementsByTagName("head").length > 0) { - document.getElementsByTagName("head")[0].remove(); - } - if (document.getElementsByTagName("body").length > 0) { - response = document.getElementsByTagName("body")[0].innerHTML; - console.log("Response: " + response); - } else { - console.log("Response: " + document.documentElement.innerHTML); - response = document.documentElement.innerHTML; - } - } - }); - - if (response == null || response == "") { - throw new Error( - "Annotation proccess failed: Returned empty or null response" - ); - //return htmlData - } else { - console.log("Response: " + response); - return response; - } -} - -let annotateHTMLsection = async (listOfCategories, enhanceTag) => { - let response = htmlData; - let document; - - if (typeof window === "undefined") { - let jsdom = await import("jsdom"); - let { JSDOM } = jsdom; - let dom = new JSDOM(htmlData); - document = dom.window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } else { - document = window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } -}; - -let enhance = async () => { - let listOfCategoriesToSearch = ["contra-indication-diabetes-mellitus"] - - //IPS interaction not implemented yet - - //Get condition categories for the ePI and filters by the condition we want to check - let categories = [] - epi.entry.forEach(element => { - if (element.resource.extension != undefined) { - element.resource.extension.forEach(category => { - if (listOfCategoriesToSearch.includes(category.extension[0].valueString)) { - categories.push(category.extension[0].valueString) - } - }); - } - }); - - //Focus (adds highlight class) the html applying every category found - - if (categories.length == 0) { - // throw new Error("No categories found", categories); - return htmlData - } - //Focus (adds highlight class) the html applying every category found - return await annotateHTMLsection(categories, "highlight"); -} -return { - enhance: enhance, - getSpecification: getSpecification -} \ No newline at end of file diff --git a/src/lenses/lens-selector-mvp2_interaction.js b/src/lenses/lens-selector-mvp2_interaction.js deleted file mode 100644 index 0cce3d5..0000000 --- a/src/lenses/lens-selector-mvp2_interaction.js +++ /dev/null @@ -1,141 +0,0 @@ -let pvData = pv; -let htmlData = html; - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0"; -}; - -let enhance = async () => { - // Proves that IPS exists - if (ips == "" || ips == null) { - throw new Error("Failed to load IPS: the LEE is getting a empty IPS"); - } - - // Instantiates the array of condition codes - let arrayOfIngredientCodes = []; - - // Iterates through the IPS entry searching for conditions - ips.entry.forEach((element) => { - if (element.resource.resourceType == "Medication") { - if (element.resource.ingredient != undefined) { - element.resource.ingredient.forEach((ingredient) => { - if (ingredient.itemCodeableConcept != undefined) { - ingredient.itemCodeableConcept.coding.forEach((coding) => { - console.log("Ingredient: " + coding.code + " - " + coding.system) - arrayOfIngredientCodes.push({ - code: coding.code, - system: "", - }); - }); - } - }) - } - } - }); - - // If there are no conditions, return the ePI as it is - if (arrayOfIngredientCodes.length == 0) { - return htmlData; - } - - // ePI traslation from terminology codes to their human redable translations in the sections - let compositions = 0; - let categories = []; - epi.entry.forEach((entry) => { - if (entry.resource.resourceType == "Composition") { - compositions++; - //Iterated through the Condition element searching for conditions - entry.resource.extension.forEach((element) => { - - // Check if the position of the extension[1] is correct - if (element.extension[1].url == "concept") { - // Search through the different terminologies that may be avaible to check in the condition - if (element.extension[1].valueCodeableReference.concept != undefined) { - element.extension[1].valueCodeableReference.concept.coding.forEach( - (coding) => { - console.log("Extension: " + element.extension[0].valueString + ":" + coding.code + " - " + coding.system) - // Check if the code is in the list of categories to search - if (equals(arrayOfIngredientCodes, { code: coding.code, system: "" })) { - // Check if the category is already in the list of categories - categories.push(element.extension[0].valueString); - } - } - ); - } - } - }); - } - }); - - if (compositions == 0) { - throw new Error('Bad ePI: no category "Composition" found'); - } - - if (categories.length == 0) { - return htmlData; - } - - //Focus (adds highlight class) the html applying every category found - return await annotateHTMLsection(categories, "highlight"); -}; - -let annotationProcess = (listOfCategories, enhanceTag, document, response) => { - listOfCategories.forEach((check) => { - if (response.includes(check)) { - let elements = document.getElementsByClassName(check); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.add(enhanceTag); - } - if (document.getElementsByTagName("head").length > 0) { - document.getElementsByTagName("head")[0].remove(); - } - if (document.getElementsByTagName("body").length > 0) { - response = document.getElementsByTagName("body")[0].innerHTML; - console.log("Response: " + response); - } else { - console.log("Response: " + document.documentElement.innerHTML); - response = document.documentElement.innerHTML; - } - } - }); - - if (response == null || response == "") { - throw new Error( - "Annotation proccess failed: Returned empty or null response" - ); - //return htmlData - } else { - console.log("Response: " + response); - return response; - } -} - -let annotateHTMLsection = async (listOfCategories, enhanceTag) => { - let response = htmlData; - let document; - - if (typeof window === "undefined") { - let jsdom = await import("jsdom"); - let { JSDOM } = jsdom; - let dom = new JSDOM(htmlData); - document = dom.window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } else { - document = window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } -}; - -let equals = (array, object) => { - return array.some((element) => { - return (element.code === object.code) && (element.system === object.system); - }); -} - -return { - enhance: enhance, - getSpecification: getSpecification, -}; diff --git a/src/lenses/lens-selector-mvp2_pregnancy.js b/src/lenses/lens-selector-mvp2_pregnancy.js deleted file mode 100644 index 8b99e85..0000000 --- a/src/lenses/lens-selector-mvp2_pregnancy.js +++ /dev/null @@ -1,136 +0,0 @@ -let pvData = pv; -let htmlData = html; - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0"; -}; - -let annotationProcess = (listOfCategories, enhanceTag, document, response) => { - listOfCategories.forEach((check) => { - if (response.includes(check)) { - let elements = document.getElementsByClassName(check); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.add(enhanceTag); - } - if (document.getElementsByTagName("head").length > 0) { - document.getElementsByTagName("head")[0].remove(); - } - if (document.getElementsByTagName("body").length > 0) { - response = document.getElementsByTagName("body")[0].innerHTML; - console.log("Response: " + response); - } else { - console.log("Response: " + document.documentElement.innerHTML); - response = document.documentElement.innerHTML; - } - } - }); - - if (response == null || response == "") { - throw new Error( - "Annotation proccess failed: Returned empty or null response" - ); - //return htmlData - } else { - console.log("Response: " + response); - return response; - } -} - -let annotateHTMLsection = async (listOfCategories, enhanceTag) => { - let response = htmlData; - let document; - - if (typeof window === "undefined") { - let jsdom = await import("jsdom"); - let { JSDOM } = jsdom; - let dom = new JSDOM(htmlData); - document = dom.window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } else { - document = window.document; - return annotationProcess(listOfCategories, enhanceTag, document, response); - } -}; - -let getIPSAge = (birthDate) => { - let today = new Date(); - let birthDateParsed = new Date(birthDate); - - let ageMiliseconds = today - birthDateParsed; - let age = Math.floor(ageMiliseconds / 31536000000); - - return age; -} - -let enhance = async () => { - // pregnancyCategory breastfeedingCategory - // SNOMED SNOMED - let listOfCategoriesToSearch = ["W78", "77386006", "69840006"]; //"contra-indication-pregancy"] - - // Get IPS gender and check if is female - let gender; - - let enhanceTag; - - if (ips == "" || ips == null) { - throw new Error("Failed to load IPS: the LEE is getting a empty IPS"); - } - ips.entry.forEach((element) => { - if (element.resource.resourceType == "Patient") { - gender = element.resource.gender; - if (gender != "female" || getIPSAge(element.resource.birthDate) >= 75) { - enhanceTag = "collapsed"; - } else { - enhanceTag = "highlight"; - } - } - }); - - // ePI traslation from terminology codes to their human redable translations in the sections - let compositions = 0; - let categories = []; - epi.entry.forEach((entry) => { - if (entry.resource.resourceType == "Composition") { - compositions++; - //Iterated through the Condition element searching for conditions - entry.resource.extension.forEach((element) => { - - // Check if the position of the extension[1] is correct - if (element.extension[1].url == "concept") { - // Search through the different terminologies that may be avaible to check in the condition - if (element.extension[1].valueCodeableReference.concept != undefined) { - element.extension[1].valueCodeableReference.concept.coding.forEach( - (coding) => { - console.log("Extension: " + element.extension[0].valueString + ":" + coding.code) - // Check if the code is in the list of categories to search - if (listOfCategoriesToSearch.includes(coding.code)) { - // Check if the category is already in the list of categories - categories.push(element.extension[0].valueString); - } - } - ); - } - } - }); - } - }); - - if (compositions == 0) { - throw new Error('Bad ePI: no category "Composition" found'); - } - - if (categories.length == 0) { - // throw new Error("No categories found", categories); - return htmlData; - } - //Focus (adds highlight class) the html applying every category found - return await annotateHTMLsection(categories, enhanceTag); -}; - -return { - enhance: enhance, - getSpecification: getSpecification, -}; diff --git a/src/lenses/lens-selector-mvp2_proxy-pregnancy.js b/src/lenses/lens-selector-mvp2_proxy-pregnancy.js deleted file mode 100644 index 23fed55..0000000 --- a/src/lenses/lens-selector-mvp2_proxy-pregnancy.js +++ /dev/null @@ -1,42 +0,0 @@ -let pvData = pv; -let htmlData = html; - -let epiData = epi; -let ipsData = ips; - -let getSpecification = () => { - return "1.0.0"; -}; - -let enhance = async () => { - - const host = process.env.PROXY_LENS_ENV == "dev" ? "https://gravitate-health.lst.tfo.upm.es" : "https://gravitate-health.lst.tfo.upm.es" //"https://fosps.gravitatehealth.eu/"; - const url = `${host}/external/pregnancy` - const options = { - method: "POST", - headers: { - "Content-Type": "application/json", - "Accept": "application/json" - }, - body: JSON.stringify({ - pvData: pv, - htmlData: html, - epiData: JSON.stringify(epi), - ipsData: JSON.stringify(ips) - }) - }; - - let response = await fetch(url, options) - .then((response) => { - return response.json(); - }).catch((error) => { - throw new Error(error); - }); - - return response.htmlString; -}; - -return { - enhance: enhance, - getSpecification: getSpecification, -}; \ No newline at end of file diff --git a/target/fhir-lens-HIV.json b/target/fhir-lens-HIV.json deleted file mode 100644 index dfd507c..0000000 --- a/target/fhir-lens-HIV.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-HIV", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-HIV" - }], - "version" : "0.1.0", - "name" : "fhir-lens-HIV", - "title" : "HIV Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "This lens is intended to be used by patients to identify relevant information about information related to HIV.", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "This lens is intended to be used by patients to identify relevant information about information related to HIV.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKHJlc3BvbnNlID09IG51bGwgfHwgcmVzcG9uc2UgPT0gIiIpI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BbXTsKICAgIGVwaS5lbnRyeS5mb3JFYWNoKChlbnRyeSkgPT4gewogICAgICAgIGlmIChlbnRyeS5yZXNvdXJjZS5yZXNvdXJjZVR5cGUgPT0gIkNvbXBvc2l0aW9uIikgewogICAgICAgICAgICBjb21wb3NpdGlvbnMrKzsKICAgICAgICAgICAgLy9JdGVyYXRlZCB0aHJvdWdoIHRoZSBDb25kaXRpb24gZWxlbWVudCBzZWFyY2hpbmcgZm9yIGNvbmRpdGlvbnMKICAgICAgICAgICAgZW50cnkucmVzb3VyY2UuZXh0ZW5zaW9uLmZvckVhY2goKGVsZW1lbnQpID0+IHsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIHBvc2l0aW9uIG9mIHRoZSBleHRlbnNpb25bMV0gaXMgY29ycmVjdAogICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuZXh0ZW5zaW9uWzFdLnVybCA9PSAiY29uY2VwdCIpIHsKICAgICAgICAgICAgICAgICAgICAvLyBTZWFyY2ggdGhyb3VnaCB0aGUgZGlmZmVyZW50IHRlcm1pbm9sb2dpZXMgdGhhdCBtYXkgYmUgYXZhaWJsZSB0byBjaGVjayBpbiB0aGUgY29uZGl0aW9uCiAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuZXh0ZW5zaW9uWzFdLnZhbHVlQ29kZWFibGVSZWZlcmVuY2UuY29uY2VwdCAhPSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5leHRlbnNpb25bMV0udmFsdWVDb2RlYWJsZVJlZmVyZW5jZS5jb25jZXB0LmNvZGluZy5mb3JFYWNoKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvZGluZykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJFeHRlbnNpb246ICIgKyBlbGVtZW50LmV4dGVuc2lvblswXS52YWx1ZVN0cmluZyArICI6IiArIGNvZGluZy5jb2RlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBjb2RlIGlzIGluIHRoZSBsaXN0IG9mIGNhdGVnb3JpZXMgdG8gc2VhcmNoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3RPZkNhdGVnb3JpZXNUb1NlYXJjaC5pbmNsdWRlcyhjb2RpbmcuY29kZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIGNhdGVnb3J5IGlzIGFscmVhZHkgaW4gdGhlIGxpc3Qgb2YgY2F0ZWdvcmllcwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXRlZ29yaWVzLnB1c2goZWxlbWVudC5leHRlbnNpb25bMF0udmFsdWVTdHJpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgIH0KICAgIH0pOwoKICAgIGlmIChjb21wb3NpdGlvbnMgPT0gMCkgewogICAgICAgIHRocm93IG5ldyBFcnJvcignQmFkIGVQSTogbm8gY2F0ZWdvcnkgIkNvbXBvc2l0aW9uIiBmb3VuZCcpOwogICAgfQoKICAgIGlmIChjYXRlZ29yaWVzLmxlbmd0aCA9PSAwKSB7CiAgICAgICAgLy90aHJvdyBuZXcgRXJyb3IoIk5vIGNhdGVnb3JpZXMgZm91bmQiLCBjYXRlZ29yaWVzKTsKICAgICAgICByZXR1cm4gaHRtbERhdGE7CiAgICB9CiAgICAvL0ZvY3VzIChhZGRzIGhpZ2hsaWdodCBjbGFzcykgdGhlIGh0bWwgYXBwbHlpbmcgZXZlcnkgY2F0ZWdvcnkgZm91bmQKICAgIHJldHVybiBhd2FpdCBhbm5vdGF0ZUhUTUxzZWN0aW9uKGNhdGVnb3JpZXMsICJoaWdobGlnaHQiKTsKfTsKcmV0dXJuIHsKICAgIGVuaGFuY2U6IGVuaGFuY2UsCiAgICBnZXRTcGVjaWZpY2F0aW9uOiBnZXRTcGVjaWZpY2F0aW9uLAp9Ow==" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-allergy.json b/target/fhir-lens-allergy.json deleted file mode 100644 index df73da6..0000000 --- a/target/fhir-lens-allergy.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-allergy", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-allergy" - }], - "version" : "0.1.0", - "name" : "fhir-lens-allergy", - "title" : "Allergy Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "This lens is intended to be used by patients to identify relevant information about information related to allergies.", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "This lens is intended to be used by patients to identify relevant information about information related to allergies.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKHJlc3BvbnNlID09IG51bGwgfHwgcmVzcG9uc2UgPT0gIiIpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoCiAgICAgICAgICAgICJBbm5vdGF0aW9uIHByb2NjZXNzIGZhaWxlZDogUmV0dXJuZWQgZW1wdHkgb3IgbnVsbCByZXNwb25zZSIKICAgICAgICApOwogICAgICAgIC8vcmV0dXJuIGh0bWxEYXRhCiAgICB9IGVsc2UgewogICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICB9Cn0KCmxldCBhbm5vdGF0ZUhUTUxzZWN0aW9uID0gYXN5bmMgKGxpc3RPZkNhdGVnb3JpZXMsIGVuaGFuY2VUYWcpID0+IHsKICAgIGxldCByZXNwb25zZSA9IGh0bWxEYXRhOwogICAgbGV0IGRvY3VtZW50OwoKICAgIGlmICh0eXBlb2Ygd2luZG93ID09PSAidW5kZWZpbmVkIikgewogICAgICAgIGxldCBqc2RvbSA9IGF3YWl0IGltcG9ydCgianNkb20iKTsKICAgICAgICBsZXQgeyBKU0RPTSB9ID0ganNkb207CiAgICAgICAgbGV0IGRvbSA9IG5ldyBKU0RPTShodG1sRGF0YSk7CiAgICAgICAgZG9jdW1lbnQgPSBkb20ud2luZG93LmRvY3VtZW50OwogICAgICAgIH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c2xhdGlvbnMgaW4gdGhlIHNlY3Rpb25zCiAgICBsZXQgY29tcG9zaXRpb25zID0gMDsKICAgIGxldCBjYXRlZ29yaWVzID0gW107CiAgICBlcGkuZW50cnkuZm9yRWFjaCgoZW50cnkpID0+IHsKICAgICAgICBpZiAoZW50cnkucmVzb3VyY2UucmVzb3VyY2VUeXBlID09ICJDb21wb3NpdGlvbiIpIHsKICAgICAgICAgICAgY29tcG9zaXRpb25zKys7CiAgICAgICAgICAgIC8vSXRlcmF0ZWQgdGhyb3VnaCB0aGUgQ29uZGl0aW9uIGVsZW1lbnQgc2VhcmNoaW5nIGZvciBjb25kaXRpb25zCiAgICAgICAgICAgIGVudHJ5LnJlc291cmNlLmV4dGVuc2lvbi5mb3JFYWNoKChlbGVtZW50KSA9PiB7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBwb3NpdGlvbiBvZiB0aGUgZXh0ZW5zaW9uWzFdIGlzIGNvcnJlY3QKICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS51cmwgPT0gImNvbmNlcHQiKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gU2VhcmNoIHRocm91Z2ggdGhlIGRpZmZlcmVudCB0ZXJtaW5vbG9naWVzIHRoYXQgbWF5IGJlIGF2YWlibGUgdG8gY2hlY2sgaW4gdGhlIGNvbmRpdGlvbgogICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS52YWx1ZUNvZGVhYmxlUmVmZXJlbmNlLmNvbmNlcHQgIT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZXh0ZW5zaW9uWzFdLnZhbHVlQ29kZWFibGVSZWZlcmVuY2UuY29uY2VwdC5jb2RpbmcuZm9yRWFjaCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjb2RpbmcpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiRXh0ZW5zaW9uOiAiICsgZWxlbWVudC5leHRlbnNpb25bMF0udmFsdWVTdHJpbmcgKyAiOiIgKyBjb2RpbmcuY29kZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgY29kZSBpcyBpbiB0aGUgbGlzdCBvZiBjYXRlZ29yaWVzIHRvIHNlYXJjaAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaXN0T2ZDYXRlZ29yaWVzVG9TZWFyY2guaW5jbHVkZXMoY29kaW5nLmNvZGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBjYXRlZ29yeSBpcyBhbHJlYWR5IGluIHRoZSBsaXN0IG9mIGNhdGVnb3JpZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZWdvcmllcy5wdXNoKGVsZW1lbnQuZXh0ZW5zaW9uWzBdLnZhbHVlU3RyaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9KTsKCiAgICBpZiAoY29tcG9zaXRpb25zID09IDApIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0JhZCBlUEk6IG5vIGNhdGVnb3J5ICJDb21wb3NpdGlvbiIgZm91bmQnKTsKICAgIH0KCiAgICBpZiAoY2F0ZWdvcmllcy5sZW5ndGggPT0gMCkgewogICAgICAgIC8vIHRocm93IG5ldyBFcnJvcigiTm8gY2F0ZWdvcmllcyBmb3VuZCIsIGNhdGVnb3JpZXMpOwogICAgICAgIHJldHVybiBodG1sRGF0YTsKICAgIH0KICAgIC8vRm9jdXMgKGFkZHMgaGlnaGxpZ2h0IGNsYXNzKSB0aGUgaHRtbCBhcHBseWluZyBldmVyeSBjYXRlZ29yeSBmb3VuZAogICAgcmV0dXJuIGF3YWl0IGFubm90YXRlSFRNTHNlY3Rpb24oY2F0ZWdvcmllcywgImhpZ2hsaWdodCIpOwp9OwoKcmV0dXJuIHsKICAgIGVuaGFuY2U6IGVuaGFuY2UsCiAgICBnZXRTcGVjaWZpY2F0aW9uOiBnZXRTcGVjaWZpY2F0aW9uLAp9Owo=" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-diabetes.json b/target/fhir-lens-diabetes.json deleted file mode 100644 index dfc2055..0000000 --- a/target/fhir-lens-diabetes.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-diabetes", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-diabetes" - }], - "version" : "0.1.0", - "name" : "fhir-lens-diabetes", - "title" : "Diabetes Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "This lens is intended to be used by patients to identify relevant information about information related to diabetes.", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "This lens is intended to be used by patients to identify relevant information about information related to diabetes.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "CmxldCBwdkRhdGEgPSBwdgpsZXQgaHRtbERhdGEgPSBodG1sCgpsZXQgZXBpRGF0YSA9IGVwaTsKbGV0IGlwc0RhdGEgPSBpcHM7CgpsZXQgZ2V0U3BlY2lmaWNhdGlvbiA9ICgpID0+IHsKICAgIHJldHVybiAiMS4wLjAiCn0KCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKHJlc3BvbnNlID09IG51bGwgfHwgcmVzcG9uc2UgPT0gIiIpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoCiAgICAgICAgICAgICJBbm5vdGF0aW9uIHByb2NjZXNzIGZhaWxlZDogUmV0dXJuZWQgZW1wdHkgb3IgbnVsbCByZXNwb25zZSIKICAgICAgICApOwogICAgICAgIC8vcmV0dXJuIGh0bWxEYXRhCiAgICB9IGVsc2UgewogICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICB9Cn0KCmxldCBhbm5vdGF0ZUhUTUxzZWN0aW9uID0gYXN5bmMgKGxpc3RPZkNhdGVnb3JpZXMsIGVuaGFuY2VUYWcpID0+IHsKICAgIGxldCByZXNwb25zZSA9IGh0bWxEYXRhOwogICAgbGV0IGRvY3VtZW50OwoKICAgIGlmICh0eXBlb2Ygd2luZG93ID09PSAidW5kZWZpbmVkIikgewogICAgICAgIGxldCBqc2RvbSA9IGF3YWl0IGltcG9ydCgianNkb20iKTsKICAgICAgICBsZXQgeyBKU0RPTSB9ID0ganNkb207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RlZ29yaWVzLnB1c2goY2F0ZWdvcnkuZXh0ZW5zaW9uWzBdLnZhbHVlU3RyaW5nKQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9KTsKCiAgICAvL0ZvY3VzIChhZGRzIGhpZ2hsaWdodCBjbGFzcykgdGhlIGh0bWwgYXBwbHlpbmcgZXZlcnkgY2F0ZWdvcnkgZm91bmQKCiAgICBpZiAoY2F0ZWdvcmllcy5sZW5ndGggPT0gMCkgewogICAgICAgIC8vIHRocm93IG5ldyBFcnJvcigiTm8gY2F0ZWdvcmllcyBmb3VuZCIsIGNhdGVnb3JpZXMpOwogICAgICAgIHJldHVybiBodG1sRGF0YQogICAgfQogICAgLy9Gb2N1cyAoYWRkcyBoaWdobGlnaHQgY2xhc3MpIHRoZSBodG1sIGFwcGx5aW5nIGV2ZXJ5IGNhdGVnb3J5IGZvdW5kCiAgICByZXR1cm4gYXdhaXQgYW5ub3RhdGVIVE1Mc2VjdGlvbihjYXRlZ29yaWVzLCAiaGlnaGxpZ2h0Iik7Cn0KcmV0dXJuIHsKICAgIGVuaGFuY2U6IGVuaGFuY2UsCiAgICBnZXRTcGVjaWZpY2F0aW9uOiBnZXRTcGVjaWZpY2F0aW9uCn0=" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-interaction.json b/target/fhir-lens-interaction.json deleted file mode 100644 index 192f0b3..0000000 --- a/target/fhir-lens-interaction.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-interaction", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-interaction" - }], - "version" : "0.1.0", - "name" : "fhir-lens-interaction", - "title" : "Interaction Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "This lens is intended to be used by patients to identify relevant information about interaction between drugs in the leaflets.", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "This lens is intended to be used by patients to identify relevant information about interaction between drugs in the leaflets.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKHJlc3BvbnNlID09IG51bGwgfHwgcmVzcG9uc2UgPT0gIiIpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoCiAgICAgICAgICAgICJBbm5vdGF0aW9uIHByb2NjZXNzIGZhaWxlZDogUmV0dXJuZWQgZW1wdHkgb3IgbnVsbCByZXNwb25zZSIKICAgICAgICApOwogICAgICAgIC8vcmV0dXJ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RlciBhbmQgY2hlY2sgaWYgaXMgZmVtYWxlCiAgICBsZXQgZ2VuZGVyOwoKICAgIGlmIChpcHMgPT0gIiIgfHwgaXBzID09IG51bGwpIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkZhaWxlZCB0byBsb2FkIElQUzogdGhlIExFRSBpcyBnZXR0aW5nIGEgZW1wdHkgSVBTIik7CiAgICB9CiAgICBpcHMuZW50cnkuZm9yRWFjaCgoZWxlbWVudCkgPT4gewogICAgICAgIGlmIChlbGVtZW50LnJlc291cmNlLnJlc291cmNlVHlwZSA9PSAiUGF0aWVudCIpIHsKICAgICAgICAgICAgZ2VuZGVyID0gZWxlbWVudC5yZXNvdXJjZS5nZW5kZXI7CiAgICAgICAgICAgIGlmIChnZW5kZXIgIT0gImZlbWFsZSIpIHsKICAgICAgICAgICAgICAgIHJldHVybiBodG1sRGF0YTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0pOwoKICAgIC8vIGVQSSB0cmFzbGF0aW9uIGZyb20gdGVybWlub2xvZ3kgY29kZXMgdG8gdGhlaXIgaHVtYW4gcmVkYWJsZSB0cmFuc2xhdGlvbnMgaW4gdGhlIHNlY3Rpb25zCiAgICBsZXQgY29tcG9zaXRpb25zID0gMDsKICAgIGxldCBjYXRlZ29yaWVzID0gW107CiAgICBlcGkuZW50cnkuZm9yRWFjaCgoZW50cnkpID0+IHsKICAgICAgICBpZiAoZW50cnkucmVzb3VyY2UucmVzb3VyY2VUeXBlID09ICJDb21wb3NpdGlvbiIpIHsKICAgICAgICAgICAgY29tcG9zaXRpb25zKys7CiAgICAgICAgICAgIC8vSXRlcmF0ZWQgdGhyb3VnaCB0aGUgQ29uZGl0aW9uIGVsZW1lbnQgc2VhcmNoaW5nIGZvciBjb25kaXRpb25zCiAgICAgICAgICAgIGVudHJ5LnJlc291cmNlLmV4dGVuc2lvbi5mb3JFYWNoKChlbGVtZW50KSA9PiB7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBwb3NpdGlvbiBvZiB0aGUgZXh0ZW5zaW9uWzFdIGlzIGNvcnJlY3QKICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS51cmwgPT0gImNvbmNlcHQiKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gU2VhcmNoIHRocm91Z2ggdGhlIGRpZmZlcmVudCB0ZXJtaW5vbG9naWVzIHRoYXQgbWF5IGJlIGF2YWlibGUgdG8gY2hlY2sgaW4gdGhlIGNvbmRpdGlvbgogICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS52YWx1ZUNvZGVhYmxlUmVmZXJlbmNlLmNvbmNlcHQgIT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZXh0ZW5zaW9uWzFdLnZhbHVlQ29kZWFibGVSZWZlcmVuY2UuY29uY2VwdC5jb2RpbmcuZm9yRWFjaCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjb2RpbmcpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiRXh0ZW5zaW9uOiAiICsgZWxlbWVudC5leHRlbnNpb25bMF0udmFsdWVTdHJpbmcgKyAiOiIgKyBjb2RpbmcuY29kZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgY29kZSBpcyBpbiB0aGUgbGlzdCBvZiBjYXRlZ29yaWVzIHRvIHNlYXJjaAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaXN0T2ZDYXRlZ29yaWVzVG9TZWFyY2guaW5jbHVkZXMoY29kaW5nLmNvZGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBjYXRlZ29yeSBpcyBhbHJlYWR5IGluIHRoZSBsaXN0IG9mIGNhdGVnb3JpZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZWdvcmllcy5wdXNoKGVsZW1lbnQuZXh0ZW5zaW9uWzBdLnZhbHVlU3RyaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9KTsKCiAgICBpZiAoY29tcG9zaXRpb25zID09IDApIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0JhZCBlUEk6IG5vIGNhdGVnb3J5ICJDb21wb3NpdGlvbiIgZm91bmQnKTsKICAgIH0KCiAgICBpZiAoY2F0ZWdvcmllcy5sZW5ndGggPT0gMCkgewogICAgICAgIC8vIHRocm93IG5ldyBFcnJvcigiTm8gY2F0ZWdvcmllcyBmb3VuZCIsIGNhdGVnb3JpZXMpOwogICAgICAgIHJldHVybiBodG1sRGF0YTsKICAgIH0KICAgIC8vRm9jdXMgKGFkZHMgaGlnaGxpZ2h0IGNsYXNzKSB0aGUgaHRtbCBhcHBseWluZyBldmVyeSBjYXRlZ29yeSBmb3VuZAogICAgcmV0dXJuIGF3YWl0IGFubm90YXRlSFRNTHNlY3Rpb24oY2F0ZWdvcmllcywgImhpZ2hsaWdodCIpOwp9OwoKcmV0dXJuIHsKICAgIGVuaGFuY2U6IGVuaGFuY2UsCiAgICBnZXRTcGVjaWZpY2F0aW9uOiBnZXRTcGVjaWZpY2F0aW9uLAp9Ow==" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-intolerance.json b/target/fhir-lens-intolerance.json deleted file mode 100644 index c8a2575..0000000 --- a/target/fhir-lens-intolerance.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-intolerance", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-intolerance" - }], - "version" : "0.1.0", - "name" : "fhir-lens-intolerance", - "title" : "Intolerance Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "This is a lens that highlights information about intolerance in the ePIs. It is intended to be used by patients to identify relevant information about intolerance in the leaflets.", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "This lens is intended to be used by patients to identify relevant information about intolerance in the leaflets.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBhbm5vdGF0aW9uUHJvY2VzcyA9IChsaXN0T2ZDYXRlZ29yaWVzLCBlbmhhbmNlVGFnLCBkb2N1bWVudCwgcmVzcG9uc2UpID0+IHsKICAgIGxpc3RPZkNhdGVnb3JpZXMuZm9yRWFjaCgoY2hlY2spID0+IHsKICAgICAgICBpZiAocmVzcG9uc2UuaW5jbHVkZXMoY2hlY2spKSB7CiAgICAgICAgICAgIGxldCBlbGVtZW50cyA9IGRvY3VtZW50LmdldEVsZW1lbnRzQnlDbGFzc05hbWUoY2hlY2spOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGVsZW1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVtZW50c1tpXS5jbGFzc0xpc3QuYWRkKGVuaGFuY2VUYWcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0ucmVtb3ZlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJib2R5IikubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiYm9keSIpWzBdLmlubmVySFRNTDsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIHJlc3BvbnNlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCJSZXNwb25zZTogIiArIGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUwpOwogICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuaW5uZXJIVE1MOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfSk7C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bnQgc2VhcmNoaW5nIGZvciBjb25kaXRpb25zCiAgICAgICAgICAgIGVudHJ5LnJlc291cmNlLmV4dGVuc2lvbi5mb3JFYWNoKChlbGVtZW50KSA9PiB7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBwb3NpdGlvbiBvZiB0aGUgZXh0ZW5zaW9uWzFdIGlzIGNvcnJlY3QKICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS51cmwgPT0gImNvbmNlcHQiKSB7CiAgICAgICAgICAgICAgICAgICAgLy8gU2VhcmNoIHRocm91Z2ggdGhlIGRpZmZlcmVudCB0ZXJtaW5vbG9naWVzIHRoYXQgbWF5IGJlIGF2YWlibGUgdG8gY2hlY2sgaW4gdGhlIGNvbmRpdGlvbgogICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50LmV4dGVuc2lvblsxXS52YWx1ZUNvZGVhYmxlUmVmZXJlbmNlLmNvbmNlcHQgIT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZXh0ZW5zaW9uWzFdLnZhbHVlQ29kZWFibGVSZWZlcmVuY2UuY29uY2VwdC5jb2RpbmcuZm9yRWFjaCgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChjb2RpbmcpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygiRXh0ZW5zaW9uOiAiICsgZWxlbWVudC5leHRlbnNpb25bMF0udmFsdWVTdHJpbmcgKyAiOiIgKyBjb2RpbmcuY29kZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgY29kZSBpcyBpbiB0aGUgbGlzdCBvZiBjYXRlZ29yaWVzIHRvIHNlYXJjaAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaXN0T2ZDYXRlZ29yaWVzVG9TZWFyY2guaW5jbHVkZXMoY29kaW5nLmNvZGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIENoZWNrIGlmIHRoZSBjYXRlZ29yeSBpcyBhbHJlYWR5IGluIHRoZSBsaXN0IG9mIGNhdGVnb3JpZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2F0ZWdvcmllcy5wdXNoKGVsZW1lbnQuZXh0ZW5zaW9uWzBdLnZhbHVlU3RyaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICB9KTsKCiAgICBpZiAoY29tcG9zaXRpb25zID09IDApIHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0JhZCBlUEk6IG5vIGNhdGVnb3J5ICJDb21wb3NpdGlvbiIgZm91bmQnKTsKICAgIH0KCiAgICBpZiAoY2F0ZWdvcmllcy5sZW5ndGggPT0gMCkgewogICAgICAgIC8vIHRocm93IG5ldyBFcnJvcigiTm8gY2F0ZWdvcmllcyBmb3VuZCIsIGNhdGVnb3JpZXMpOwogICAgICAgIHJldHVybiBodG1sRGF0YTsKICAgIH0KICAgIC8vRm9jdXMgKGFkZHMgaGlnaGxpZ2h0IGNsYXNzKSB0aGUgaHRtbCBhcHBseWluZyBldmVyeSBjYXRlZ29yeSBmb3VuZAogICAgcmV0dXJuIGF3YWl0IGFubm90YXRlSFRNTHNlY3Rpb24oY2F0ZWdvcmllcywgImhpZ2hsaWdodCIpOwp9OwoKcmV0dXJuIHsKICAgIGVuaGFuY2U6IGVuaGFuY2UsCiAgICBnZXRTcGVjaWZpY2F0aW9uOiBnZXRTcGVjaWZpY2F0aW9uLAp9Owo=" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-pregnancy.json b/target/fhir-lens-pregnancy.json deleted file mode 100644 index 07eeebf..0000000 --- a/target/fhir-lens-pregnancy.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-pregnancy", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-pregnancy" - }], - "version" : "0.1.0", - "name" : "fhir-lens-pregnancy", - "title" : "Pregnancy Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "if a person is female and between 18 and 70 years, information about pregnancy is going to be highlighted. if a person is a man, the information is collapsed", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "The Pregnancy Lens is a lens that highlights information about pregnancy in the ePIs. It is intended to be used by patients to identify relevant information about pregnancy in the leaflets.", - "usage" : "Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoK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bnNlOiAiICsgcmVzcG9uc2UpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgY29uc29sZS5sb2coIlJlc3BvbnNlOiAiICsgZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50LmlubmVySFRNTCk7CiAgICAgICAgICAgICAgICByZXNwb25zZSA9IGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5pbm5lckhUTUw7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9KTsKCiAgICBpZiAocmVzcG9uc2UgPT0gbnVsbCB8fCByZXNwb25zZSA9PSAiIikgewogICAgICAgIHRocm93IG5ldyBFcnJvcigKICAgICAgICAgICAgIkFubm90YXRpb24gcHJvY2Nlc3MgZmFpbGVkOiBSZXR1cm5lZCBlbXB0eSBvciBudWxsIHJlc3BvbnNlIgogICAgICAgICk7CiAgICAgICAgLy9yZXR1cm4gaHRtbERhdGEKICAgIH0gZWxzZSB7CiAgICAgICAgY29uc29sZS5sb2coIlJlc3BvbnNlOiAiICsgcmVzcG9uc2UpOwogICAgICAgIHJldHVybiByZXNwb25zZTsKICAgIH0KfQoKbGV0IGFubm90YXRlSFRNTHNlY3Rpb24gPSBhc3luYyAobGlzdE9mQ2F0ZWdvcmllcywgZW5oYW5jZVRhZykgPT4gewogICAgbGV0IHJlc3BvbnNlID0gaHRtbERhdGE7CiAgICBsZXQgZG9jdW1lbnQ7CgogICAgaWYgKHR5cGVvZiB3aW5kb3cgPT09ICJ1bmRlZmluZWQiKSB7CiAgICAgICAgbGV0IGpzZG9tID0gYXdhaXQgaW1wb3J0KCJqc2RvbSIpOwogICAgICAgIGxldCB7IEpTRE9NIH0gPSBqc2RvbTsKICAgICAgICBsZXQgZG9tID0gbmV3IEpTRE9NKGh0bWxEYXRhKTsKICAgICAgICBkb2N1bWVudCA9IGRvbS53aW5kb3cuZG9jdW1lbnQ7CiAgICAgICAgcmV0dXJuIGFubm90YXRpb25Qcm9jZXNzKGxpc3RPZkNhdGVnb3JpZXMs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gICAgICB9CiAgICB9KTsKCiAgICAvLyBlUEkgdHJhc2xhdGlvbiBmcm9tIHRlcm1pbm9sb2d5IGNvZGVzIHRvIHRoZWlyIGh1bWFuIHJlZGFibGUgdHJhbnNsYXRpb25zIGluIHRoZSBzZWN0aW9ucwogICAgbGV0IGNvbXBvc2l0aW9ucyA9IDA7CiAgICBsZXQgY2F0ZWdvcmllcyA9IFtdOwogICAgZXBpLmVudHJ5LmZvckVhY2goKGVudHJ5KSA9PiB7CiAgICAgICAgaWYgKGVudHJ5LnJlc291cmNlLnJlc291cmNlVHlwZSA9PSAiQ29tcG9zaXRpb24iKSB7CiAgICAgICAgICAgIGNvbXBvc2l0aW9ucysrOwogICAgICAgICAgICAvL0l0ZXJhdGVkIHRocm91Z2ggdGhlIENvbmRpdGlvbiBlbGVtZW50IHNlYXJjaGluZyBmb3IgY29uZGl0aW9ucwogICAgICAgICAgICBlbnRyeS5yZXNvdXJjZS5leHRlbnNpb24uZm9yRWFjaCgoZWxlbWVudCkgPT4gewogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgcG9zaXRpb24gb2YgdGhlIGV4dGVuc2lvblsxXSBpcyBjb3JyZWN0CiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5leHRlbnNpb25bMV0udXJsID09ICJjb25jZXB0IikgewogICAgICAgICAgICAgICAgICAgIC8vIFNlYXJjaCB0aHJvdWdoIHRoZSBkaWZmZXJlbnQgdGVybWlub2xvZ2llcyB0aGF0IG1heSBiZSBhdmFpYmxlIHRvIGNoZWNrIGluIHRoZSBjb25kaXRpb24KICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5leHRlbnNpb25bMV0udmFsdWVDb2RlYWJsZVJlZmVyZW5jZS5jb25jZXB0ICE9IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmV4dGVuc2lvblsxXS52YWx1ZUNvZGVhYmxlUmVmZXJlbmNlLmNvbmNlcHQuY29kaW5nLmZvckVhY2goCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoY29kaW5nKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkV4dGVuc2lvbjogIiArIGVsZW1lbnQuZXh0ZW5zaW9uWzBdLnZhbHVlU3RyaW5nICsgIjoiICsgY29kaW5nLmNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWYgdGhlIGNvZGUgaXMgaW4gdGhlIGxpc3Qgb2YgY2F0ZWdvcmllcyB0byBzZWFyY2gKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGlzdE9mQ2F0ZWdvcmllc1RvU2VhcmNoLmluY2x1ZGVzKGNvZGluZy5jb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBDaGVjayBpZiB0aGUgY2F0ZWdvcnkgaXMgYWxyZWFkeSBpbiB0aGUgbGlzdCBvZiBjYXRlZ29yaWVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhdGVnb3JpZXMucHVzaChlbGVtZW50LmV4dGVuc2lvblswXS52YWx1ZVN0cmluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSk7CiAgICAgICAgfQogICAgfSk7CgogICAgaWYgKGNvbXBvc2l0aW9ucyA9PSAwKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdCYWQgZVBJOiBubyBjYXRlZ29yeSAiQ29tcG9zaXRpb24iIGZvdW5kJyk7CiAgICB9CgogICAgaWYgKGNhdGVnb3JpZXMubGVuZ3RoID09IDApIHsKICAgICAgICAvLyB0aHJvdyBuZXcgRXJyb3IoIk5vIGNhdGVnb3JpZXMgZm91bmQiLCBjYXRlZ29yaWVzKTsKICAgICAgICByZXR1cm4gaHRtbERhdGE7CiAgICB9CiAgICAvL0ZvY3VzIChhZGRzIGhpZ2hsaWdodCBjbGFzcykgdGhlIGh0bWwgYXBwbHlpbmcgZXZlcnkgY2F0ZWdvcnkgZm91bmQKICAgIHJldHVybiBhd2FpdCBhbm5vdGF0ZUhUTUxzZWN0aW9uKGNhdGVnb3JpZXMsICJoaWdobGlnaHQiKTsKfTsKCnJldHVybiB7CiAgICBlbmhhbmNlOiBlbmhhbmNlLAogICAgZ2V0U3BlY2lmaWNhdGlvbjogZ2V0U3BlY2lmaWNhdGlvbiwKfTs=" - }] - } \ No newline at end of file diff --git a/target/fhir-lens-proxy-pregnancy.json b/target/fhir-lens-proxy-pregnancy.json deleted file mode 100644 index 9c961c7..0000000 --- a/target/fhir-lens-proxy-pregnancy.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType" : "Library", - "id" : "fhir-lens-proxy-pregnancy", - "meta" : { - "profile" : ["http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lens"] - }, - "text" : { - "status" : "generated", - "div" : "

Parameters

inCodeableConceptparameter documentation

Contents

application/javascript

Classic Pregnancy Lens
" - }, - "extension" : [{ - "url" : "http://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/lee-version", - "valueString" : "0.1" - }], - "url" : "http://hl7.eu/fhir/ig/gravitate-health/Library/mock-lib", - "identifier" : [{ - "system" : "http://gravitate-health.lst.tfo.upm.es", - "value" : "fhir-lens-proxy-pregnancy" - }], - "version" : "0.1.0", - "name" : "fhir-lens-proxy-pregnancy", - "title" : "Proxy Pregnancy Lens - Now in FHIR format and with metadata", - "status" : "draft", - "experimental" : true, - "type" : { - "coding" : [{ - "code" : "logical-library" - }] - }, - "date" : "2024-02-29T10:54:27+00:00", - "publisher" : "Gravitate Health Project - UPM Team", - "contact" : [{ - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }, - { - "name" : "Gravitate Health Project", - "telecom" : [{ - "system" : "url", - "value" : "https://www.gravitatehealth.eu/" - }] - }], - "description" : "Original Lens made on Python. This lens connect with a service that executes the core computiong of the lens. If a person is female and between 18 and 70 years, information about pregnancy is going to be highlighted. if a person is a man, the information is collapsed", - "jurisdiction" : [{ - "coding" : [{ - "system" : "urn:iso:std:iso:3166", - "code" : "AD" - }] - }], - "purpose" : "The Pregnancy Lens is a lens that highlights information about pregnancy in the ePIs. It is intended to be used by patients to identify relevant information about pregnancy in the leaflets.", - "usage" : "Deploy the external service. Just apply it on the app", - "copyright" : "copyright label", - "parameter" : [{ - "use" : "in", - "documentation" : "parameter documentation", - "type" : "CodeableConcept" - }], - "content" : [{ - "contentType" : "application/javascript", - "data" : "bGV0IHB2RGF0YSA9IHB2OwpsZXQgaHRtbERhdGEgPSBodG1sOwoKbGV0IGVwaURhdGEgPSBlcGk7CmxldCBpcHNEYXRhID0gaXBzOwoKbGV0IGdldFNwZWNpZmljYXRpb24gPSAoKSA9PiB7CiAgICByZXR1cm4gIjEuMC4wIjsKfTsKCmxldCBlbmhhbmNlID0gYXN5bmMgKCkgPT4gewogICAgCiAgICBjb25zdCBob3N0ID0gcHJvY2Vzcy5lbnYuUFJPWFlfTEVOU19FTlYgPT0gImRldiIgPyAiaHR0cHM6Ly9ncmF2aXRhdGUtaGVhbHRoLmxzdC50Zm8udXBtLmVzIiA6ICJodHRwczovL2dyYXZpdGF0ZS1oZWFsdGgubHN0LnRmby51cG0uZXMiIC8vImh0dHBzOi8vZm9zcHMuZ3Jhdml0YXRlaGVhbHRoLmV1LyI7CiAgICBjb25zdCB1cmwgPSBgJHtob3N0fS9leHRlcm5hbC9wcmVnbmFuY3lgCiAgICBjb25zdCBvcHRpb25zID0gewogICAgICAgIG1ldGhvZDogIlBPU1QiLAogICAgICAgIGhlYWRlcnM6IHsKICAgICAgICAgICAgIkNvbnRlbnQtVHlwZSI6ICJhcHBsaWNhdGlvbi9qc29uIiwKICAgICAgICAgICAgIkFjY2VwdCI6ICJhcHBsaWNhdGlvbi9qc29uIgogICAgICAgIH0sCiAgICAgICAgYm9keTogSlNPTi5zdHJpbmdpZnkoewogICAgICAgICAgICBwdkRhdGE6IHB2LAogICAgICAgICAgICBodG1sRGF0YTogaHRtbCwKICAgICAgICAgICAgZXBpRGF0YTogSlNPTi5zdHJpbmdpZnkoZXBpKSwKICAgICAgICAgICAgaXBzRGF0YTogSlNPTi5zdHJpbmdpZnkoaXBzKQogICAgICAgIH0pCiAgICB9OwoKICAgIGxldCByZXNwb25zZSA9IGF3YWl0IGZldGNoKHVybCwgb3B0aW9ucykKICAgIC50aGVuKChyZXNwb25zZSkgPT4gewogICAgICAgIHJldHVybiByZXNwb25zZS5qc29uKCk7CiAgICB9KS5jYXRjaCgoZXJyb3IpID0+IHsKICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3IpOwogICAgfSk7CgogICAgcmV0dXJuIHJlc3BvbnNlLmh0bWxTdHJpbmc7Cn07CgpyZXR1cm4gewogICAgZW5oYW5jZTogZW5oYW5jZSwKICAgIGdldFNwZWNpZmljYXRpb246IGdldFNwZWNpZmljYXRpb24sCn07" - }] - } \ No newline at end of file