Database Schema for Parent-Child Relationships - asp.net

I need to develop a database schema for a pediatrics database that allows the following:
Store last name, first name, date of birth, and gender for each patient.
Store all applicable guardians that may include mother, father, legal guardian and their relationship to the patient (child).
Identifies patient siblings and their relationship to the patient.
4, Allows for patients to become guardians/parents over time.
Stores phones numbers linked to each individual including patients and parents/guardians.
I'm really locked up on the best way to tackle this problem. I'm considering three tables, tblPatients, tblGuardians, and tblTelephones, but I think this would require multiple entries for parents who have multiple children. I'm sure this problem has been solved in the past, but I haven't found a suitable answer. Any insight would be appreciated.

Allows for patients to become guardians/parents over time.
This is key. If patients may become guardians/parents later, you should probably have a table for "person" that describes any kind of person, and then categorize that person with other tables.
For example
PERSON table defines demographics, (last name, first name, date of
birth, and gender, phone number etc)
PATIENT Table defines patient data with FK, and points to
a specific PERSON, optionally with a unique constraint on
PATIENT.PERSONID to ensure that no two patients are the same
person. Presence of a record in this table implies a PERSON is a PATIENT
RELATIONSHIP table links two PERSON records together and defines a relationship. Person1ID, Person2ID, and RelationshipType for example.

Here's my approach to the problem.
tbl_person, columns:
id
first_name
last_name
birth_date
gender
contact info
other personal info
tbl_patient, columns:
id
tbl_person_id
"other columns related to the patient like reason, symptoms, diagnosis, etc"
tbl_patient_has_guardian(one-to-many), columns:
tbl_patient_id(primary key)
tbl_person_id(primary key)
patient_relationship_to_guardian_type
mother, father, etc
So when adding a new patient record, add the personal info to tbl_person, then reference tbl_person id to tbl_patient.
tbl_patient_has_guardian, one patient can have multiple guardians. The guardians has specific relationship type assigned to a patient, it could be a mother, father, etc.

Related

Microsoft dynamics ax 2012 How to create autolookup from 2 different tables

I just realised that im facing huge problem on my project. I have 3 tables- slimnica(Hospital), nodala(Department) and telpa(Room). There are hundreds of Hospitals, Departments and rooms. When im filling table Room, i must select ID from table Department, but the problem is, one multiple hospitals can have example, Surgery department. It means, when im filling up Room table, i can put autolookup Departments name, but then it will show multiple Surgery departments. Is there a way to also show name of Hospital in autolookup? I added link down below of my tables.
Tables: Slimnica(Hospital), nodala(Department), telpa(Room)
Example:
I have 3 different hospitals, but all of them has Surgery department. When im filling up Room table, i must select what depertment it is, so i select departments id(it will show department name, because of autolookup name) and it will show me 3 options - id 1, surgery. id 2, surgery. id 3, surgery. Is it possible to make a autolookup that will also show hospital where that department is??? example - id 1, surgery, Childrens traumatology hospital.

GSuite AppMaker - Populate datasource with distinct values from another table

I have a simple gsuite app with two data sources. One is a students datasource which stores student name, id, and demographic info. The other is a record of the attendance for the current day and contains name, date, and present (boolean column). Each student is unique and maps to one or more rows in the attendance datasource.
The goal is to be able to pre load the table with a set of students from the students table, leaving the date and present blank. THen the user can go down the table checking the boxes for who is in attendance on that day.
Is there a simple way to pre-load a set of records in the Attendance table based on the students table? Any good examples with explanation?
EDIT:
Here's what a data model might look like:
Students: FirstName:string LastName:string Status:string SiteName:string
Attendance: FirstName:string LastName:string Date:date Present:bool
The Students datasource would contain one record per FirstName, LastName. The Attendance datasource would contain multiple records per student, corresponding to each day that attendance data was captured.
Ideally, when displaying the Attendance table widget, I would pre-populate the table with a list of students for one Site. I already have a date-picker widget that updates all the date column values.

MS Access 2010, Distinct in a Report?

I have a report that is based on a query of diagnoses (for example diabetes). The report returns a list of patients with that diagnosis. The problem is if john Q has diabetes xyz and diabetes 123, so if I run the report to give me a list of everyone with diabetes it will retun his name twice. I really don't want to change the particular query that this based on, I just want distinct name in the report. Is there a way to use distinct for a report or any other way of limiting the names to just once in the report? Or am I going to have to write a distinct query just for this report?
either edit the query by changing SELECT to
SELECT DISTINCT
or set the report to use grouping, you can Group by Name (or more likely, by a patient ID so two people with the same name don't get combined) - it's as described here
if you exclude listing the types of diabetes you will get each person on one line, if you include the types of diabetes you will get each person's details used as a heading with the types of diabetes indented
If the report already exists you can edit it by using the Grouping and Sorting option https://support.office.com/en-za/article/Create-a-grouped-or-summary-report-6a58e9ab-9f74-4689-83b6-c63cddb2c7f9?ui=en-US&rs=en-ZA&ad=ZA#__migbm_0

Enter data in mother table using data from child tables

Hi all,
I have 3 tables in an access 2010 database:
Crew: CrewID; Name; Adres;...
Voyage: VoyageId; Voyage name; Departure harbour; Arrival harbour
Crewlist: CrewlistId, VoaygeId, CrewId, Rank
The VoaygeId and CrewId from the Crewlist table are linked (relation) to the autonumber ID's from tables 2 and 1.
My first and main question is: Upon boarding everyone has to ‘sign in’ selecting the voyage and there name, and assign them a roll (of to be donde by the responsible officer). How can I make a form that lets the users browse through the voyagenames and crewnames in stead of the ID’s uses in the ‘mother’ table (table 3: Crewlist)
2nd question: how can I make sure that someone isn’t enrolled twice for the same voyage (adding same voyagenumber and same crewId number in crewlist). This would preferably be blocked upon trying to add the same person a second time on a voyage.
To prevent duplicates in Crewlist, add a unique index to the table on both CrewId and VoyageId
It would be a good idea to add relationships and enforce referential integrity
You are now in a position to use the wizards to create a form based on Voyage and a subform based on CrewList with a combobox based on Crew
There are a number of refinements you could add.
Make sure you do not use reserved words like Name and do not put spaces in field names. You will thank yourself later.
See also create form to add records in multiple tables

How to get each new survey to start from 1?

Please bear with my rambling for a moment.
I have a table called Survey.
This table is used to store Different kinds of surveys.
For instance, there is Employee Survey.
Salary Survey, etc.
Then there is a Questions table.
This table houses questions related to each Survey.
It has surveyId fk to Survey table.
But the real kicker is that it also has a field called QuestionOrder.
I need this field to be able to order and re-order questions related to a particular Survey.
For instance, right now, if a user takes an Employee survey, the first question starts with number 1), the next question, 2), et.
If we start with a new Survey, we would like the question for that survey to start with 1.
I would like to do this with QuestionOrder field.
Any idea how to do this?
I do not think this can be easily done via SQL. Perhaps you should move this logic to the application layer. For instance, when you add a new question, the QuestionOrder will be equal to "# of QuestionOrder in Survey" + 1
Create view with ROW_NUMBER() OVER(PARTITION BY surveyId ORDER BY >as you need<) as QuestionOrder

Resources