Skip to content

Commit

Permalink
Merge pull request #91 from hms-dbmi/PPM-766
Browse files Browse the repository at this point in the history
Ppm 766
  • Loading branch information
b32147 authored Jul 15, 2024
2 parents e8f255b + f940355 commit 737be42
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ppmutils/fhir.py
Original file line number Diff line number Diff line change
Expand Up @@ -7812,7 +7812,7 @@ def flatten_consent_composition(bundle: Union[Bundle, dict]) -> Optional[dict]:

# Exceptions are for when they refuse part of the consent.
consent_exception_extension = next(
e for e in signed_consent.extension if e.url == FHIR.consent_exception_extension_url
(e for e in signed_consent.extension if e.url == FHIR.consent_exception_extension_url), None
)
if consent_exception_extension:

Expand Down Expand Up @@ -9330,7 +9330,7 @@ def related_contract(

@staticmethod
def composition(
patient: Patient, date: datetime, text: str, resources: list[DomainResource] = []
patient: Patient, date: datetime, text: str, study: PPM.Study | str, resources: list[DomainResource] = []
) -> Composition:
"""
Creates and returns a FHIR resource of the given type for
Expand All @@ -9345,6 +9345,8 @@ def composition(
:type date: datetime
:param text: The text to set for the Composition
:type text: str
:param study: The study for which this resource applies
:type study: PPM.Study | str
:param resources: A list of resources related to the composition,
defaults to []
:type resources: list[DomainResource], optional
Expand Down Expand Up @@ -9393,6 +9395,11 @@ def composition(
consent_section.entry = [FHIR.Resources.reference_to(resource)]
composition.section.append(consent_section)

# Add study reference
study_section = CompositionSection()
study_section.entry = [FHIRReference({"reference": f"ResearchStudy/{PPM.Study.fhir_id(study)}"})]
composition.section.append(study_section)

return composition

@staticmethod
Expand Down

0 comments on commit 737be42

Please sign in to comment.