diff --git a/healthchain/data_generator/__init__.py b/healthchain/data_generator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/healthchain/data_generator/base_generators.py b/healthchain/data_generator/base_generators.py new file mode 100644 index 0000000..60827d7 --- /dev/null +++ b/healthchain/data_generator/base_generators.py @@ -0,0 +1,179 @@ +# generators.py + +import random +import string + +from healthchain.fhir_resources.base_resources import ( + booleanModel, + canonicalModel, + codeModel, + dateModel, + dateTimeModel, + decimalModel, + idModel, + instantModel, + integerModel, + markdownModel, + positiveIntModel, + stringModel, + timeModel, + unsignedIntModel, + uriModel, + urlModel, + uuidModel, +) + +from faker import Faker + +faker = Faker() + + +class Registry: + def __init__(self): + self.registry = {} + + def register(self, cls): + self.registry[cls.__name__] = cls + return cls + + def get(self, name): + if name not in self.registry: + raise ValueError(f"No generator registered for '{name}'") + return self.registry.get(name) + + +generator_registry = Registry() + + +def register_generator(cls): + generator_registry.register(cls) + return cls + + +@register_generator +class BaseGenerator: + @staticmethod + def generate(): + raise NotImplementedError("Each generator must implement a 'generate' method.") + + +@register_generator +class booleanGenerator(BaseGenerator): + @staticmethod + def generate(): + return booleanModel(random.choice(["true", "false"])) + + +@register_generator +class canonicalGenerator(BaseGenerator): + @staticmethod + def generate(): + return canonicalModel(f"https://example/{faker.uri_path()}") + + +@register_generator +class codeGenerator(BaseGenerator): + # TODO: Codes can technically have whitespace but here I've left it out for simplicity + @staticmethod + def generate(): + return codeModel( + "".join(random.choices(string.ascii_uppercase + string.digits, k=6)) + ) + + +@register_generator +class dateGenerator(BaseGenerator): + @staticmethod + def generate(): + return dateModel(faker.date()) + + +@register_generator +class dateTimeGenerator(BaseGenerator): + @staticmethod + def generate(): + return dateTimeModel(faker.date_time().isoformat()) + + +@register_generator +class decimalGenerator(BaseGenerator): + @staticmethod + def generate(): + return decimalModel(faker.random_number()) + + +@register_generator +class idGenerator(BaseGenerator): + @staticmethod + def generate(): + return idModel(faker.uuid4()) + + +@register_generator +class instantGenerator(BaseGenerator): + @staticmethod + def generate(): + return instantModel(faker.date_time().isoformat()) + + +@register_generator +class integerGenerator(BaseGenerator): + @staticmethod + def generate(): + return integerModel(faker.random_int()) + + +@register_generator +class markdownGenerator(BaseGenerator): + @staticmethod + def generate(): + return markdownModel(faker.text()) + + +@register_generator +class positiveIntGenerator(BaseGenerator): + @staticmethod + def generate(): + return positiveIntModel(faker.random_int(min=1)) + + +@register_generator +class stringGenerator(BaseGenerator): + @staticmethod + def generate(): + return stringModel(faker.word()) + + +@register_generator +class timeGenerator(BaseGenerator): + @staticmethod + def generate(): + return timeModel(faker.time()) + + +@register_generator +class unsignedIntGenerator(BaseGenerator): + @staticmethod + def generate(): + return unsignedIntModel(faker.random_int(min=0)) + + +@register_generator +class uriGenerator(BaseGenerator): + @staticmethod + def generate(): + return uriModel(f"https://example/{faker.uri_path()}") + + +@register_generator +class urlGenerator(BaseGenerator): + @staticmethod + def generate(): + return urlModel(f"https://example/{faker.uri_path()}") + + +@register_generator +class uuidGenerator(BaseGenerator): + @staticmethod + def generate(): + return uuidModel(faker.uuid4()) diff --git a/healthchain/data_generator/encounter_generator.py b/healthchain/data_generator/encounter_generator.py new file mode 100644 index 0000000..807d455 --- /dev/null +++ b/healthchain/data_generator/encounter_generator.py @@ -0,0 +1,92 @@ +from healthchain.fhir_resources.encounter_resources import EncounterModel +from healthchain.fhir_resources.base_resources import CodingModel, CodeableConceptModel +from healthchain.data_generator.base_generators import ( + BaseGenerator, + generator_registry, + register_generator, +) +from typing import Optional +from faker import Faker + +faker = Faker() + + +@register_generator +class ClassGenerator(BaseGenerator): + @staticmethod + def generate(): + patient_class_mapping = {"IMP": "inpatient", "AMB": "ambulatory"} + patient_class = faker.random_element(elements=("IMP", "AMB")) + return CodeableConceptModel( + coding=[ + CodingModel( + system="http://terminology.hl7.org/CodeSystem/v3-ActCode", + code=patient_class, + display=patient_class_mapping.get(patient_class), + ) + ] + ) + + +@register_generator +class EncounterTypeGenerator(BaseGenerator): + @staticmethod + def generate(): + encounter_type_mapping = {"11429006": "consultation", "50849002": "emergency"} + encounter_type = faker.random_element(elements=("11429006", "50849002")) + return CodeableConceptModel( + coding=[ + CodingModel( + system="http://snomed.info/sct", + code=encounter_type, + display=encounter_type_mapping.get(encounter_type), + ) + ] + ) + + +@register_generator +class EncounterPriorityGenerator(BaseGenerator): + @staticmethod + def generate(): + encounter_priority_mapping = {"17621005": "normal", "24484000": "critical"} + encounter_priority = faker.random_element(elements=("17621005", "24484000")) + return CodeableConceptModel( + coding=[ + CodingModel( + system="http://snomed.info/sct", + code=encounter_priority, + display=encounter_priority_mapping.get(encounter_priority), + ) + ] + ) + + +@register_generator +class EncounterGenerator(BaseGenerator): + @staticmethod + def generate(patient_reference: Optional[str]): + if patient_reference is None: + patient_reference = "Patient/123" + return EncounterModel( + resourceType="Encounter", + id=generator_registry.get("idGenerator").generate(), + text={ + "status": "generated", + "div": '
Encounter with patient @example
', + }, + status=faker.random_element( + elements=( + "planned", + "in-progress", + "on-hold", + "discharged", + "cancelled", + ) + ), + class_field=[generator_registry.get("ClassGenerator").generate()], + type_field=[generator_registry.get("EncounterTypeGenerator").generate()], + subject={"reference": patient_reference, "display": patient_reference}, + participant=[], + reason=[], + ) diff --git a/healthchain/data_generator/generator_templates/templates.py b/healthchain/data_generator/generator_templates/templates.py new file mode 100644 index 0000000..3e2aca4 --- /dev/null +++ b/healthchain/data_generator/generator_templates/templates.py @@ -0,0 +1,6 @@ +from pydantic import BaseModel + + +class patient_template_1(BaseModel): + name: list = [{"family": "Doe", "given": ["John"], "prefix": ["Mr."]}] + birthDate: str = "1999-01-01" diff --git a/healthchain/data_generator/patient_generator.py b/healthchain/data_generator/patient_generator.py new file mode 100644 index 0000000..d78a89b --- /dev/null +++ b/healthchain/data_generator/patient_generator.py @@ -0,0 +1,129 @@ +from healthchain.data_generator.base_generators import ( + BaseGenerator, + generator_registry, + register_generator, +) +from healthchain.fhir_resources.base_resources import ( + PeriodModel, + CodeableConceptModel, + stringModel, + CodingModel, + uriModel, + codeModel, + dateTimeModel, + positiveIntModel, +) +from healthchain.fhir_resources.patient_resources import ( + PatientModel, + HumanNameModel, + ContactPointModel, + AddressModel, +) +from faker import Faker + + +faker = Faker() + + +@register_generator +class PeriodGenerator(BaseGenerator): + @staticmethod + def generate(): + start = faker.date_time() + end = faker.date_time_between(start_date=start).isoformat() + start = start.isoformat() + return PeriodModel( + start=dateTimeModel(start), + end=dateTimeModel(end), + ) + + +@register_generator +class ContactPointGenerator(BaseGenerator): + @staticmethod + def generate(): + return ContactPointModel( + system=codeModel(faker.random_element(elements=("phone", "fax"))), + value=stringModel(faker.phone_number()), + use=codeModel(faker.random_element(elements=("home", "work"))), + rank=positiveIntModel(1), + period=generator_registry.get("PeriodGenerator").generate(), + ) + + +@register_generator +class AddressGenerator(BaseGenerator): + @staticmethod + def generate(): + return AddressModel( + use=codeModel( + faker.random_element(elements=("home", "work", "temp", "old")) + ), + type=codeModel( + faker.random_element(elements=("postal", "physical", "both")) + ), + text=stringModel(faker.address()), + line=[stringModel(faker.street_address())], + city=stringModel(faker.city()), + district=stringModel(faker.state()), + state=stringModel(faker.state_abbr()), + postalCode=stringModel(faker.postcode()), + country=stringModel(faker.country_code()), + period=generator_registry.get("PeriodGenerator").generate(), + ) + + +@register_generator +class maritalStatusGenerator(BaseGenerator): + def generate(): + marital_status_dict = { + "D": "Divorced", + "L": "Legally Separated", + "M": "Married", + } + marital_code = faker.random_element(elements=(marital_status_dict.keys())) + return CodeableConceptModel( + coding=[ + CodingModel( + system=uriModel( + "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus" + ), + code=codeModel(marital_code), + display=stringModel(marital_status_dict.get(marital_code)), + ) + ], + text=stringModel(marital_status_dict.get(marital_code)), + ) + + +@register_generator +class HumanNameGenerator(BaseGenerator): + @staticmethod + def generate(): + return HumanNameModel( + family=stringModel(faker.last_name()), + given=[stringModel(faker.first_name())], + prefix=[stringModel(faker.prefix())], + suffix=[stringModel(faker.suffix())], + ) + + +@register_generator +class PatientGenerator(BaseGenerator): + @staticmethod + def generate(): + return PatientModel( + resourceType="Patient", + id=generator_registry.get("idGenerator").generate(), + active=generator_registry.get("booleanGenerator").generate(), + name=[generator_registry.get("HumanNameGenerator").generate()], + telecom=[generator_registry.get("ContactPointGenerator").generate()], + gender=codeModel( + faker.random_element(elements=("male", "female", "other", "unknown")) + ), + birthDate=generator_registry.get("dateGenerator").generate(), + address=[ + generator_registry.get("AddressGenerator").generate() for _ in range(1) + ], ## List of length 1 for simplicity + maritalStatus=generator_registry.get("maritalStatusGenerator").generate(), + ) diff --git a/healthchain/data_generator/practitioner_generator.py b/healthchain/data_generator/practitioner_generator.py new file mode 100644 index 0000000..2e468dc --- /dev/null +++ b/healthchain/data_generator/practitioner_generator.py @@ -0,0 +1,129 @@ +from healthchain.data_generator.base_generators import ( + BaseGenerator, + generator_registry, + register_generator, +) +from healthchain.fhir_resources.base_resources import ( + booleanModel, + CodeableConceptModel, + stringModel, + CodingModel, + uriModel, + codeModel, +) +from healthchain.fhir_resources.practitioner_resources import ( + PractitionerModel, + Practitioner_QualificationModel, + Practitioner_CommunicationModel, +) +from faker import Faker + + +faker = Faker() + + +@register_generator +class QualificationGenerator(BaseGenerator): + # TODO: Update with realistic qualifications + qualification_dict = { + "12345": "Qualification 1", + "67890": "Qualification 2", + "54321": "Qualification 3", + "09876": "Qualification 4", + "65432": "Qualification 5", + } + + @staticmethod + def generate(): + random_qual = faker.random_element( + elements=QualificationGenerator.qualification_dict.keys() + ) + return CodeableConceptModel( + coding=[ + CodingModel( + system=uriModel("http://example.org"), + code=codeModel(random_qual), + display=stringModel( + QualificationGenerator.qualification_dict.get(random_qual) + ), + ) + ], + text=stringModel( + QualificationGenerator.qualification_dict.get(random_qual) + ), + ) + + +@register_generator +class Practitioner_QualificationGenerator(BaseGenerator): + @staticmethod + def generate(): + return Practitioner_QualificationModel( + id=stringModel(faker.uuid4()), + code=generator_registry.get("QualificationGenerator").generate(), + # TODO: Modify period generator to have flexibility to set to present date + period=generator_registry.get("PeriodGenerator").generate(), + # issuer=generator_registry.get('ReferenceGenerator').generate(), + ) + + +@register_generator +class LanguageGenerator: + @staticmethod + def generate(): + language_value_dict = { + "en": "English", + "es": "Spanish", + "fr": "French", + "de": "German", + "it": "Italian", + "ja": "Japanese", + "ko": "Korean", + "zh": "Chinese", + "ru": "Russian", + "ar": "Arabic", + } + language = faker.random_element(elements=language_value_dict.keys()) + return CodeableConceptModel( + coding=[ + CodingModel( + system=uriModel("http://terminology.hl7.org/CodeSystem/languages"), + code=codeModel(language), + display=stringModel(language_value_dict.get(language)), + ) + ], + text=stringModel(language_value_dict.get(language)), + ) + + +@register_generator +class Practitioner_CommunicationGenerator(BaseGenerator): + @staticmethod + def generate(): + return Practitioner_CommunicationModel( + id=stringModel(faker.uuid4()), + language=generator_registry.get("LanguageGenerator").generate(), + preferred=booleanModel("true"), + ) + + +@register_generator +class PractitionerGenerator(BaseGenerator): + @staticmethod + def generate(): + return PractitionerModel( + id=stringModel(faker.uuid4()), + active=booleanModel("true"), + name=[generator_registry.get("HumanNameGenerator").generate()], + telecom=[generator_registry.get("ContactPointGenerator").generate()], + gender=codeModel( + faker.random_element(elements=("male", "female", "other", "unknown")) + ), + address=[generator_registry.get("AddressGenerator").generate()], + qualification=[ + generator_registry.get("Practitioner_QualificationGenerator").generate() + ], + communication=[ + generator_registry.get("Practitioner_CommunicationGenerator").generate() + ], + ) diff --git a/healthchain/fhir_resources/base_resources.py b/healthchain/fhir_resources/base_resources.py new file mode 100644 index 0000000..742e596 --- /dev/null +++ b/healthchain/fhir_resources/base_resources.py @@ -0,0 +1,255 @@ +from __future__ import annotations + +from pydantic import BaseModel, Field, conint +from typing import List +from pydantic import constr + + +booleanModel = constr(pattern=r"^(true|false)$") +canonicalModel = constr(pattern=r"^\S*$") +codeModel = constr(pattern=r"^[^\s]+( [^\s]+)*$") +dateModel = constr( + pattern=r"^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?$" +) +dateTimeModel = constr( + pattern=r"^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?)?)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)?)?)?$" +) +decimalModel = constr( + pattern=r"^-?(0|[1-9][0-9]{0,17})(\.[0-9]{1,17})?([eE][+-]?[0-9]{1,9}})?$" +) +idModel = constr(pattern=r"^[A-Za-z0-9\-\.]{1,64}$") +instantModel = constr( + pattern=r"^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))$" +) +integerModel = constr(pattern=r"^[0]|[-+]?[1-9][0-9]*$") +integer64Model = constr(pattern=r"^[0]|[-+]?[1-9][0-9]*$") +markdownModel = constr(pattern=r"^^[\s\S]+$$") +oidModel = constr(pattern=r"^urn:oid:[0-2](\.(0|[1-9][0-9]*))+$") +positiveIntModel = conint(strict=True, gt=0) +stringModel = constr(pattern=r"^^[\s\S]+$$") +timeModel = constr( + pattern=r"^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?$" +) +unsignedIntModel = constr(pattern=r"^[0]|([1-9][0-9]*)$") +uriModel = constr(pattern=r"^\S*$") +urlModel = constr(pattern=r"^\S*$") +uuidModel = constr( + pattern=r"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" +) + + +# TODO: Rename to primitives and move the models below to a separate file called General-purpose data types +class ExtensionModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + url_field: uriModel = Field( + default=None, + alias="url", + description="Source of the definition for the extension code - a logical name or a URL.", + ) + + +class PeriodModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + start_field: dateTimeModel = Field( + default=None, + alias="start", + description="The start of the period. The boundary is inclusive.", + ) + end_field: dateTimeModel = Field( + default=None, + alias="end", + description="The end of the period. If the end of the period is missing, it means no end was known or planned at the time the instance was created. The start may be in the past, and the end date in the future, which means that period is expected/planned to end at that time.", + ) + + +class IdentifierModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + # Identifier_use_field: useModel = Field(..., alias="use", description="The purpose of this identifier.") + type_field: CodeableConceptModel = Field( + default=None, + alias="type", + description="A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.", + ) + system_field: uriModel = Field( + default=None, + alias="system", + description="Establishes the namespace for the value - that is, an absolute URL that describes a set values that are unique.", + ) + value_field: stringModel = Field( + default=None, + alias="value", + description="The portion of the identifier typically relevant to the user and which is unique within the context of the system.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Time period during which identifier is/was valid for use.", + ) + assigner_field: ReferenceModel = Field( + default=None, + alias="assigner", + description="Organization that issued/manages the identifier.", + ) + + +class CodingModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + system_field: uriModel = Field( + default=None, + alias="system", + description="The identification of the code system that defines the meaning of the symbol in the code.", + ) + version_field: stringModel = Field( + default=None, + alias="version", + description="The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured, and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.", + ) + code_field: codeModel = Field( + default=None, + alias="code", + description="A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination).", + ) + display_field: stringModel = Field( + default=None, + alias="display", + description="A representation of the meaning of the code in the system, following the rules of the system.", + ) + userSelected_field: booleanModel = Field( + default=None, + alias="userSelected", + description="Indicates that this coding was chosen by a user directly - e.g. off a pick list of available items (codes or displays).", + ) + + +class CodeableConceptModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + coding_field: List[CodingModel] = Field( + default_factory=list, + alias="coding", + description="A reference to a code defined by a terminology system.", + ) + text_field: stringModel = Field( + default=None, + alias="text", + description="A human language representation of the concept as seen/selected/uttered by the user who entered the data and/or which represents the intended meaning of the user.", + ) + + +class ReferenceModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + reference_field: stringModel = Field( + default=None, + alias="reference", + description="A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.", + ) + type_field: uriModel = Field( + default=None, + alias="type", + description="The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.", + ) + identifier_field: IdentifierModel = Field( + default=None, + alias="identifier", + description="An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.", + ) + display_field: stringModel = Field( + default=None, + alias="display", + description="Plain text narrative that identifies the resource in addition to the resource reference.", + ) + + +class CodeableReferenceModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + concept_field: CodeableConceptModel = Field( + default=None, + alias="concept", + description="A reference to a concept - e.g. the information is identified by its general class to the degree of precision found in the terminology.", + ) + reference_field: ReferenceModel = Field( + default=None, + alias="reference", + description="A reference to a resource the provides exact details about the information being referenced.", + ) + + +class NarrativeModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + # Narrative_status_field: statusModel = Field(..., alias="status", description="The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data.") + div_field: stringModel = Field( + default=None, + alias="div", + description="The actual narrative content, a stripped down version of XHTML.", + ) diff --git a/healthchain/fhir_resources/encounter_resources.py b/healthchain/fhir_resources/encounter_resources.py new file mode 100644 index 0000000..2e82351 --- /dev/null +++ b/healthchain/fhir_resources/encounter_resources.py @@ -0,0 +1,359 @@ +from pydantic import BaseModel, Field +from typing import List +from healthchain.fhir_resources.base_resources import ( + stringModel, + idModel, + uriModel, + codeModel, + ExtensionModel, + IdentifierModel, + CodeableConceptModel, + ReferenceModel, + PeriodModel, + dateTimeModel, + CodeableReferenceModel, + NarrativeModel, +) + + +class Encounter_ParticipantModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + type_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="type", + description="Role of participant in encounter.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="The period of time that the specified participant participated in the encounter. These can overlap or be sub-sets of the overall encounter's period.", + ) + actor_field: ReferenceModel = Field( + default=None, + alias="actor", + description="Person involved in the encounter, the patient/group is also included here to indicate that the patient was actually participating in the encounter. Not including the patient here covers use cases such as a case meeting between practitioners about a patient - non contact times.", + ) + + +class Encounter_ReasonModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + use_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="use", + description="What the reason value should be used as e.g. Chief Complaint, Health Concern, Health Maintenance (including screening).", + ) + value_field: List[CodeableReferenceModel] = Field( + default_factory=list, + alias="value", + description="Reason the encounter takes place, expressed as a code or a reference to another resource. For admissions, this can be used for a coded admission diagnosis.", + ) + + +class Encounter_DiagnosisModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + condition_field: List[CodeableReferenceModel] = Field( + default_factory=list, + alias="condition", + description="The coded diagnosis or a reference to a Condition (with other resources referenced in the evidence.detail), the use property will indicate the purpose of this specific diagnosis.", + ) + use_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="use", + description="Role that this diagnosis has within the encounter (e.g. admission, billing, discharge …).", + ) + + +class Encounter_AdmissionModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + preAdmissionIdentifier_field: IdentifierModel = Field( + default=None, + alias="preAdmissionIdentifier", + description="Pre-admission identifier.", + ) + origin_field: ReferenceModel = Field( + default=None, + alias="origin", + description="The location/organization from which the patient came before admission.", + ) + admitSource_field: CodeableConceptModel = Field( + default=None, + alias="admitSource", + description="From where patient was admitted (physician referral, transfer).", + ) + reAdmission_field: CodeableConceptModel = Field( + default=None, + alias="reAdmission", + description="Indicates that this encounter is directly related to a prior admission, often because the conditions addressed in the prior admission were not fully addressed.", + ) + destination_field: ReferenceModel = Field( + default=None, + alias="destination", + description="Location/organization to which the patient is discharged.", + ) + dischargeDisposition_field: CodeableConceptModel = Field( + default=None, + alias="dischargeDisposition", + description="Category or kind of location after discharge.", + ) + + +class Encounter_LocationModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + location_field: ReferenceModel = Field( + default=None, + alias="location", + description="The location where the encounter takes place.", + ) + status_field: codeModel = Field( + default=None, + alias="status", + description="The status of the participants' presence at the specified location during the period specified. If the participant is no longer at the location, then the period will have an end date/time.", + ) + form_field: CodeableConceptModel = Field( + default=None, + alias="form", + description="This will be used to specify the required levels (bed/ward/room/etc.) desired to be recorded to simplify either messaging or query.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Time period during which the patient was present at the location.", + ) + + +class EncounterModel(BaseModel): + resourceType: str = "Encounter" + id_field: idModel = Field( + default=None, + alias="id", + description="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", + ) + # meta_field: MetaModel = Field(default=None, alias="meta", description="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.") + implicitRules_field: uriModel = Field( + default=None, + alias="implicitRules", + description="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", + ) + language_field: codeModel = Field( + default=None, + alias="language", + description="The base language in which the resource is written.", + ) + text_field: NarrativeModel = Field( + default=None, + alias="text", + description="A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it clinically safe for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.", + ) + # contained_field: List[ResourceListModel] = Field(default_factory=list, alias="contained", description="These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.") + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + identifier_field: List[IdentifierModel] = Field( + default_factory=list, + alias="identifier", + description="Identifier(s) by which this encounter is known.", + ) + status_field: codeModel = Field( + default=None, + alias="status", + description="The current state of the encounter (not the state of the patient within the encounter - that is subjectState).", + ) + class_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="class", + description="Concepts representing classification of patient encounter such as ambulatory (outpatient), inpatient, emergency, home health or others due to local variations.", + ) + priority_field: CodeableConceptModel = Field( + default=None, + alias="priority", + description="Indicates the urgency of the encounter.", + ) + type_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="type", + description="Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation).", + ) + serviceType_field: List[CodeableReferenceModel] = Field( + default_factory=list, + alias="serviceType", + description="Broad categorization of the service that is to be provided (e.g. cardiology).", + ) + subject_field: ReferenceModel = Field( + default=None, + alias="subject", + description="The patient or group related to this encounter. In some use-cases the patient MAY not be present, such as a case meeting about a patient between several practitioners or a careteam.", + ) + subjectStatus_field: CodeableConceptModel = Field( + default=None, + alias="subjectStatus", + description="The subjectStatus value can be used to track the patient's status within the encounter. It details whether the patient has arrived or departed, has been triaged or is currently in a waiting status.", + ) + episodeOfCare_field: List[ReferenceModel] = Field( + default_factory=list, + alias="episodeOfCare", + description="Where a specific encounter should be classified as a part of a specific episode(s) of care this field should be used. This association can facilitate grouping of related encounters together for a specific purpose, such as government reporting, issue tracking, association via a common problem. The association is recorded on the encounter as these are typically created after the episode of care and grouped on entry rather than editing the episode of care to append another encounter to it (the episode of care could span years).", + ) + basedOn_field: List[ReferenceModel] = Field( + default_factory=list, + alias="basedOn", + description="The request this encounter satisfies (e.g. incoming referral or procedure request).", + ) + careTeam_field: List[ReferenceModel] = Field( + default_factory=list, + alias="careTeam", + description="The group(s) of individuals, organizations that are allocated to participate in this encounter. The participants backbone will record the actuals of when these individuals participated during the encounter.", + ) + partOf_field: ReferenceModel = Field( + default=None, + alias="partOf", + description="Another Encounter of which this encounter is a part of (administratively or in time).", + ) + serviceProvider_field: ReferenceModel = Field( + default=None, + alias="serviceProvider", + description="The organization that is primarily responsible for this Encounter's services. This MAY be the same as the organization on the Patient record, however it could be different, such as if the actor performing the services was from an external organization (which may be billed seperately) for an external consultation. Refer to the colonoscopy example on the Encounter examples tab.", + ) + participant_field: List[Encounter_ParticipantModel] = Field( + default_factory=list, + alias="participant", + description="The list of people responsible for providing the service.", + ) + appointment_field: List[ReferenceModel] = Field( + default_factory=list, + alias="appointment", + description="The appointment that scheduled this encounter.", + ) + # virtualService_field: List[VirtualServiceDetailModel] = Field(default_factory=list, alias="virtualService", description="Connection details of a virtual service (e.g. conference call).") + actualPeriod_field: PeriodModel = Field( + default=None, + alias="actualPeriod", + description="The actual start and end time of the encounter.", + ) + plannedStartDate_field: dateTimeModel = Field( + default=None, + alias="plannedStartDate", + description="The planned start date/time (or admission date) of the encounter.", + ) + plannedEndDate_field: dateTimeModel = Field( + default=None, + alias="plannedEndDate", + description="The planned end date/time (or discharge date) of the encounter.", + ) + # length_field: DurationModel = Field(default=None, alias="length", description="Actual quantity of time the encounter lasted. This excludes the time during leaves of absence.") + reason_field: List[Encounter_ReasonModel] = Field( + default_factory=list, + alias="reason", + description="The list of medical reasons that are expected to be addressed during the episode of care.", + ) + diagnosis_field: List[Encounter_DiagnosisModel] = Field( + default_factory=list, + alias="diagnosis", + description="The list of diagnosis relevant to this encounter.", + ) + account_field: List[ReferenceModel] = Field( + default_factory=list, + alias="account", + description="The set of accounts that may be used for billing for this Encounter.", + ) + dietPreference_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="dietPreference", + description="Diet preferences reported by the patient.", + ) + specialArrangement_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="specialArrangement", + description="Any special requests that have been made for this encounter, such as the provision of specific equipment or other things.", + ) + specialCourtesy_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="specialCourtesy", + description="Special courtesies that may be provided to the patient during the encounter (VIP, board member, professional courtesy).", + ) + admission_field: Encounter_AdmissionModel = Field( + default=None, + alias="admission", + description="Details about the stay during which a healthcare service is provided.", + ) + location_field: List[Encounter_LocationModel] = Field( + default_factory=list, + alias="location", + description="List of locations where the patient has been during this encounter.", + ) diff --git a/healthchain/fhir_resources/patient_resources.py b/healthchain/fhir_resources/patient_resources.py new file mode 100644 index 0000000..f5db87e --- /dev/null +++ b/healthchain/fhir_resources/patient_resources.py @@ -0,0 +1,369 @@ +from pydantic import Field, BaseModel +from typing import List +from healthchain.fhir_resources.base_resources import ( + idModel, + uriModel, + codeModel, + booleanModel, + IdentifierModel, + ReferenceModel, + stringModel, + ExtensionModel, + PeriodModel, + positiveIntModel, + CodeableConceptModel, + dateModel, +) + + +class AddressModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + use_field: codeModel = Field( + default=None, alias="use", description="The purpose of this address." + ) + type_field: codeModel = Field( + default=None, + alias="type", + description="Distinguishes between physical addresses (those you can visit) and mailing addresses (e.g. PO Boxes and care-of addresses). Most addresses are both.", + ) + text_field: stringModel = Field( + default=None, + alias="text", + description="Specifies the entire address as it should be displayed e.g. on a postal label. This may be provided instead of or as well as the specific parts.", + ) + line_field: List[stringModel] = Field( + default_factory=list, + alias="line", + description="This component contains the house number, apartment number, street name, street direction, P.O. Box number, delivery hints, and similar address information.", + ) + city_field: stringModel = Field( + default=None, + alias="city", + description="The name of the city, town, suburb, village or other community or delivery center.", + ) + district_field: stringModel = Field( + default=None, + alias="district", + description="The name of the administrative area (county).", + ) + state_field: stringModel = Field( + default=None, + alias="state", + description="Sub-unit of a country with limited sovereignty in a federally organized country. A code may be used if codes are in common use (e.g. US 2 letter state codes).", + ) + postalCode_field: stringModel = Field( + default=None, + alias="postalCode", + description="A postal code designating a region defined by the postal service.", + ) + country_field: stringModel = Field( + default=None, + alias="country", + description="Country - a nation as commonly understood or generally accepted.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Time period when address was/is in use.", + ) + + +class ContactPointModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + system_field: codeModel = Field( + default=None, + alias="system", + description="Telecommunications form for contact point - what communications system is required to make use of the contact.", + ) + value_field: stringModel = Field( + default=None, + alias="value", + description="The actual contact point details, in a form that is meaningful to the designated communication system (i.e. phone number or email address).", + ) + use_field: codeModel = Field( + default=None, + alias="use", + description="Identifies the purpose for the contact point.", + ) + rank_field: positiveIntModel = Field( + default=None, + alias="rank", + description="Specifies a preferred order in which to use a set of contacts. ContactPoints with lower rank values are more preferred than those with higher rank values.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Time period when the contact point was/is in use.", + ) + + +class HumanNameModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + use_field: codeModel = Field( + default=None, alias="use", description="Identifies the purpose for this name." + ) + text_field: stringModel = Field( + default=None, + alias="text", + description="Specifies the entire name as it should be displayed e.g. on an application UI. This may be provided instead of or as well as the specific parts.", + ) + family_field: stringModel = Field( + default=None, + alias="family", + description="The part of a name that links to the genealogy. In some cultures (e.g. Eritrea) the family name of a son is the first name of his father.", + ) + given_field: List[stringModel] = Field( + default_factory=list, alias="given", description="Given name." + ) + prefix_field: List[stringModel] = Field( + default_factory=list, + alias="prefix", + description="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name.", + ) + suffix_field: List[stringModel] = Field( + default_factory=list, + alias="suffix", + description="Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the end of the name.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Indicates the period of time when this name was valid for the named person.", + ) + + +class Patient_LinkModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + other_field: ReferenceModel = Field( + default=None, + alias="other", + description="Link to a Patient or RelatedPerson resource that concerns the same actual individual.", + ) + type_field: codeModel = Field( + default=None, + alias="type", + description="The type of link between this patient resource and another patient resource.", + ) + + +class Patient_ContactModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + relationship_field: List[CodeableConceptModel] = Field( + default_factory=list, + alias="relationship", + description="The nature of the relationship between the patient and the contact person.", + ) + name_field: HumanNameModel = Field( + default=None, + alias="name", + description="A name associated with the contact person.", + ) + telecom_field: List[ContactPointModel] = Field( + default_factory=list, + alias="telecom", + description="A contact detail for the person, e.g. a telephone number or an email address.", + ) + address_field: AddressModel = Field( + default=None, alias="address", description="Address for the contact person." + ) + gender_field: codeModel = Field( + default=None, + alias="gender", + description="Administrative Gender - the gender that the contact person is considered to have for administration and record keeping purposes.", + ) + organization_field: ReferenceModel = Field( + default=None, + alias="organization", + description="Organization on behalf of which the contact is acting or for which the contact is working.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="The period during which this contact person or organization is valid to be contacted relating to this patient.", + ) + + +class Patient_CommunicationModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + language_field: CodeableConceptModel = Field( + default=None, + alias="language", + description="The ISO-639-1 alpha 2 code in lower case for the language, optionally followed by a hyphen and the ISO-3166-1 alpha 2 code for the region in upper case; e.g. en for English, or en-US for American English versus en-AU for Australian English.", + ) + preferred_field: booleanModel = Field( + default=None, + alias="preferred", + description="Indicates whether or not the patient prefers this language (over other languages he masters up a certain level).", + ) + + +class PatientModel(BaseModel): + resourceType: str = "Patient" + id_field: idModel = Field( + default=None, + alias="id", + description="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", + ) + # meta_field: MetaModel = Field(default=None, alias="meta", description="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.") + implicitRules_field: uriModel = Field( + default=None, + alias="implicitRules", + description="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", + ) + language_field: codeModel = Field( + default=None, + alias="language", + description="The base language in which the resource is written.", + ) + # NOTE: The text field has been switched to stringModel rather than NarrativeField for simplicity. + text_field: stringModel = Field( + default=None, + alias="text", + description="A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it clinically safe for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.", + ) + # contained_field: List[ResourceListModel] = Field(default_factory=list, alias="contained", description="These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.") + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + identifier_field: List[IdentifierModel] = Field( + default_factory=list, + alias="identifier", + description="An identifier for this patient.", + ) + active_field: booleanModel = Field( + default=None, + alias="active", + description="Whether this patient record is in active use. ", + ) + name_field: List[HumanNameModel] = Field( + default_factory=list, + alias="name", + description="A name associated with the individual.", + ) + telecom_field: List[ContactPointModel] = Field( + default_factory=list, + alias="telecom", + description="A contact detail (e.g. a telephone number or an email address) by which the individual may be contacted.", + ) + gender_field: codeModel = Field( + default=None, + alias="gender", + description="Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes.", + ) + birthDate_field: dateModel = Field( + default=None, + alias="birthDate", + description="The date of birth for the individual.", + ) + address_field: List[AddressModel] = Field( + default_factory=list, + alias="address", + description="An address for the individual.", + ) + maritalStatus_field: CodeableConceptModel = Field( + default=None, + alias="maritalStatus", + description="This field contains a patient's most recent marital (civil) status.", + ) + # photo_field: List[AttachmentModel] = Field(default_factory=list, alias="photo", description="Image of the patient.") + contact_field: List[Patient_ContactModel] = Field( + default_factory=list, + alias="contact", + description="A contact party (e.g. guardian, partner, friend) for the patient.", + ) + communication_field: List[Patient_CommunicationModel] = Field( + default_factory=list, + alias="communication", + description="A language which may be used to communicate with the patient about his or her health.", + ) + generalPractitioner_field: List[ReferenceModel] = Field( + default_factory=list, + alias="generalPractitioner", + description="Patient's nominated care provider.", + ) + managingOrganization_field: ReferenceModel = Field( + default=None, + alias="managingOrganization", + description="Organization that is the custodian of the patient record.", + ) + link_field: List[Patient_LinkModel] = Field( + default_factory=list, + alias="link", + description="Link to a Patient or RelatedPerson resource that concerns the same actual individual.", + ) diff --git a/healthchain/fhir_resources/practitioner_resources.py b/healthchain/fhir_resources/practitioner_resources.py new file mode 100644 index 0000000..10a0e42 --- /dev/null +++ b/healthchain/fhir_resources/practitioner_resources.py @@ -0,0 +1,168 @@ +from pydantic import Field, BaseModel +from typing import List +from healthchain.fhir_resources.base_resources import ( + idModel, + uriModel, + codeModel, + booleanModel, + IdentifierModel, + ReferenceModel, + stringModel, + ExtensionModel, + PeriodModel, + CodeableConceptModel, + dateModel, +) +from healthchain.fhir_resources.patient_resources import ( + HumanNameModel, + ContactPointModel, + AddressModel, +) + + +class Practitioner_QualificationModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + identifier_field: List[IdentifierModel] = Field( + default_factory=list, + alias="identifier", + description="An identifier that applies to this person's qualification.", + ) + code_field: CodeableConceptModel = Field( + default=None, + alias="code", + description="Coded representation of the qualification.", + ) + period_field: PeriodModel = Field( + default=None, + alias="period", + description="Period during which the qualification is valid.", + ) + issuer_field: ReferenceModel = Field( + default=None, + alias="issuer", + description="Organization that regulates and issues the qualification.", + ) + + +class Practitioner_CommunicationModel(BaseModel): + id_field: stringModel = Field( + default=None, + alias="id", + description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", + ) + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + language_field: CodeableConceptModel = Field( + default=None, + alias="language", + description="The ISO-639-1 alpha 2 code in lower case for the language, optionally followed by a hyphen and the ISO-3166-1 alpha 2 code for the region in upper case; e.g. en for English, or en-US for American English versus en-AU for Australian English.", + ) + preferred_field: booleanModel = Field( + default=None, + alias="preferred", + description="Indicates whether or not the person prefers this language (over other languages he masters up a certain level).", + ) + + +class PractitionerModel(BaseModel): + resourceType: str = "Practitioner" + id_field: idModel = Field( + default=None, + alias="id", + description="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.", + ) + # meta_field: MetaModel = Field(default=None, alias="meta", description="The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.") + implicitRules_field: uriModel = Field( + default=None, + alias="implicitRules", + description="A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.", + ) + language_field: codeModel = Field( + default=None, + alias="language", + description="The base language in which the resource is written.", + ) + text_field: stringModel = Field( + default=None, + alias="text", + description="A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it clinically safe for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.", + ) + # contained_field: List[ResourceListModel] = Field(default_factory=list, alias="contained", description="These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, nor can they have their own independent transaction scope. This is allowed to be a Parameters resource if and only if it is referenced by a resource that provides context/meaning.") + extension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="extension", + description="May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", + ) + modifierExtension_field: List[ExtensionModel] = Field( + default_factory=list, + alias="modifierExtension", + description="May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.", + ) + identifier_field: List[IdentifierModel] = Field( + default_factory=list, + alias="identifier", + description="An identifier that applies to this person in this role.", + ) + active_field: booleanModel = Field( + default=None, + alias="active", + description="Whether this practitioner's record is in active use.", + ) + name_field: List[HumanNameModel] = Field( + default_factory=list, + alias="name", + description="The name(s) associated with the practitioner.", + ) + telecom_field: List[ContactPointModel] = Field( + default_factory=list, + alias="telecom", + description="A contact detail for the practitioner, e.g. a telephone number or an email address.", + ) + gender_field: codeModel = Field( + default=None, + alias="gender", + description="Administrative Gender - the gender that the person is considered to have for administration and record keeping purposes.", + ) + birthDate_field: dateModel = Field( + default=None, + alias="birthDate", + description="The date of birth for the practitioner.", + ) + address_field: List[AddressModel] = Field( + default_factory=list, + alias="address", + description="Address(es) of the practitioner that are not role specific (typically home address). ", + ) + # photo_field: List[AttachmentModel] = Field(default_factory=list, alias="photo", description="Image of the person.") + qualification_field: List[Practitioner_QualificationModel] = Field( + default_factory=list, + alias="qualification", + description="The official qualifications, certifications, accreditations, training, licenses (and other types of educations/skills/capabilities) that authorize or otherwise pertain to the provision of care by the practitioner.", + ) + communication_field: List[Practitioner_CommunicationModel] = Field( + default_factory=list, + alias="communication", + description="A language which may be used to communicate with the practitioner, often for correspondence/administrative purposes.", + ) diff --git a/healthchain/fhir_resources/resource_registry.py b/healthchain/fhir_resources/resource_registry.py new file mode 100644 index 0000000..cb689cf --- /dev/null +++ b/healthchain/fhir_resources/resource_registry.py @@ -0,0 +1,166 @@ +from typing import Enum + + +class ImplementedResourceRegistry(Enum): + Bundle: str = "Bundle" + Encounter: str = "Encounter" + MedicationRequest: str = "MedicationRequest" + NutritionOrder: str = "NutritionOrder" + Patient: str = "Patient" + Practitioner: str = "Practitioner" + + +class UnimplementedResourceRegistry(Enum): + Account: str = "Account" + ActivityDefinition: str = "ActivityDefinition" + ActorDefinition: str = "ActorDefinition" + AdministrableProductDefinition: str = "AdministrableProductDefinition" + AdverseEvent: str = "AdverseEvent" + AllergyIntolerance: str = "AllergyIntolerance" + Appointment: str = "Appointment" + AppointmentResponse: str = "AppointmentResponse" + ArtifactAssessment: str = "ArtifactAssessment" + AuditEvent: str = "AuditEvent" + Basic: str = "Basic" + Binary: str = "Binary" + BiologicallyDerivedProduct: str = "BiologicallyDerivedProduct" + BiologicallyDerivedProductDispense: str = "BiologicallyDerivedProductDispense" + BodyStructure: str = "BodyStructure" + CapabilityStatement: str = "CapabilityStatement" + CarePlan: str = "CarePlan" + CareTeam: str = "CareTeam" + ChargeItem: str = "ChargeItem" + ChargeItemDefinition: str = "ChargeItemDefinition" + Citation: str = "Citation" + Claim: str = "Claim" + ClaimResponse: str = "ClaimResponse" + ClinicalImpression: str = "ClinicalImpression" + ClinicalUseDefinition: str = "ClinicalUseDefinition" + CodeSystem: str = "CodeSystem" + Communication: str = "Communication" + CommunicationRequest: str = "CommunicationRequest" + CompartmentDefinition: str = "CompartmentDefinition" + Composition: str = "Composition" + ConceptMap: str = "ConceptMap" + Condition: str = "Condition" + ConditionDefinition: str = "ConditionDefinition" + Consent: str = "Consent" + Contract: str = "Contract" + Coverage: str = "Coverage" + CoverageEligibilityRequest: str = "CoverageEligibilityRequest" + CoverageEligibilityResponse: str = "CoverageEligibilityResponse" + DetectedIssue: str = "DetectedIssue" + Device: str = "Device" + DeviceAssociation: str = "DeviceAssociation" + DeviceDefinition: str = "DeviceDefinition" + DeviceDispense: str = "DeviceDispense" + DeviceMetric: str = "DeviceMetric" + DeviceRequest: str = "DeviceRequest" + DeviceUsage: str = "DeviceUsage" + DiagnosticReport: str = "DiagnosticReport" + DocumentReference: str = "DocumentReference" + Encounter: str = "Encounter" + EncounterHistory: str = "EncounterHistory" + Endpoint: str = "Endpoint" + EnrollmentRequest: str = "EnrollmentRequest" + EnrollmentResponse: str = "EnrollmentResponse" + EpisodeOfCare: str = "EpisodeOfCare" + EventDefinition: str = "EventDefinition" + Evidence: str = "Evidence" + EvidenceReport: str = "EvidenceReport" + EvidenceVariable: str = "EvidenceVariable" + ExampleScenario: str = "ExampleScenario" + ExplanationOfBenefit: str = "ExplanationOfBenefit" + FamilyMemberHistory: str = "FamilyMemberHistory" + Flag: str = "Flag" + FormularyItem: str = "FormularyItem" + GenomicStudy: str = "GenomicStudy" + Goal: str = "Goal" + GraphDefinition: str = "GraphDefinition" + Group: str = "Group" + GuidanceResponse: str = "GuidanceResponse" + HealthcareService: str = "HealthcareService" + ImagingSelection: str = "ImagingSelection" + ImagingStudy: str = "ImagingStudy" + Immunization: str = "Immunization" + ImmunizationEvaluation: str = "ImmunizationEvaluation" + ImmunizationRecommendation: str = "ImmunizationRecommendation" + ImplementationGuide: str = "ImplementationGuide" + Ingredient: str = "Ingredient" + InsurancePlan: str = "InsurancePlan" + InventoryItem: str = "InventoryItem" + InventoryReport: str = "InventoryReport" + Invoice: str = "Invoice" + Library: str = "Library" + Linkage: str = "Linkage" + List: str = "List" + Location: str = "Location" + ManufacturedItemDefinition: str = "ManufacturedItemDefinition" + Measure: str = "Measure" + MeasureReport: str = "MeasureReport" + Medication: str = "Medication" + MedicationAdministration: str = "MedicationAdministration" + MedicationDispense: str = "MedicationDispense" + MedicationKnowledge: str = "MedicationKnowledge" + MedicationStatement: str = "MedicationStatement" + MedicinalProductDefinition: str = "MedicinalProductDefinition" + MessageDefinition: str = "MessageDefinition" + MessageHeader: str = "MessageHeader" + MolecularSequence: str = "MolecularSequence" + NamingSystem: str = "NamingSystem" + NutritionIntake: str = "NutritionIntake" + NutritionProduct: str = "NutritionProduct" + Observation: str = "Observation" + ObservationDefinition: str = "ObservationDefinition" + OperationDefinition: str = "OperationDefinition" + OperationOutcome: str = "OperationOutcome" + Organization: str = "Organization" + OrganizationAffiliation: str = "OrganizationAffiliation" + PackagedProductDefinition: str = "PackagedProductDefinition" + Parameters: str = "Parameters" + PaymentNotice: str = "PaymentNotice" + PaymentReconciliation: str = "PaymentReconciliation" + Permission: str = "Permission" + Person: str = "Person" + PlanDefinition: str = "PlanDefinition" + PractitionerRole: str = "PractitionerRole" + Procedure: str = "Procedure" + Provenance: str = "Provenance" + Questionnaire: str = "Questionnaire" + QuestionnaireResponse: str = "QuestionnaireResponse" + RegulatedAuthorization: str = "RegulatedAuthorization" + RelatedPerson: str = "RelatedPerson" + RequestOrchestration: str = "RequestOrchestration" + Requirements: str = "Requirements" + ResearchStudy: str = "ResearchStudy" + ResearchSubject: str = "ResearchSubject" + RiskAssessment: str = "RiskAssessment" + Schedule: str = "Schedule" + SearchParameter: str = "SearchParameter" + ServiceRequest: str = "ServiceRequest" + Slot: str = "Slot" + Specimen: str = "Specimen" + SpecimenDefinition: str = "SpecimenDefinition" + StructureDefinition: str = "StructureDefinition" + StructureMap: str = "StructureMap" + Subscription: str = "Subscription" + SubscriptionStatus: str = "SubscriptionStatus" + SubscriptionTopic: str = "SubscriptionTopic" + Substance: str = "Substance" + SubstanceDefinition: str = "SubstanceDefinition" + SubstanceNucleicAcid: str = "SubstanceNucleicAcid" + SubstancePolymer: str = "SubstancePolymer" + SubstanceProtein: str = "SubstanceProtein" + SubstanceReferenceInformation: str = "SubstanceReferenceInformation" + SubstanceSourceMaterial: str = "SubstanceSourceMaterial" + SupplyDelivery: str = "SupplyDelivery" + SupplyRequest: str = "SupplyRequest" + Task: str = "Task" + TerminologyCapabilities: str = "TerminologyCapabilities" + TestPlan: str = "TestPlan" + TestReport: str = "TestReport" + TestScript: str = "TestScript" + Transport: str = "Transport" + ValueSet: str = "ValueSet" + VerificationResult: str = "VerificationResult" + VisionPrescription: str = "VisionPrescription" diff --git a/poetry.lock b/poetry.lock index 23b4dea..0d8c541 100644 --- a/poetry.lock +++ b/poetry.lock @@ -306,6 +306,20 @@ files = [ dnspython = ">=2.0.0" idna = ">=2.0.0" +[[package]] +name = "faker" +version = "25.2.0" +description = "Faker is a Python package that generates fake data for you." +optional = false +python-versions = ">=3.8" +files = [ + {file = "Faker-25.2.0-py3-none-any.whl", hash = "sha256:cfe97c4857c4c36ee32ea4aaabef884895992e209bae4cbd26807cf3e05c6918"}, + {file = "Faker-25.2.0.tar.gz", hash = "sha256:45b84f47ff1ef86e3d1a8d11583ca871ecf6730fad0660edadc02576583a2423"}, +] + +[package.dependencies] +python-dateutil = ">=2.4" + [[package]] name = "fastapi" version = "0.111.0" @@ -822,13 +836,13 @@ files = [ [[package]] name = "platformdirs" -version = "4.2.1" +version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ - {file = "platformdirs-4.2.1-py3-none-any.whl", hash = "sha256:17d5a1161b3fd67b390023cb2d3b026bbd40abde6fdb052dfbd3a29c3ba22ee1"}, - {file = "platformdirs-4.2.1.tar.gz", hash = "sha256:031cd18d4ec63ec53e82dceaac0417d218a6863f7745dfcc9efe7793b7039bdf"}, + {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, + {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, ] [package.extras] @@ -853,13 +867,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.7.0" +version = "3.7.1" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false python-versions = ">=3.9" files = [ - {file = "pre_commit-3.7.0-py2.py3-none-any.whl", hash = "sha256:5eae9e10c2b5ac51577c3452ec0a490455c45a0533f7960f993a0d01e59decab"}, - {file = "pre_commit-3.7.0.tar.gz", hash = "sha256:e209d61b8acdcf742404408531f0c37d49d2c734fd7cff2d6076083d191cb060"}, + {file = "pre_commit-3.7.1-py2.py3-none-any.whl", hash = "sha256:fae36fd1d7ad7d6a5a1c0b0d5adb2ed1a3bda5a21bf6c3e5372073d7a11cd4c5"}, + {file = "pre_commit-3.7.1.tar.gz", hash = "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a"}, ] [package.dependencies] @@ -1106,7 +1120,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1196,28 +1209,28 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.4.3" +version = "0.4.4" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.4.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b70800c290f14ae6fcbb41bbe201cf62dfca024d124a1f373e76371a007454ce"}, - {file = "ruff-0.4.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:08a0d6a22918ab2552ace96adeaca308833873a4d7d1d587bb1d37bae8728eb3"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eba1f14df3c758dd7de5b55fbae7e1c8af238597961e5fb628f3de446c3c40c5"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:819fb06d535cc76dfddbfe8d3068ff602ddeb40e3eacbc90e0d1272bb8d97113"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bfc9e955e6dc6359eb6f82ea150c4f4e82b660e5b58d9a20a0e42ec3bb6342b"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:510a67d232d2ebe983fddea324dbf9d69b71c4d2dfeb8a862f4a127536dd4cfb"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc9ff11cd9a092ee7680a56d21f302bdda14327772cd870d806610a3503d001f"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:29efff25bf9ee685c2c8390563a5b5c006a3fee5230d28ea39f4f75f9d0b6f2f"}, - {file = "ruff-0.4.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18b00e0bcccf0fc8d7186ed21e311dffd19761cb632241a6e4fe4477cc80ef6e"}, - {file = "ruff-0.4.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:262f5635e2c74d80b7507fbc2fac28fe0d4fef26373bbc62039526f7722bca1b"}, - {file = "ruff-0.4.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7363691198719c26459e08cc17c6a3dac6f592e9ea3d2fa772f4e561b5fe82a3"}, - {file = "ruff-0.4.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:eeb039f8428fcb6725bb63cbae92ad67b0559e68b5d80f840f11914afd8ddf7f"}, - {file = "ruff-0.4.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:927b11c1e4d0727ce1a729eace61cee88a334623ec424c0b1c8fe3e5f9d3c865"}, - {file = "ruff-0.4.3-py3-none-win32.whl", hash = "sha256:25cacda2155778beb0d064e0ec5a3944dcca9c12715f7c4634fd9d93ac33fd30"}, - {file = "ruff-0.4.3-py3-none-win_amd64.whl", hash = "sha256:7a1c3a450bc6539ef00da6c819fb1b76b6b065dec585f91456e7c0d6a0bbc725"}, - {file = "ruff-0.4.3-py3-none-win_arm64.whl", hash = "sha256:71ca5f8ccf1121b95a59649482470c5601c60a416bf189d553955b0338e34614"}, - {file = "ruff-0.4.3.tar.gz", hash = "sha256:ff0a3ef2e3c4b6d133fbedcf9586abfbe38d076041f2dc18ffb2c7e0485d5a07"}, + {file = "ruff-0.4.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:29d44ef5bb6a08e235c8249294fa8d431adc1426bfda99ed493119e6f9ea1bf6"}, + {file = "ruff-0.4.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:c4efe62b5bbb24178c950732ddd40712b878a9b96b1d02b0ff0b08a090cbd891"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c8e2f1e8fc12d07ab521a9005d68a969e167b589cbcaee354cb61e9d9de9c15"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:60ed88b636a463214905c002fa3eaab19795679ed55529f91e488db3fe8976ab"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b90fc5e170fc71c712cc4d9ab0e24ea505c6a9e4ebf346787a67e691dfb72e85"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:8e7e6ebc10ef16dcdc77fd5557ee60647512b400e4a60bdc4849468f076f6eef"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b9ddb2c494fb79fc208cd15ffe08f32b7682519e067413dbaf5f4b01a6087bcd"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c51c928a14f9f0a871082603e25a1588059b7e08a920f2f9fa7157b5bf08cfe9"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b5eb0a4bfd6400b7d07c09a7725e1a98c3b838be557fee229ac0f84d9aa49c36"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b1867ee9bf3acc21778dcb293db504692eda5f7a11a6e6cc40890182a9f9e595"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1aecced1269481ef2894cc495647392a34b0bf3e28ff53ed95a385b13aa45768"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9da73eb616b3241a307b837f32756dc20a0b07e2bcb694fec73699c93d04a69e"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:958b4ea5589706a81065e2a776237de2ecc3e763342e5cc8e02a4a4d8a5e6f95"}, + {file = "ruff-0.4.4-py3-none-win32.whl", hash = "sha256:cb53473849f011bca6e754f2cdf47cafc9c4f4ff4570003a0dad0b9b6890e876"}, + {file = "ruff-0.4.4-py3-none-win_amd64.whl", hash = "sha256:424e5b72597482543b684c11def82669cc6b395aa8cc69acc1858b5ef3e5daae"}, + {file = "ruff-0.4.4-py3-none-win_arm64.whl", hash = "sha256:39df0537b47d3b597293edbb95baf54ff5b49589eb7ff41926d8243caa995ea6"}, + {file = "ruff-0.4.4.tar.gz", hash = "sha256:f87ea42d5cdebdc6a69761a9d0bc83ae9b3b30d0ad78952005ba6568d6c022af"}, ] [[package]] @@ -1299,13 +1312,13 @@ full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.7 [[package]] name = "trio" -version = "0.25.0" +version = "0.25.1" description = "A friendly Python library for async concurrency and I/O" optional = false python-versions = ">=3.8" files = [ - {file = "trio-0.25.0-py3-none-any.whl", hash = "sha256:e6458efe29cc543e557a91e614e2b51710eba2961669329ce9c862d50c6e8e81"}, - {file = "trio-0.25.0.tar.gz", hash = "sha256:9b41f5993ad2c0e5f62d0acca320ec657fdb6b2a2c22b8c7aed6caf154475c4e"}, + {file = "trio-0.25.1-py3-none-any.whl", hash = "sha256:e42617ba091e7b2e50c899052e83a3c403101841de925187f61e7b7eaebdf3fb"}, + {file = "trio-0.25.1.tar.gz", hash = "sha256:9f5314f014ea3af489e77b001861c535005c3858d38ec46b6b071ebfa339d7fb"}, ] [package.dependencies] @@ -1346,76 +1359,89 @@ files = [ [[package]] name = "ujson" -version = "5.9.0" +version = "5.10.0" description = "Ultra fast JSON encoder and decoder for Python" optional = false python-versions = ">=3.8" files = [ - {file = "ujson-5.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ab71bf27b002eaf7d047c54a68e60230fbd5cd9da60de7ca0aa87d0bccead8fa"}, - {file = "ujson-5.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:7a365eac66f5aa7a7fdf57e5066ada6226700884fc7dce2ba5483538bc16c8c5"}, - {file = "ujson-5.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e015122b337858dba5a3dc3533af2a8fc0410ee9e2374092f6a5b88b182e9fcc"}, - {file = "ujson-5.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:779a2a88c53039bebfbccca934430dabb5c62cc179e09a9c27a322023f363e0d"}, - {file = "ujson-5.9.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:10ca3c41e80509fd9805f7c149068fa8dbee18872bbdc03d7cca928926a358d5"}, - {file = "ujson-5.9.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4a566e465cb2fcfdf040c2447b7dd9718799d0d90134b37a20dff1e27c0e9096"}, - {file = "ujson-5.9.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:f833c529e922577226a05bc25b6a8b3eb6c4fb155b72dd88d33de99d53113124"}, - {file = "ujson-5.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b68a0caab33f359b4cbbc10065c88e3758c9f73a11a65a91f024b2e7a1257106"}, - {file = "ujson-5.9.0-cp310-cp310-win32.whl", hash = "sha256:7cc7e605d2aa6ae6b7321c3ae250d2e050f06082e71ab1a4200b4ae64d25863c"}, - {file = "ujson-5.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:a6d3f10eb8ccba4316a6b5465b705ed70a06011c6f82418b59278fbc919bef6f"}, - {file = "ujson-5.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3b23bbb46334ce51ddb5dded60c662fbf7bb74a37b8f87221c5b0fec1ec6454b"}, - {file = "ujson-5.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6974b3a7c17bbf829e6c3bfdc5823c67922e44ff169851a755eab79a3dd31ec0"}, - {file = "ujson-5.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b5964ea916edfe24af1f4cc68488448fbb1ec27a3ddcddc2b236da575c12c8ae"}, - {file = "ujson-5.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8ba7cac47dd65ff88571eceeff48bf30ed5eb9c67b34b88cb22869b7aa19600d"}, - {file = "ujson-5.9.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6bbd91a151a8f3358c29355a491e915eb203f607267a25e6ab10531b3b157c5e"}, - {file = "ujson-5.9.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:829a69d451a49c0de14a9fecb2a2d544a9b2c884c2b542adb243b683a6f15908"}, - {file = "ujson-5.9.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:a807ae73c46ad5db161a7e883eec0fbe1bebc6a54890152ccc63072c4884823b"}, - {file = "ujson-5.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8fc2aa18b13d97b3c8ccecdf1a3c405f411a6e96adeee94233058c44ff92617d"}, - {file = "ujson-5.9.0-cp311-cp311-win32.whl", hash = "sha256:70e06849dfeb2548be48fdd3ceb53300640bc8100c379d6e19d78045e9c26120"}, - {file = "ujson-5.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:7309d063cd392811acc49b5016728a5e1b46ab9907d321ebbe1c2156bc3c0b99"}, - {file = "ujson-5.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:20509a8c9f775b3a511e308bbe0b72897ba6b800767a7c90c5cca59d20d7c42c"}, - {file = "ujson-5.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b28407cfe315bd1b34f1ebe65d3bd735d6b36d409b334100be8cdffae2177b2f"}, - {file = "ujson-5.9.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d302bd17989b6bd90d49bade66943c78f9e3670407dbc53ebcf61271cadc399"}, - {file = "ujson-5.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f21315f51e0db8ee245e33a649dd2d9dce0594522de6f278d62f15f998e050e"}, - {file = "ujson-5.9.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5635b78b636a54a86fdbf6f027e461aa6c6b948363bdf8d4fbb56a42b7388320"}, - {file = "ujson-5.9.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:82b5a56609f1235d72835ee109163c7041b30920d70fe7dac9176c64df87c164"}, - {file = "ujson-5.9.0-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:5ca35f484622fd208f55041b042d9d94f3b2c9c5add4e9af5ee9946d2d30db01"}, - {file = "ujson-5.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:829b824953ebad76d46e4ae709e940bb229e8999e40881338b3cc94c771b876c"}, - {file = "ujson-5.9.0-cp312-cp312-win32.whl", hash = "sha256:25fa46e4ff0a2deecbcf7100af3a5d70090b461906f2299506485ff31d9ec437"}, - {file = "ujson-5.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:60718f1720a61560618eff3b56fd517d107518d3c0160ca7a5a66ac949c6cf1c"}, - {file = "ujson-5.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d581db9db9e41d8ea0b2705c90518ba623cbdc74f8d644d7eb0d107be0d85d9c"}, - {file = "ujson-5.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ff741a5b4be2d08fceaab681c9d4bc89abf3c9db600ab435e20b9b6d4dfef12e"}, - {file = "ujson-5.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cdcb02cabcb1e44381221840a7af04433c1dc3297af76fde924a50c3054c708c"}, - {file = "ujson-5.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e208d3bf02c6963e6ef7324dadf1d73239fb7008491fdf523208f60be6437402"}, - {file = "ujson-5.9.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f4b3917296630a075e04d3d07601ce2a176479c23af838b6cf90a2d6b39b0d95"}, - {file = "ujson-5.9.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:0c4d6adb2c7bb9eb7c71ad6f6f612e13b264942e841f8cc3314a21a289a76c4e"}, - {file = "ujson-5.9.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:0b159efece9ab5c01f70b9d10bbb77241ce111a45bc8d21a44c219a2aec8ddfd"}, - {file = "ujson-5.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f0cb4a7814940ddd6619bdce6be637a4b37a8c4760de9373bac54bb7b229698b"}, - {file = "ujson-5.9.0-cp38-cp38-win32.whl", hash = "sha256:dc80f0f5abf33bd7099f7ac94ab1206730a3c0a2d17549911ed2cb6b7aa36d2d"}, - {file = "ujson-5.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:506a45e5fcbb2d46f1a51fead991c39529fc3737c0f5d47c9b4a1d762578fc30"}, - {file = "ujson-5.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d0fd2eba664a22447102062814bd13e63c6130540222c0aa620701dd01f4be81"}, - {file = "ujson-5.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bdf7fc21a03bafe4ba208dafa84ae38e04e5d36c0e1c746726edf5392e9f9f36"}, - {file = "ujson-5.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e2f909bc08ce01f122fd9c24bc6f9876aa087188dfaf3c4116fe6e4daf7e194f"}, - {file = "ujson-5.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd4ea86c2afd41429751d22a3ccd03311c067bd6aeee2d054f83f97e41e11d8f"}, - {file = "ujson-5.9.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:63fb2e6599d96fdffdb553af0ed3f76b85fda63281063f1cb5b1141a6fcd0617"}, - {file = "ujson-5.9.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:32bba5870c8fa2a97f4a68f6401038d3f1922e66c34280d710af00b14a3ca562"}, - {file = "ujson-5.9.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:37ef92e42535a81bf72179d0e252c9af42a4ed966dc6be6967ebfb929a87bc60"}, - {file = "ujson-5.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f69f16b8f1c69da00e38dc5f2d08a86b0e781d0ad3e4cc6a13ea033a439c4844"}, - {file = "ujson-5.9.0-cp39-cp39-win32.whl", hash = "sha256:3382a3ce0ccc0558b1c1668950008cece9bf463ebb17463ebf6a8bfc060dae34"}, - {file = "ujson-5.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:6adef377ed583477cf005b58c3025051b5faa6b8cc25876e594afbb772578f21"}, - {file = "ujson-5.9.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:ffdfebd819f492e48e4f31c97cb593b9c1a8251933d8f8972e81697f00326ff1"}, - {file = "ujson-5.9.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c4eec2ddc046360d087cf35659c7ba0cbd101f32035e19047013162274e71fcf"}, - {file = "ujson-5.9.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fbb90aa5c23cb3d4b803c12aa220d26778c31b6e4b7a13a1f49971f6c7d088e"}, - {file = "ujson-5.9.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba0823cb70866f0d6a4ad48d998dd338dce7314598721bc1b7986d054d782dfd"}, - {file = "ujson-5.9.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:4e35d7885ed612feb6b3dd1b7de28e89baaba4011ecdf995e88be9ac614765e9"}, - {file = "ujson-5.9.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:b048aa93eace8571eedbd67b3766623e7f0acbf08ee291bef7d8106210432427"}, - {file = "ujson-5.9.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:323279e68c195110ef85cbe5edce885219e3d4a48705448720ad925d88c9f851"}, - {file = "ujson-5.9.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9ac92d86ff34296f881e12aa955f7014d276895e0e4e868ba7fddebbde38e378"}, - {file = "ujson-5.9.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:6eecbd09b316cea1fd929b1e25f70382917542ab11b692cb46ec9b0a26c7427f"}, - {file = "ujson-5.9.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:473fb8dff1d58f49912323d7cb0859df5585cfc932e4b9c053bf8cf7f2d7c5c4"}, - {file = "ujson-5.9.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f91719c6abafe429c1a144cfe27883eace9fb1c09a9c5ef1bcb3ae80a3076a4e"}, - {file = "ujson-5.9.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b1c0991c4fe256f5fdb19758f7eac7f47caac29a6c57d0de16a19048eb86bad"}, - {file = "ujson-5.9.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2a8ea0f55a1396708e564595aaa6696c0d8af532340f477162ff6927ecc46e21"}, - {file = "ujson-5.9.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:07e0cfdde5fd91f54cd2d7ffb3482c8ff1bf558abf32a8b953a5d169575ae1cd"}, - {file = "ujson-5.9.0.tar.gz", hash = "sha256:89cc92e73d5501b8a7f48575eeb14ad27156ad092c2e9fc7e3cf949f07e75532"}, + {file = "ujson-5.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2601aa9ecdbee1118a1c2065323bda35e2c5a2cf0797ef4522d485f9d3ef65bd"}, + {file = "ujson-5.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:348898dd702fc1c4f1051bc3aacbf894caa0927fe2c53e68679c073375f732cf"}, + {file = "ujson-5.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22cffecf73391e8abd65ef5f4e4dd523162a3399d5e84faa6aebbf9583df86d6"}, + {file = "ujson-5.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26b0e2d2366543c1bb4fbd457446f00b0187a2bddf93148ac2da07a53fe51569"}, + {file = "ujson-5.10.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:caf270c6dba1be7a41125cd1e4fc7ba384bf564650beef0df2dd21a00b7f5770"}, + {file = "ujson-5.10.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a245d59f2ffe750446292b0094244df163c3dc96b3ce152a2c837a44e7cda9d1"}, + {file = "ujson-5.10.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:94a87f6e151c5f483d7d54ceef83b45d3a9cca7a9cb453dbdbb3f5a6f64033f5"}, + {file = "ujson-5.10.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:29b443c4c0a113bcbb792c88bea67b675c7ca3ca80c3474784e08bba01c18d51"}, + {file = "ujson-5.10.0-cp310-cp310-win32.whl", hash = "sha256:c18610b9ccd2874950faf474692deee4223a994251bc0a083c114671b64e6518"}, + {file = "ujson-5.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:924f7318c31874d6bb44d9ee1900167ca32aa9b69389b98ecbde34c1698a250f"}, + {file = "ujson-5.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a5b366812c90e69d0f379a53648be10a5db38f9d4ad212b60af00bd4048d0f00"}, + {file = "ujson-5.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:502bf475781e8167f0f9d0e41cd32879d120a524b22358e7f205294224c71126"}, + {file = "ujson-5.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b91b5d0d9d283e085e821651184a647699430705b15bf274c7896f23fe9c9d8"}, + {file = "ujson-5.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:129e39af3a6d85b9c26d5577169c21d53821d8cf68e079060602e861c6e5da1b"}, + {file = "ujson-5.10.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f77b74475c462cb8b88680471193064d3e715c7c6074b1c8c412cb526466efe9"}, + {file = "ujson-5.10.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7ec0ca8c415e81aa4123501fee7f761abf4b7f386aad348501a26940beb1860f"}, + {file = "ujson-5.10.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:ab13a2a9e0b2865a6c6db9271f4b46af1c7476bfd51af1f64585e919b7c07fd4"}, + {file = "ujson-5.10.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:57aaf98b92d72fc70886b5a0e1a1ca52c2320377360341715dd3933a18e827b1"}, + {file = "ujson-5.10.0-cp311-cp311-win32.whl", hash = "sha256:2987713a490ceb27edff77fb184ed09acdc565db700ee852823c3dc3cffe455f"}, + {file = "ujson-5.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:f00ea7e00447918ee0eff2422c4add4c5752b1b60e88fcb3c067d4a21049a720"}, + {file = "ujson-5.10.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:98ba15d8cbc481ce55695beee9f063189dce91a4b08bc1d03e7f0152cd4bbdd5"}, + {file = "ujson-5.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a9d2edbf1556e4f56e50fab7d8ff993dbad7f54bac68eacdd27a8f55f433578e"}, + {file = "ujson-5.10.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6627029ae4f52d0e1a2451768c2c37c0c814ffc04f796eb36244cf16b8e57043"}, + {file = "ujson-5.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f8ccb77b3e40b151e20519c6ae6d89bfe3f4c14e8e210d910287f778368bb3d1"}, + {file = "ujson-5.10.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f3caf9cd64abfeb11a3b661329085c5e167abbe15256b3b68cb5d914ba7396f3"}, + {file = "ujson-5.10.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6e32abdce572e3a8c3d02c886c704a38a1b015a1fb858004e03d20ca7cecbb21"}, + {file = "ujson-5.10.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:a65b6af4d903103ee7b6f4f5b85f1bfd0c90ba4eeac6421aae436c9988aa64a2"}, + {file = "ujson-5.10.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:604a046d966457b6cdcacc5aa2ec5314f0e8c42bae52842c1e6fa02ea4bda42e"}, + {file = "ujson-5.10.0-cp312-cp312-win32.whl", hash = "sha256:6dea1c8b4fc921bf78a8ff00bbd2bfe166345f5536c510671bccececb187c80e"}, + {file = "ujson-5.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:38665e7d8290188b1e0d57d584eb8110951a9591363316dd41cf8686ab1d0abc"}, + {file = "ujson-5.10.0-cp313-cp313-macosx_10_9_x86_64.whl", hash = "sha256:618efd84dc1acbd6bff8eaa736bb6c074bfa8b8a98f55b61c38d4ca2c1f7f287"}, + {file = "ujson-5.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:38d5d36b4aedfe81dfe251f76c0467399d575d1395a1755de391e58985ab1c2e"}, + {file = "ujson-5.10.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:67079b1f9fb29ed9a2914acf4ef6c02844b3153913eb735d4bf287ee1db6e557"}, + {file = "ujson-5.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7d0e0ceeb8fe2468c70ec0c37b439dd554e2aa539a8a56365fd761edb418988"}, + {file = "ujson-5.10.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:59e02cd37bc7c44d587a0ba45347cc815fb7a5fe48de16bf05caa5f7d0d2e816"}, + {file = "ujson-5.10.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:2a890b706b64e0065f02577bf6d8ca3b66c11a5e81fb75d757233a38c07a1f20"}, + {file = "ujson-5.10.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:621e34b4632c740ecb491efc7f1fcb4f74b48ddb55e65221995e74e2d00bbff0"}, + {file = "ujson-5.10.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:b9500e61fce0cfc86168b248104e954fead61f9be213087153d272e817ec7b4f"}, + {file = "ujson-5.10.0-cp313-cp313-win32.whl", hash = "sha256:4c4fc16f11ac1612f05b6f5781b384716719547e142cfd67b65d035bd85af165"}, + {file = "ujson-5.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:4573fd1695932d4f619928fd09d5d03d917274381649ade4328091ceca175539"}, + {file = "ujson-5.10.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a984a3131da7f07563057db1c3020b1350a3e27a8ec46ccbfbf21e5928a43050"}, + {file = "ujson-5.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:73814cd1b9db6fc3270e9d8fe3b19f9f89e78ee9d71e8bd6c9a626aeaeaf16bd"}, + {file = "ujson-5.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:61e1591ed9376e5eddda202ec229eddc56c612b61ac6ad07f96b91460bb6c2fb"}, + {file = "ujson-5.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2c75269f8205b2690db4572a4a36fe47cd1338e4368bc73a7a0e48789e2e35a"}, + {file = "ujson-5.10.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7223f41e5bf1f919cd8d073e35b229295aa8e0f7b5de07ed1c8fddac63a6bc5d"}, + {file = "ujson-5.10.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:d4dc2fd6b3067c0782e7002ac3b38cf48608ee6366ff176bbd02cf969c9c20fe"}, + {file = "ujson-5.10.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:232cc85f8ee3c454c115455195a205074a56ff42608fd6b942aa4c378ac14dd7"}, + {file = "ujson-5.10.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:cc6139531f13148055d691e442e4bc6601f6dba1e6d521b1585d4788ab0bfad4"}, + {file = "ujson-5.10.0-cp38-cp38-win32.whl", hash = "sha256:e7ce306a42b6b93ca47ac4a3b96683ca554f6d35dd8adc5acfcd55096c8dfcb8"}, + {file = "ujson-5.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:e82d4bb2138ab05e18f089a83b6564fee28048771eb63cdecf4b9b549de8a2cc"}, + {file = "ujson-5.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:dfef2814c6b3291c3c5f10065f745a1307d86019dbd7ea50e83504950136ed5b"}, + {file = "ujson-5.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4734ee0745d5928d0ba3a213647f1c4a74a2a28edc6d27b2d6d5bd9fa4319e27"}, + {file = "ujson-5.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d47ebb01bd865fdea43da56254a3930a413f0c5590372a1241514abae8aa7c76"}, + {file = "ujson-5.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dee5e97c2496874acbf1d3e37b521dd1f307349ed955e62d1d2f05382bc36dd5"}, + {file = "ujson-5.10.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7490655a2272a2d0b072ef16b0b58ee462f4973a8f6bbe64917ce5e0a256f9c0"}, + {file = "ujson-5.10.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ba17799fcddaddf5c1f75a4ba3fd6441f6a4f1e9173f8a786b42450851bd74f1"}, + {file = "ujson-5.10.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:2aff2985cef314f21d0fecc56027505804bc78802c0121343874741650a4d3d1"}, + {file = "ujson-5.10.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:ad88ac75c432674d05b61184178635d44901eb749786c8eb08c102330e6e8996"}, + {file = "ujson-5.10.0-cp39-cp39-win32.whl", hash = "sha256:2544912a71da4ff8c4f7ab5606f947d7299971bdd25a45e008e467ca638d13c9"}, + {file = "ujson-5.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:3ff201d62b1b177a46f113bb43ad300b424b7847f9c5d38b1b4ad8f75d4a282a"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:5b6fee72fa77dc172a28f21693f64d93166534c263adb3f96c413ccc85ef6e64"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:61d0af13a9af01d9f26d2331ce49bb5ac1fb9c814964018ac8df605b5422dcb3"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecb24f0bdd899d368b715c9e6664166cf694d1e57be73f17759573a6986dd95a"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fbd8fd427f57a03cff3ad6574b5e299131585d9727c8c366da4624a9069ed746"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:beeaf1c48e32f07d8820c705ff8e645f8afa690cca1544adba4ebfa067efdc88"}, + {file = "ujson-5.10.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:baed37ea46d756aca2955e99525cc02d9181de67f25515c468856c38d52b5f3b"}, + {file = "ujson-5.10.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:7663960f08cd5a2bb152f5ee3992e1af7690a64c0e26d31ba7b3ff5b2ee66337"}, + {file = "ujson-5.10.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:d8640fb4072d36b08e95a3a380ba65779d356b2fee8696afeb7794cf0902d0a1"}, + {file = "ujson-5.10.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78778a3aa7aafb11e7ddca4e29f46bc5139131037ad628cc10936764282d6753"}, + {file = "ujson-5.10.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b0111b27f2d5c820e7f2dbad7d48e3338c824e7ac4d2a12da3dc6061cc39c8e6"}, + {file = "ujson-5.10.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:c66962ca7565605b355a9ed478292da628b8f18c0f2793021ca4425abf8b01e5"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:ba43cc34cce49cf2d4bc76401a754a81202d8aa926d0e2b79f0ee258cb15d3a4"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:ac56eb983edce27e7f51d05bc8dd820586c6e6be1c5216a6809b0c668bb312b8"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f44bd4b23a0e723bf8b10628288c2c7c335161d6840013d4d5de20e48551773b"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7c10f4654e5326ec14a46bcdeb2b685d4ada6911050aa8baaf3501e57024b804"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0de4971a89a762398006e844ae394bd46991f7c385d7a6a3b93ba229e6dac17e"}, + {file = "ujson-5.10.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:e1402f0564a97d2a52310ae10a64d25bcef94f8dd643fcf5d310219d915484f7"}, + {file = "ujson-5.10.0.tar.gz", hash = "sha256:b3cd8f3c5d8c7738257f1018880444f7b7d9b66232c64649f562d7ba86ad4bc1"}, ] [[package]] @@ -1506,13 +1532,13 @@ test = ["Cython (>=0.29.36,<0.30.0)", "aiohttp (==3.9.0b0)", "aiohttp (>=3.8.1)" [[package]] name = "virtualenv" -version = "20.26.1" +version = "20.26.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"}, - {file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"}, + {file = "virtualenv-20.26.2-py3-none-any.whl", hash = "sha256:a624db5e94f01ad993d476b9ee5346fdf7b9de43ccaee0e0197012dc838a0e9b"}, + {file = "virtualenv-20.26.2.tar.gz", hash = "sha256:82bf0f4eebbb78d36ddaee0283d43fe5736b53880b8a8cdcd37390a07ac3741c"}, ] [package.dependencies] @@ -1736,4 +1762,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "cd59bbc208cd6244560391965b78b84df26a19092e29fc7459c73cfcfd3aab69" +content-hash = "93f55c659874518d1b8d41141bf6ed9bef198c86878b3988e6dd976be9731cba" diff --git a/pyproject.toml b/pyproject.toml index e663d2a..6f12fed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ pydantic = "^2.7.1" requests = "^2.31.0" colorama = "^0.4.6" fastapi = "^0.111.0" +faker = "^25.1.0" [tool.poetry.group.dev.dependencies] ruff = "^0.4.2" diff --git a/tests/fhir_resources_unit_tests/test_fhir_resources_base.py b/tests/fhir_resources_unit_tests/test_fhir_resources_base.py new file mode 100644 index 0000000..83d9b23 --- /dev/null +++ b/tests/fhir_resources_unit_tests/test_fhir_resources_base.py @@ -0,0 +1,59 @@ +from pydantic import ValidationError +import pytest +from pydantic import BaseModel +from healthchain.fhir_resources.base_resources import ( + booleanModel, + canonicalModel, + codeModel, +) + + +class booleanTestModel(BaseModel): + my_bool: booleanModel + + +def test_boolean_valid(): + data = {"my_bool": "true"} + result = booleanTestModel(**data) + assert result.my_bool == "true" + + +def test_boolean_invalid(): + data = {"my_bool": "invalid"} + with pytest.raises(ValidationError): + booleanTestModel(**data) + + +class canonicalTestModel(BaseModel): + my_canonical: canonicalModel + + +def test_canonical_valid(): + data = {"my_canonical": "https://example.com"} + result = canonicalTestModel(**data) + assert result.my_canonical == "https://example.com" + + +def test_canonical_invalid(): + data = {"my_canonical": "invalid url"} + with pytest.raises(ValidationError): + canonicalTestModel(**data) + + +class codeTestModel(BaseModel): + my_code: codeModel + + +def test_code_valid(): + data = {"my_code": "ABC123"} + result = codeTestModel(**data) + assert result.my_code == "ABC123" + + +def test_code_invalid(): + data = {"my_code": "invalid code"} + with pytest.raises(ValidationError): + codeTestModel(**data) + + +# TODO: Add tests for the remaining base resources diff --git a/tests/fhir_resources_unit_tests/test_fhir_resources_patient.py b/tests/fhir_resources_unit_tests/test_fhir_resources_patient.py new file mode 100644 index 0000000..b29c0de --- /dev/null +++ b/tests/fhir_resources_unit_tests/test_fhir_resources_patient.py @@ -0,0 +1,79 @@ +import pytest +from healthchain.fhir_resources.patient_resources import ( + PatientModel, + HumanNameModel, + ContactPointModel, + AddressModel, +) + + +# TODO: Refactor pytest fixtures +def test_PatientModel(): + data = { + "resourceType": "Patient", + "name": [{"family": "Doe", "given": ["John"], "prefix": ["Mr."]}], + "birthDate": "1980-01-01", + "gender": "Male", + } + patient = PatientModel(**data) + patient = patient.model_dump(by_alias=True) + assert patient["resourceType"] == "Patient" + assert patient["name"][0]["given"] == ["John"] + assert patient["birthDate"] == "1980-01-01" + assert patient["gender"] == "Male" + + +def test_PatientModel_invalid(): + # Fails due to invalid date format + data = { + "resourceType": "Patient", + "name": [{"family": "Doe", "given": ["John"], "prefix": ["Mr."]}], + "birthDate": "1980-00-00", + } + with pytest.raises(ValueError): + PatientModel(**data) + + +def test_HumanNameModel(): + data = {"family": "Doe", "given": ["John"], "prefix": ["Mr."]} + name = HumanNameModel(**data) + name = name.model_dump(by_alias=True) + assert name["family"] == "Doe" + assert name["given"] == ["John"] + + +def test_HumanNameModel_invalid(): + # Fails due to invalid data type (int instead of str) for given + data = {"family": "Doe", "given": [15], "prefix": ["Mr."]} + with pytest.raises(ValueError): + HumanNameModel(**data) + + +def test_ContactPointModel(): + data = {"system": "phone", "value": "1234567890", "use": "home"} + contact = ContactPointModel(**data) + contact = contact.model_dump(by_alias=True) + assert contact["system"] == "phone" + assert contact["value"] == "1234567890" + + +def test_AddressModel(): + data = { + "use": "home", + "type": "postal", + "text": "123 Main St", + "line": ["Apt 1"], + "city": "Anytown", + "district": "Any County", + "state": "NY", + "postalCode": "12345", + "country": "US", + } + address = AddressModel(**data) + address = address.model_dump(by_alias=True) + assert address["use"] == "home" + assert address["line"] == ["Apt 1"] + assert address["city"] == "Anytown" + assert address["state"] == "NY" + assert address["postalCode"] == "12345" + assert address["country"] == "US" diff --git a/tests/fhir_resources_unit_tests/test_fhir_resources_practitioner.py b/tests/fhir_resources_unit_tests/test_fhir_resources_practitioner.py new file mode 100644 index 0000000..ec5939b --- /dev/null +++ b/tests/fhir_resources_unit_tests/test_fhir_resources_practitioner.py @@ -0,0 +1,45 @@ +from healthchain.fhir_resources.practitioner_resources import PractitionerModel + + +def test_PractitionerModel(): + data = { + "resourceType": "Practitioner", + "name": [{"family": "Doe", "given": ["John"], "prefix": ["Mr."]}], + "birthDate": "1980-01-01", + "qualification": [ + { + "code": { + "coding": [ + { + "system": "http://example.org", + "code": "12345", + "display": "Qualification 1", + } + ], + "text": "Qualification 1", + }, + "period": {"start": "2010-01-01", "end": "2015-01-01"}, + } + ], + "communication": [ + { + "language": { + "coding": [ + { + "system": "http://example.org", + "code": "en", + "display": "English", + } + ], + "text": "English", + } + } + ], + } + + practitioner = PractitionerModel(**data) + practitioner = practitioner.model_dump(by_alias=True) + assert practitioner["resourceType"] == "Practitioner" + assert practitioner["name"][0]["given"] == ["John"] + assert practitioner["birthDate"] == "1980-01-01" + assert practitioner["qualification"][0]["code"]["coding"][0]["code"] == "12345" diff --git a/tests/generators_tests/test_encounter_generators.py b/tests/generators_tests/test_encounter_generators.py new file mode 100644 index 0000000..68f58cb --- /dev/null +++ b/tests/generators_tests/test_encounter_generators.py @@ -0,0 +1,41 @@ +from healthchain.data_generator.encounter_generator import ( + ClassGenerator, + EncounterTypeGenerator, + EncounterGenerator, +) + + +def test_ClassGenerator(): + patient_class = ClassGenerator.generate() + assert ( + patient_class.coding_field[0].system_field + == "http://terminology.hl7.org/CodeSystem/v3-ActCode" + ) + assert patient_class.coding_field[0].code_field in ("IMP", "AMB") + assert patient_class.coding_field[0].display_field in ("inpatient", "ambulatory") + + +def test_EncounterTypeGenerator(): + encounter_type = EncounterTypeGenerator.generate() + assert encounter_type.coding_field[0].system_field == "http://snomed.info/sct" + assert encounter_type.coding_field[0].display_field in ("consultation", "emergency") + + +def test_EncounterModel(): + encounter = EncounterGenerator.generate(patient_reference="Patient/123") + + assert encounter.resourceType == "Encounter" + assert encounter.id_field is not None + assert encounter.text_field is not None + assert encounter.status_field in ( + "planned", + "in-progress", + "on-hold", + "discharged", + "cancelled", + ) + assert encounter.class_field is not None + assert encounter.type_field is not None + assert encounter.subject_field is not None + assert encounter.subject_field.reference_field == "Patient/123" + assert encounter.subject_field.display_field == "Patient/123" diff --git a/tests/generators_tests/test_patient_generators.py b/tests/generators_tests/test_patient_generators.py new file mode 100644 index 0000000..bc90501 --- /dev/null +++ b/tests/generators_tests/test_patient_generators.py @@ -0,0 +1,30 @@ +from healthchain.data_generator.patient_generator import ( + PatientGenerator, + HumanNameGenerator, +) + + +def test_human_name_generator(): + # Create an instance of the HumanNameGenerator + generator = HumanNameGenerator() + + # Generate a human name + human_name = generator.generate() + + assert human_name is not None + + +def test_patient_data_generator(): + # Create an instance of the PatientDataGenerator + generator = PatientGenerator() + + # Generate patient data + patient_data = generator.generate() + + # Assert that the patient data is not empty + assert patient_data is not None + + # Assert that the patient data has the expected pydantic fields + assert patient_data.resourceType == "Patient" + assert patient_data.id_field is not None + assert patient_data.active_field is not None diff --git a/tests/generators_tests/test_practitioner_generators.py b/tests/generators_tests/test_practitioner_generators.py new file mode 100644 index 0000000..43c578e --- /dev/null +++ b/tests/generators_tests/test_practitioner_generators.py @@ -0,0 +1,68 @@ +from healthchain.data_generator.practitioner_generator import ( + PractitionerGenerator, + Practitioner_QualificationGenerator, + Practitioner_CommunicationGenerator, +) + + +def test_practitioner_data_generator(): + # Create an instance of the PractitionerDataGenerator + generator = PractitionerGenerator() + + # Generate practitioner data + practitioner_data = generator.generate() + + # Assert that the practitioner data is not empty + assert practitioner_data is not None + + # Assert that the practitioner data has the expected pydantic fields + assert practitioner_data.resourceType == "Practitioner" + assert practitioner_data.id_field is not None + assert practitioner_data.active_field is not None + assert practitioner_data.name_field is not None + assert practitioner_data.qualification_field is not None + assert practitioner_data.communication_field is not None + + # Assert that the qualification data has the expected pydantic fields + qualification_data = practitioner_data.qualification_field[0] + assert qualification_data.id_field is not None + assert qualification_data.code_field is not None + assert qualification_data.period_field is not None + + # Assert that the communication data has the expected pydantic fields + communication_data = practitioner_data.communication_field[0] + assert communication_data.id_field is not None + assert communication_data.language_field is not None + assert communication_data.preferred_field is not None + + +def test_practitioner_qualification_generator(): + # Create an instance of the PractitionerQualificationGenerator + generator = Practitioner_QualificationGenerator() + + # Generate a practitioner qualification + qualification = generator.generate() + + # Assert that the qualification is not empty + assert qualification is not None + + # Assert that the qualification has the expected pydantic fields + assert qualification.id_field is not None + assert qualification.code_field is not None + assert qualification.period_field is not None + + +def test_practitioner_communication_generator(): + # Create an instance of the PractitionerCommunicationGenerator + generator = Practitioner_CommunicationGenerator() + + # Generate a practitioner communication + communication = generator.generate() + + # Assert that the communication is not empty + assert communication is not None + + # Assert that the communication has the expected pydantic fields + assert communication.id_field is not None + assert communication.language_field is not None + assert communication.preferred_field is not None