create a code on python that will sort out patients into sets

Watch this thread
ah17054
Badges: 4
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 2 years ago
#1
#1
I am trying to create a code on python that will allow me to sort my list of information into sets. For example I have 3 patient. Patient x has treatment 1,2,3 patient y has treatment 3 and 4 and patient z has treatment 1 and 2. I want to code it so that my output is the list of patients that need treatment 1, list of patients that need treatment 2, list of patients that need treatment 3 and list of patients that need treatment 4.
Thank you
0
reply
Strange5050
Badges: 17
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 2 years ago
#2
First of all how is your list information being stored? If you can expand a bit more on exactly where and how your information you need categorised is stored, we can help.
0
reply
ah17054
Badges: 4
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report Thread starter 2 years ago
#3
okay I dont really know anything about python so idk what info you need but I can expend on what I am trying to do.
I have a list of patient treatment plans and I am trying to group the patients to what procedures the patients need.
There are 7 procedures so there will be 7 groups, p1, p2,p3,p4,p5,p6,p7
the treatment plans will look like
Patient A=(p1,p3,p4)
Patient B=(p1,p1,p1,p3)
patient C=(p2,p2,p7)
just an example,
I want to group these such that my output will be
p1= (A,B)
p2=(C)
p3=(A,B)
p4=(A)
p5=()
p6=()
p7=(C)
Does that make more sense?

Heres a sc of the example treatment plan I have so the Direct Restoration is p1, Complex Perio is p2, prevention is p3,
Attached files
Last edited by ah17054; 2 years ago
0
reply
Strange5050
Badges: 17
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report 2 years ago
#4
So, first of all I would ensure that each paitent is an 'list' effectively. So example:

Code:
patientA = ['p1', 'p3', 'p4']
I would also have several list that would be a holding those patients for each procedure:
Code:
procOne = []
procTwo = [] 
ect......
I would then use a function like so:
Code:
def sortPatients(patientArray):
    if 'p1' in patientArray:
        procOne.Append(patientA)
    if 'p2' in patientArray:
        procTwo.Append(patientA)
  
    // And so on and on.....
Or something along those line? Hope this helps.
Last edited by Strange5050; 2 years ago
0
reply
ah17054
Badges: 4
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#5
Report Thread starter 2 years ago
#5
okay I have written that and ran print(sortPatients(patientA)) but this came up
Attached files
0
reply
Strange5050
Badges: 17
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#6
Report 2 years ago
#6
(Original post by ah17054)
okay I have written that and ran print(sortPatients(patientA)) but this came up
My bad, I've haven't used Python for a while. It's a simple fix, simply change .Append() to lower case, so .append()
0
reply
ah17054
Badges: 4
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#7
Report Thread starter 2 years ago
#7
thank you so much!!
1
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How did your AQA Combined Science - Biology Paper 1 go?

Loved the paper - Feeling positive (59)
34.5%
The paper was reasonable (68)
39.77%
Not feeling great about that exam... (28)
16.37%
It was TERRIBLE (16)
9.36%

Watched Threads

View All