Skip to content

Model non-patient users as FHIR Practitioners and allow Patients to belong to multiple Organizations #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
s1monj opened this issue Nov 22, 2024 · 0 comments
Assignees
Labels
backend Python and SQL code enhancement New feature or request

Comments

@s1monj
Copy link
Collaborator

s1monj commented Nov 22, 2024

Background

  • currently a default "user" is a practitioner, but a patient also becomes a user when they are invited to a study so that the oauth mechanism can be used
  • a better model for this is to have users only concerned with account functions (email, password, django system fields eg is_superuser etc) and have Practitioners and Patients reference a specific user
  • also, rather than have a patient reference one organization_id, there should be a break out table for many to many

TBD

  • (we will keep first_name and last_name in core_jheuser to maintain compatibility with standard Django user libs like OAuth)
  • create a new table core_practitioner with fields below (use jhe_user_id instead of user_id)
  • remove organization_id from core_patient
  • remove the table core_jheuserorganization
  • add core_patientorganizations with fields below
  • add core_practitionerorganizations with fields below
  • update app logic
erDiagram
    "users" ||--|{ "DELETEuser_organizations": ""
    "users" {
        int id
        jsonb identifer
        varchar email
        DELETE first_name
        DELETE last_name
        various django_standard_user_fields
    }
    "organizations (FHIR Organization)" ||--|{ "organizations (FHIR Organization)": ""
    "organizations (FHIR Organization)" ||--|{ "DELETEuser_organizations": ""
    "organizations (FHIR Organization)" ||--|{ "smart_client_configs": ""
    "organizations (FHIR Organization)" ||--|{ "studies (FHIR Group)": ""
    "organizations (FHIR Organization)" {
        int id
        jsonb identifer
        varchar name
        enum type
        int part_of
    }
    "smart_client_configs" {
        int id
        int organization_id
        varchar well_known_uri
        varchar client_id
        varchar scopes
    }
    "DELETEuser_organizations" {
        int id
        int user_id
        int organization_id
    }
    "patients (FHIR Patient)" ||--|| "users": ""
    "patients (FHIR Patient)" ||--|{ "observations (FHIR Observation)": ""
    "patients (FHIR Patient)" ||--|{ "study_patients": ""
    "patients (FHIR Patient)" {
        int id
        int user_id
        DELETE organization_id
        varchar identifer
        varchar name_family
        varchar name_given
        date   birth_date
        varchar telecom_cell
    }
    "patient_organizations" ||--|{ "patients (FHIR Patient)": ""
    "patient_organizations" ||--|{ "organizations (FHIR Organization)": ""
    "patient_organizations" {
        int id
        int patient_id
        int organization_id
    }
    "practitioners (FHIR Practitioner)" ||--|| "users": ""
    "practitioners (FHIR Practitioner)" {
        int id
        int user_id
        varchar identifer
        varchar name_family
        varchar name_given
        date   birth_date
        varchar telecom_cell
    }
    "practitioner_organizations" ||--|{ "practitioners (FHIR Practitioner)": ""
    "practitioner_organizations" ||--|{ "organizations (FHIR Organization)": ""
    "practitioner_organizations" {
        int id
        int practitioner_id
        int organization_id
    }
    "studies (FHIR Group)" ||--|{ "study_patients": ""       
    "studies (FHIR Group)" ||--|{ "study_scope_requests": ""
    "studies (FHIR Group)" ||--|{ "study_data_sources": ""
    "studies (FHIR Group)" {
        int id
        int organization_id
        jsonb identifer
        varchar name
        varchar description
    }
    "study_patients" ||--|{ "study_patient_scope_consents": ""
    "study_patients" {
        int id
        int study_id
        int pateint_id
    }
    "study_scope_requests" ||--|{ "codeable_concepts (FHIR CodeableConcept)": ""
    "study_scope_requests" {
        int id
        int study_id
        enum scope_action
        int scope_code_id
    }

    
    "observations (FHIR Observation)" ||--|| "codeable_concepts (FHIR CodeableConcept)": ""
    "observations (FHIR Observation)" ||--|{ "observation_identifiers": ""
    "observations (FHIR Observation)" ||--|| "data_sources": ""
    "observations (FHIR Observation)" {
        int id
        int subject_patient_id
        int codeable_concept_id
        jsonb value_attachment_data
        timestamp transaction_time
    }

    "observation_identifiers" {
        int id
        int observation_id
        varchar system
        varchar value
    }
    
    "studies (FHIR Group)" ||--|{ "study_patients": ""
    "codeable_concepts (FHIR CodeableConcept)" {
        int id
        varchar coding_system
        varchar coding_code
        varchar text
    }
    "study_patient_scope_consents" ||--|| "codeable_concepts (FHIR CodeableConcept)": ""
    "study_patient_scope_consents" {
        int id
        int study_patient_id
        enum scope_action
        int scope_code_id
        bool consented
        timestamp consented_time       
    }
    "data_sources" ||--|{ "data_source_supported_scopes": ""
    "data_sources" ||--|{ "study_data_sources": ""
    "data_sources" {
        int id
        varchar name
        enum type
    }
    "data_source_supported_scopes" ||--|| "codeable_concepts (FHIR CodeableConcept)": ""
    "data_source_supported_scopes" {
        int id
        int data_source_id
        int scope_code_id
    }
    "study_data_sources" {
        int id
        int study_id
        int data_source_id
    }
Loading
@s1monj s1monj added the enhancement New feature or request label Nov 22, 2024
@s1monj s1monj added the backend Python and SQL code label Nov 22, 2024
@s1monj s1monj changed the title Model non-patient users as FHIR Practitioners Model non-patient users as FHIR Practitioners and allow Patients to belong to multiple Organizations Apr 5, 2025
@s1monj s1monj moved this from Backlog to Ready in jupyterhealth-exchange Apr 5, 2025
@s1monj s1monj assigned s1monj and unassigned travis-sauer-oltech Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Python and SQL code enhancement New feature or request
Projects
Status: Ready
Development

No branches or pull requests

2 participants