Skip to content

Commit

Permalink
Merge pull request #14 from BBMRI-cz/import_issues
Browse files Browse the repository at this point in the history
feat: move packages from src to root of the project
  • Loading branch information
SimonKonar authored Oct 30, 2024
2 parents 1ef80db + 9986080 commit 002a718
Show file tree
Hide file tree
Showing 35 changed files with 103 additions and 108 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The MIABIS on FHIR profile full specification along with the guide is available

## Modules

### 1. `MIABIS_on_FHIR`
The `MIABIS_on_FHIR` module includes a set of classes to help developers:
### 1. `miabis_model`
The `miabis_model` module includes a set of classes to help developers:
- **Create** MIABIS on FHIR resources.
- **Read** and **validate** these resources.
- **Convert** resources to and from JSON format.
Expand All @@ -37,14 +37,14 @@ This package is ideal for developers looking to work with MIABIS on FHIR resourc

## Installation
```bash
pip install MIABIS_on_FHIR
pip install miabis_model
```
## How to use
Here is how you can create a MIABIS on FHIR sample resource:

```python
from MIABIS_on_FHIR import Sample
from MIABIS_on_FHIR import StorageTemperature
from miabis_model import Sample
from miabis_model import StorageTemperature

sample = Sample("sampleId", "donorId", "Urine", storage_temperature=StorageTemperature.TEMPERATURE_ROOM,
use_restrictions="No restrictions")
Expand All @@ -58,12 +58,12 @@ Here is an example on how to communicate with blaze server via the BlazeClient:

```python
import datetime
from MIABIS_on_FHIR import Gender
from miabis_model import Gender
from blaze_client import BlazeClient
from MIABIS_on_FHIR import SampleDonor
from miabis_model import SampleDonor

client = BlazeClient("example_url","username","password")
client = BlazeClient("example_url", "username", "password")

