Skip to content

Commit 4b5c336

Browse files
committed
💥 transformation to FHIR R5 has been officially started.
* root FHIR resources are moved under R4B sub-packages. * make sure all tests are passing & lintings are fine.
1 parent 92d72ff commit 4b5c336

File tree

352 files changed

+61
-1247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+61
-1247
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ ENV/
106106
# Others
107107
/pip-wheel-metadata
108108
/fhir-parser
109+
.python-version

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ script:
6363
- pytest tests
6464
- pytest fhir/resources/DSTU2/tests
6565
- pytest fhir/resources/STU3/tests
66-
- pytest -s --cov=fhir/resources/tests -s --tb=native -v --cov-report term-missing --cov-append fhir/resources/tests
66+
- pytest -s --cov=fhir/resources/R4B/tests -s --tb=native -v --cov-report term-missing --cov-append fhir/resources/R4B/tests
6767
after_success:
6868
- codecov

fhir/resources/DSTU2/fhirabstractmodel.py

-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ def dict(
268268
if field.outer_type_ != field.type_ and str(
269269
field.outer_type_
270270
).startswith("typing.List["):
271-
272271
children_excludes[field.name] = {
273272
"__all__": {FHIR_COMMENTS_FIELD_NAME}
274273
}

fhir/resources/DSTU2/fhirtypes.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ class Oid(ConstrainedStr):
236236

237237
class Markdown(ConstrainedStr):
238238
"""A FHIR string (see above) that may contain markdown syntax for optional processing
239-
by a markdown presentation engine, in the GFM extension of CommonMark format (see below)"""
239+
by a markdown presentation engine, in the GFM extension of CommonMark format (see below)
240+
"""
240241

241242
__visit_name__ = "markdown"
242243
regex = re.compile(r"\s*(\S|\s)*")
@@ -262,7 +263,6 @@ class Date(datetime.date):
262263

263264
@classmethod
264265
def __get_validators__(cls) -> "CallableGenerator":
265-
266266
yield cls.validate
267267

268268
@classmethod
@@ -309,7 +309,6 @@ class DateTime(datetime.datetime):
309309

310310
@classmethod
311311
def __get_validators__(cls) -> "CallableGenerator":
312-
313312
yield cls.validate
314313

315314
@classmethod
@@ -351,7 +350,8 @@ class Instant(datetime.datetime):
351350
use date or dateTime (which can be as precise as instant,
352351
but is not required to be). instant is a more constrained dateTime
353352
354-
Note: This type is for system times, not human times (see date and dateTime below)."""
353+
Note: This type is for system times, not human times (see date and dateTime below).
354+
"""
355355

356356
regex = re.compile(
357357
r"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|"
@@ -364,7 +364,6 @@ class Instant(datetime.datetime):
364364

365365
@classmethod
366366
def __get_validators__(cls) -> "CallableGenerator":
367-
368367
yield cls.validate
369368

370369
@classmethod
@@ -389,7 +388,6 @@ class Time(datetime.time):
389388

390389
@classmethod
391390
def __get_validators__(cls) -> "CallableGenerator":
392-
393391
yield cls.validate
394392

395393
@classmethod

fhir/resources/DSTU2/fhirtypesvalidators.py

-4
Original file line numberDiff line numberDiff line change
@@ -464,22 +464,18 @@ def fhir_model_validator(
464464

465465

466466
def fhirprimitiveextension_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]):
467-
468467
return fhir_model_validator("FHIRPrimitiveExtension", v)
469468

470469

471470
def element_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]):
472-
473471
return fhir_model_validator("Element", v)
474472

475473

476474
def resource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]):
477-
478475
return fhir_model_validator("Resource", v)
479476

480477

481478
def domainresource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]):
482-
483479
return fhir_model_validator("DomainResource", v)
484480

485481

fhir/resources/DSTU2/specimen.py

-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class Specimen(DomainResource):
134134

135135

136136
class SpecimenCollection(BackboneElement):
137-
138137
resource_type = Field("SpecimenCollection", const=True)
139138

140139
collector: fhirtypes.ReferenceType = Field(

fhir/resources/R4B/__init__.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
from pathlib import Path
3+
from typing import Any, Dict, Union
4+
5+
from fhir.resources.core.fhirabstractmodel import FHIRAbstractModel
6+
7+
from .fhirtypesvalidators import get_fhir_model_class
8+
9+
__fhir_version__ = "4.3.0"
10+
11+
12+
def construct_fhir_element(
13+
element_type: str, data: Union[Dict[str, Any], str, bytes, Path]
14+
) -> FHIRAbstractModel:
15+
try:
16+
klass = get_fhir_model_class(element_type)
17+
except KeyError:
18+
raise LookupError(
19+
f"'{element_type}' is not valid FHIRModel (element type) name!"
20+
)
21+
if isinstance(data, (str, bytes)):
22+
return klass.parse_raw(data, content_type="application/json")
23+
elif isinstance(data, Path):
24+
return klass.parse_file(data)
25+
return klass.parse_obj(data)
26+
27+
28+
__all__ = ["get_fhir_model_class", "construct_fhir_element"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

fhir/resources/fhirtypes.py fhir/resources/R4B/fhirtypes.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ def to_string(cls, value):
420420

421421
class Markdown(ConstrainedStr, Primitive):
422422
"""A FHIR string (see above) that may contain markdown syntax for optional processing
423-
by a markdown presentation engine, in the GFM extension of CommonMark format (see below)"""
423+
by a markdown presentation engine, in the GFM extension of CommonMark format (see below)
424+
"""
424425

425426
__visit_name__ = "markdown"
426427
regex = re.compile(r"\s*(\S|\s)*")
@@ -461,7 +462,6 @@ class Date(datetime.date, Primitive):
461462

462463
@classmethod
463464
def __get_validators__(cls) -> "CallableGenerator":
464-
465465
yield cls.validate
466466

467467
@classmethod
@@ -516,7 +516,6 @@ class DateTime(datetime.datetime, Primitive):
516516

517517
@classmethod
518518
def __get_validators__(cls) -> "CallableGenerator":
519-
520519
yield cls.validate
521520

522521
@classmethod
@@ -566,7 +565,8 @@ class Instant(datetime.datetime, Primitive):
566565
use date or dateTime (which can be as precise as instant,
567566
but is not required to be). instant is a more constrained dateTime
568567
569-
Note: This type is for system times, not human times (see date and dateTime below)."""
568+
Note: This type is for system times, not human times (see date and dateTime below).
569+
"""
570570

571571
regex = re.compile(
572572
r"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|"
@@ -579,7 +579,6 @@ class Instant(datetime.datetime, Primitive):
579579

580580
@classmethod
581581
def __get_validators__(cls) -> "CallableGenerator":
582-
583582
yield cls.validate
584583

585584
@classmethod
@@ -612,7 +611,6 @@ class Time(datetime.time, Primitive):
612611

613612
@classmethod
614613
def __get_validators__(cls) -> "CallableGenerator":
615-
616614
yield cls.validate
617615

618616
@classmethod

0 commit comments

Comments
 (0)