Skip to content

Commit

Permalink
sections pt and test
Browse files Browse the repository at this point in the history
  • Loading branch information
joofio committed Nov 25, 2024
1 parent eb2c566 commit 7d39e96
Show file tree
Hide file tree
Showing 8 changed files with 414 additions and 139 deletions.
88 changes: 44 additions & 44 deletions input/fsh/examples/processedEPI/p_pt-scenario.fsh

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions input/fsh/examples/rawEPI/pt-scenario.fsh

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
26 changes: 26 additions & 0 deletions tests/lenses.http
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ GET https://gravitate-health.lst.tfo.upm.es/epi/api/fhir/Composition?subject=mp9

### Test Lens: Pregnancy
POST https://gravitate-health.lst.tfo.upm.es/focusing/focus/processedbundledovato-en-49178f16170ee8a6bc2a4361c1748d5f?preprocessors=preprocessing-service-manual&lenses=lens-selector-mvp2_pregnancy&patientIdentifier=Pedro-1
Accept: application/json


### that worked
Expand Down Expand Up @@ -250,3 +251,28 @@ POST http://gravitate-health.lst.tfo.upm.es/focusing/focus/PT-Glimepirida-Generi
### testing
POST https://fosps.gravitatehealth.eu/focusing/focus/PT-Glimepirida-Generis-processed-bundle?patientIdentifier=alicia-1



##### tttt
POST https://gravitate-health.lst.tfo.upm.es/focusing/focus/bundlepackageleaflet-es-94a96e39cfdcd8b378d12dd4063065f9?preprocessors=preprocessing-service-manual&patientIdentifier=alicia-1
Accept: application/json



### preproc

POST https://gravitate-health.lst.tfo.upm.es/focusing/preprocessing/bundlepackageleaflet-es-da0fc2395ce219262dfd4f0c9a9f72e1?preprocessors=preprocessing-service-mvp2
Accept: application/json


##### testing testing-preprocessor.py
POST https://gravitate-health.lst.tfo.upm.es/focusing/preprocessing/bundlepackageleaflet-es-29436a85dac3ea374adb3fa64cfd2578?preprocessors=preprocessing-service-mvp2
Accept: application/json


### preproc

POST https://gravitate-health.lst.tfo.upm.es/focusing/preprocessing/bundlepackageleaflet-es-af1953635c28668e0d454e0740fcb36f?preprocessors=preprocessing-service-mvp2
Accept: application/json


5 changes: 5 additions & 0 deletions tests/new-tests.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### condition lens
POST https://gravitate-health.lst.tfo.upm.es/focusing/focus/bundlepackageleaflet-en-94a96e39cfdcd8b378d12dd4063065f9?preprocessors=preprocessing-service-manual&patientIdentifier=alicia-1
content-type: application/json
Accept: application/json
#Accept: text/html
25 changes: 25 additions & 0 deletions tests/output.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
epid,extension+
bundlepackageleaflet-da-dcaa4d32aa6658a8df831551503e52ee, No extension
bundlepackageleaflet-es-da0fc2395ce219262dfd4f0c9a9f72e1, Has extension
FK40274, No extension
bundlepackageleaflet-da-a38f06714db0c27b2ba704652e3f08c5, No extension
bundlepackageleaflet-en-dcaa4d32aa6658a8df831551503e52ee, Has extension
bundlepackageleaflet-en-a64c0ccb066e7fdf6ba2d86dcd8bda5e, Has extension
bundlepackageleaflet-en-2f37d696067eeb6daf1111cfc3272672, Has extension
bundlepackageleaflet-es-e762a2f54b0b24fca4744b1bb7524a5b, Has extension
bundlepackageleaflet-es-29436a85dac3ea374adb3fa64cfd2578, Has extension
FK45691, No extension
PT-Glimepirida-Generis, No extension
bundlepackageleaflet-en-04c9bd6fb89d38b2d83eced2460c4dc1, Has extension
bundlepackageleaflet-en-b62cc095c7be2116a8a65157286376a3, Has extension
bundlepackageleaflet-es-4fab126d28f65a1084e7b50a23200363, Has extension
bundlepackageleafletxyntha, No extension
bundlepackageleaflet-en-534e209eb0a3ff60437639cb2015316f, No extension
bundlepackageleaflet-en-e2464a7d3d627b9df9bef5bc3b263fb4, Has extension
bundlepackageleaflet-es-af1953635c28668e0d454e0740fcb36f, No extension
FK37812, No extension
bundlepackageleaflet-en-94a96e39cfdcd8b378d12dd4063065f9, Has extension
bundlepackageleaflet-pt-49178f16170ee8a6bc2a4361c1748d5f, No extension
bundlepackageleaflet-es-dcaa4d32aa6658a8df831551503e52ee, Has extension
bundlepackageleaflet-es-2f37d696067eeb6daf1111cfc3272672, Has extension
PT-GLUCOPHAGE, No extension
48 changes: 20 additions & 28 deletions tests/testing-preprocessor.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import json

import requests

headers = {"Content-Type": "application/json", "Accept": "application/json"}


def word_in_json(json_obj, word):
"""
Check if a word exists anywhere in a JSON object/dict.
Args:
json_obj (dict or list): The JSON object to search.
word (str): The word to search for.
Returns:
bool: True if the word is found, False otherwise.
"""
if isinstance(json_obj, dict):
for key, value in json_obj.items():
if word_in_json(value, word): # Recursive check in value
return True
elif isinstance(json_obj, list):
for item in json_obj:
if word_in_json(item, word): # Recursive check in each item
return True
elif isinstance(json_obj, str): # Check if word is in string
if word in json_obj:
return True
return False
file = open("output.csv", "w")
file.write("epid" + ",extension+\n")


def test_preprocessor(epiid, language):
Expand All @@ -41,12 +21,22 @@ def test_preprocessor(epiid, language):

composition = result["entry"][0]
## print(composition)
extension_exist = word_in_json(composition, "extension")
print(extension_exist) # Output: ?
json_string = json.dumps(composition)

extension_exist = (
"https://hl7.eu/fhir/ig/gravitate-health/StructureDefinition/HtmlElementLink"
in json_string
)

# print(extension_exist) # Output: ?
# print(word_in_json(composition, "composition")) # Output: True
# print(word_in_json(composition, "whites")) # Output: True
if not extension_exist:
print(epiid, "No extension")
file.write(epiid + ", No extension\n")
else:
file.write(epiid + ", Has extension\n")

return 1


Expand Down Expand Up @@ -76,8 +66,9 @@ def fetch_paginated_data(
id_ = bundle["id"]
# print(id_)
language = composition.get("language")
if not language:
pass
# print(language)
if not language or language in ["no", "fi", "ja"]:
continue
category = composition.get("category")
if category is None:
test_preprocessor(id_, language)
Expand All @@ -102,3 +93,4 @@ def fetch_paginated_data(

fetch_paginated_data()
# test_preprocessor("bundlepackageleaflet-en-b62cc095c7be2116a8a65157286376a3", "en")
file.close()
Loading

0 comments on commit 7d39e96

Please sign in to comment.