donor = SampleDonor("donorId", Gender.MALE, birth_date=datetime.datetime(year=2000,month=12,day=12))
donor = SampleDonor("donorId", Gender.MALE, birth_date=datetime.datetime(year=2000, month=12, day=12))
donor_fhir_id = client.upload_donor(donor)
```
File renamed without changes.
24 changes: 12 additions & 12 deletions src/blaze_client/blaze_client.py → blaze_client/blaze_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from requests import Response
from requests.adapters import HTTPAdapter, Retry

from src.MIABIS_on_FHIR.biobank import Biobank
from src.MIABIS_on_FHIR.collection import Collection
from src.MIABIS_on_FHIR.collection_organization import CollectionOrganization
from src.MIABIS_on_FHIR.condition import Condition
from src.MIABIS_on_FHIR.diagnosis_report import DiagnosisReport
from src.MIABIS_on_FHIR.network import Network
from src.MIABIS_on_FHIR.network_organization import NetworkOrganization
from src.MIABIS_on_FHIR.observation import Observation
from src.MIABIS_on_FHIR.sample import Sample
from src.MIABIS_on_FHIR.sample_donor import SampleDonor
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id, \
from miabis_model.biobank import Biobank
from miabis_model.collection import Collection
from miabis_model.collection_organization import CollectionOrganization
from miabis_model.condition import Condition
from miabis_model.diagnosis_report import DiagnosisReport
from miabis_model.network import Network
from miabis_model.network_organization import NetworkOrganization
from miabis_model.observation import Observation
from miabis_model.sample import Sample
from miabis_model.sample_donor import SampleDonor
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id, \
get_material_type_from_detailed_material_type
from src.blaze_client.NonExistentResourceException import NonExistentResourceException
from blaze_client.NonExistentResourceException import NonExistentResourceException


class BlazeClient:
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/MIABIS_on_FHIR/biobank.py → miabis_model/biobank.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from fhirclient.models.meta import Meta
from fhirclient.models.organization import Organization

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import BIOBANK_BIOPROCESSING_AND_ANALYTICAL_CAPABILITIES, \
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import BIOBANK_BIOPROCESSING_AND_ANALYTICAL_CAPABILITIES, \
BIOBANK_INFRASTRUCTURAL_CAPABILITIES, \
BIOBANK_ORGANISATIONAL_CAPABILITIES, DEFINITION_BASE_URL
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_contact
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier, create_contact, create_country_of_residence, \
from miabis_model.util.parsing_util import get_nested_value, parse_contact
from miabis_model.util.util import create_fhir_identifier, create_contact, create_country_of_residence, \
create_codeable_concept_extension, create_string_extension


Expand Down
14 changes: 7 additions & 7 deletions src/MIABIS_on_FHIR/collection.py → miabis_model/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from fhirclient.models.quantity import Quantity
from fhirclient.models.range import Range

from src.MIABIS_on_FHIR.gender import Gender
from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.storage_temperature import StorageTemperature
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import COLLECTION_INCLUSION_CRITERIA, COLLECTION_MATERIAL_TYPE_CODES
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier, create_integer_extension, \
from miabis_model.gender import Gender
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.storage_temperature import StorageTemperature
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import COLLECTION_INCLUSION_CRITERIA, COLLECTION_MATERIAL_TYPE_CODES
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier, create_integer_extension, \
create_codeable_concept_extension, \
create_codeable_concept

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from fhirclient.models.meta import Meta
from fhirclient.models.organization import Organization

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import COLLECTION_DESIGN, COLLECTION_SAMPLE_COLLECTION_SETTING, \
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import COLLECTION_DESIGN, COLLECTION_SAMPLE_COLLECTION_SETTING, \
COLLECTION_SAMPLE_SOURCE, COLLECTION_DATASET_TYPE, COLLECTION_USE_AND_ACCESS_CONDITIONS
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_contact, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_country_of_residence, create_contact, create_codeable_concept_extension, \
from miabis_model.util.parsing_util import get_nested_value, parse_contact, parse_reference_id
from miabis_model.util.util import create_country_of_residence, create_contact, create_codeable_concept_extension, \
create_string_extension, create_fhir_identifier


Expand Down
8 changes: 4 additions & 4 deletions src/MIABIS_on_FHIR/condition.py → miabis_model/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from fhirclient.models.fhirreference import FHIRReference
from fhirclient.models.meta import Meta

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier


class Condition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from fhirclient.models.fhirreference import FHIRReference
from fhirclient.models.meta import Meta

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier


class DiagnosisReport:
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/MIABIS_on_FHIR/network.py → miabis_model/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from fhirclient.models.group import Group
from fhirclient.models.meta import Meta

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier


class Network:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from fhirclient.models.meta import Meta
from fhirclient.models.organization import Organization

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import NETWORK_COMMON_COLLAB_TOPICS
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_contact, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier, create_contact, create_country_of_residence, \
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import NETWORK_COMMON_COLLAB_TOPICS
from miabis_model.util.parsing_util import get_nested_value, parse_contact, parse_reference_id
from miabis_model.util.util import create_fhir_identifier, create_contact, create_country_of_residence, \
create_codeable_concept_extension, create_string_extension


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from fhirclient.models.fhirreference import FHIRReference
from fhirclient.models.meta import Meta

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier


class Observation:
Expand Down
12 changes: 6 additions & 6 deletions src/MIABIS_on_FHIR/sample.py → miabis_model/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from fhirclient.models.meta import Meta
from fhirclient.models.specimen import Specimen, SpecimenCollection, SpecimenProcessing

from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.storage_temperature import StorageTemperature
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import DETAILED_MATERIAL_TYPE_CODES
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value, parse_reference_id
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier, create_codeable_concept, \
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.storage_temperature import StorageTemperature
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import DETAILED_MATERIAL_TYPE_CODES
from miabis_model.util.parsing_util import get_nested_value, parse_reference_id
from miabis_model.util.util import create_fhir_identifier, create_codeable_concept, \
create_codeable_concept_extension


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from fhirclient.models.meta import Meta
from fhirclient.models.patient import Patient

from src.MIABIS_on_FHIR.gender import Gender
from src.MIABIS_on_FHIR.incorrect_json_format import IncorrectJsonFormatException
from src.MIABIS_on_FHIR.util.config import FHIRConfig
from src.MIABIS_on_FHIR.util.constants import DONOR_DATASET_TYPE
from src.MIABIS_on_FHIR.util.parsing_util import get_nested_value
from src.MIABIS_on_FHIR.util.util import create_fhir_identifier, create_codeable_concept_extension
from miabis_model.gender import Gender
from miabis_model.incorrect_json_format import IncorrectJsonFormatException
from miabis_model.util.config import FHIRConfig
from miabis_model.util.constants import DONOR_DATASET_TYPE
from miabis_model.util.parsing_util import get_nested_value
from miabis_model.util.util import create_fhir_identifier, create_codeable_concept_extension


class SampleDonor:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dateutil import parser as date_parser
from datetime import date

from src.MIABIS_on_FHIR.util.constants import DETAILED_MATERIAL_TYPE_TO_COLLECTION_MATERIAL_TYPE_MAP
from miabis_model.util.constants import DETAILED_MATERIAL_TYPE_TO_COLLECTION_MATERIAL_TYPE_MAP


def get_nested_value(data: dict, keys: list):
Expand Down
File renamed without changes.
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"

[project]
name = "MIABIS_on_FHIR"
version = "1.0.0"
description = "Library containing classes for easier handling of data according to the MIABIS on FHIR profile"
version = "1.1.0"
description = "Library containing classes for easier handling of data according to the MIABIS on FHIR profile, as well as client for communication with sample blaze server"
readme = "README.md"
authors = [{"name" = "Simon Konar", "email" = "[email protected]"}]
license = { file = "LICENSE" }
Expand All @@ -26,11 +26,8 @@ requires-python = ">=3.11"
[project.optional-dependencies]
test=["pytest >= 8.3.0"]

[tool.setuptools]
package-dir = { "" = "src" }


[tool.setuptools.packages.find]
where = ["src"]
include = ["MIABIS_on_FHIR*", "blaze_client*"]
include = ["miabis_model*", "blaze_client*"]
exclude =["test*"]
30 changes: 14 additions & 16 deletions test/service/test_blaze_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@

import pytest as pytest
import requests.exceptions
from fhirclient.models.bundle import Bundle, BundleEntry, BundleEntryRequest
from fhirclient.models.patient import Patient
from requests.exceptions import HTTPError

from src.MIABIS_on_FHIR.biobank import Biobank
from src.MIABIS_on_FHIR.collection import Collection
from src.MIABIS_on_FHIR.collection_organization import CollectionOrganization
from src.MIABIS_on_FHIR.condition import Condition
from src.MIABIS_on_FHIR.diagnosis_report import DiagnosisReport
from src.MIABIS_on_FHIR.gender import Gender
from src.MIABIS_on_FHIR.network import Network
from src.MIABIS_on_FHIR.network_organization import NetworkOrganization
from src.MIABIS_on_FHIR.observation import Observation
from src.MIABIS_on_FHIR.sample import Sample
from src.MIABIS_on_FHIR.sample_donor import SampleDonor
from src.MIABIS_on_FHIR.storage_temperature import StorageTemperature
from src.blaze_client.NonExistentResourceException import NonExistentResourceException
from src.blaze_client.blaze_client import BlazeClient
from miabis_model import Biobank
from miabis_model import Collection
from miabis_model.collection_organization import CollectionOrganization
from miabis_model import Condition
from miabis_model import DiagnosisReport
from miabis_model import Gender
from miabis_model import Network
from miabis_model import NetworkOrganization
from miabis_model.observation import Observation
from miabis_model import Sample
from miabis_model import SampleDonor
from miabis_model import StorageTemperature
from blaze_client import NonExistentResourceException
from blaze_client.blaze_client import BlazeClient


class TestBlazeService(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_biobank.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.biobank import Biobank
from miabis_model import Biobank


class TestBiobank(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions test/unit/model/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from fhirclient.models.group import Group

from src.MIABIS_on_FHIR.collection import Collection
from src.MIABIS_on_FHIR.gender import Gender
from src.MIABIS_on_FHIR.storage_temperature import StorageTemperature
from miabis_model import Collection
from miabis_model import Gender
from miabis_model import StorageTemperature


class TestCollection(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_collection_org.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.collection_organization import CollectionOrganization
from miabis_model.collection_organization import CollectionOrganization


class TestCollectionOrganization(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_condition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.condition import Condition
from miabis_model import Condition


class TestCondition(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_diagnosis_report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.diagnosis_report import DiagnosisReport
from miabis_model import DiagnosisReport


class TestDiagnosisReport(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.network import Network
from miabis_model import Network


class TestNetwork(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_network_org.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from src.MIABIS_on_FHIR.network_organization import NetworkOrganization
from miabis_model import NetworkOrganization


class TestNetworkOrganization(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/model/test_observation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import unittest

from src.MIABIS_on_FHIR.observation import Observation
from miabis_model.observation import Observation


class TestObservation(unittest.TestCase):
Expand Down
Loading

0 comments on commit 002a718

Please sign in to comment.