Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97148822
InfoPatient.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jan 2, 22:51
Size
4 KB
Mime Type
text/x-java
Expires
Sat, Jan 4, 22:51 (2 d)
Engine
blob
Format
Raw Data
Handle
23338097
Attached To
R3229 Genome Privacy - SHCS App
InfoPatient.java
View Options
package
com.example.genomicprivacy
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.Random
;
import
FrameWork.DBconnector_mu
;
import
FrameWork.RequestPatient
;
import
android.app.ActionBar
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.graphics.drawable.ColorDrawable
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
public
class
InfoPatient
extends
Activity
{
/**
* Name of the patient
*/
private
String
name
;
/**
* Lastname of the patient
*/
private
String
lastName
;
/**
* Id of the patient
*/
private
int
id
;
/**
* Information about the patient selected
*/
private
TextView
title
;
/**
* Layout for the text of the category and for the checkboxes
*/
private
LinearLayout
catObject
;
/**
* Text of each of the category
*/
private
TextView
catTitle
;
/**
* Checkbox of the differents diseases
*/
private
CheckBox
disCheck
;
/**
* Mapping of the category ID to the disease
*/
private
HashMap
<
Integer
,
LinkedList
<
String
>>
catIDtoDis
=
new
HashMap
<
Integer
,
LinkedList
<
String
>>();
/**
* Mapping every disease with his ID
*/
private
HashMap
<
String
,
Integer
>
diseaseToIDdis
=
new
HashMap
<
String
,
Integer
>();
/**
* Mapping of the categoryID to the category Name
*/
private
HashMap
<
Integer
,
String
>
catIDtoCatName
=
new
HashMap
<
Integer
,
String
>();
private
HashMap
<
Integer
,
String
>
IDDisToDisease
=
new
HashMap
<
Integer
,
String
>();
/**
* Button ask consent
*/
private
Button
askConsent
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
info_patient
);
id
=
getIntent
().
getIntExtra
(
"id"
,
0
);
name
=
getIntent
().
getStringExtra
(
"name"
);
lastName
=
getIntent
().
getStringExtra
(
"lastName"
);
catObject
=
(
LinearLayout
)
findViewById
(
R
.
id
.
objetCat
);
catTitle
=
new
TextView
(
ContextApp
.
getContext
());
title
=
(
TextView
)
findViewById
(
R
.
id
.
titlePatientInfo
);
askConsent
=
(
Button
)
findViewById
(
R
.
id
.
askConsent
);
title
.
setText
(
"Patient ID: "
+
id
+
", LastName: "
+
lastName
+
", Name: "
+
name
);
ActionBar
actionBar
=
getActionBar
();
actionBar
.
setDisplayHomeAsUpEnabled
(
true
);
new
getHashMap
().
execute
();
//Send the consent to the patient
askConsent
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
ArrayList
<
RequestPatient
>
arp
=
createRequestsPatient
();
// Ask consent for each request
for
(
int
i
=
0
;
i
<
arp
.
size
();
i
++)
{
ContextApp
.
getMu
().
sendToPatient
(
arp
.
get
(
i
));
}
Toast
toast
=
Toast
.
makeText
(
ContextApp
.
getContext
(),
"Your request was sent"
,
8000
);
toast
.
show
();
}
});
}
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
finish
();
return
true
;
}
/**
* Creates the requests patient. This generate a list of RequestPatient
* given the ID of patient, the ID test, and ID of MU
*
* @return the array list
*/
public
ArrayList
<
RequestPatient
>
createRequestsPatient
()
{
ArrayList
<
RequestPatient
>
rp
=
new
ArrayList
<
RequestPatient
>();
int
id_p
=
id
;
Random
rnd
=
new
Random
();
// use for create the request ID
int
id_d
=
0
;
int
flag
=
0
;
String
nameTest
=
null
;
for
(
int
i
=
0
;
i
<
catObject
.
getChildCount
();
i
++)
{
CheckBox
box
=
(
CheckBox
)
catObject
.
getChildAt
(
i
);
if
(
box
.
isChecked
()
&&
box
.
isEnabled
())
{
id_d
=
diseaseToIDdis
.
get
(
box
.
getText
());
rp
.
add
(
new
RequestPatient
(
Math
.
abs
(
rnd
.
nextInt
()),
id_p
,
ContextApp
.
getMu
().
getID
(),
id_d
,
box
.
getText
()
.
toString
(),
flag
));
}
}
return
rp
;
}
private
class
getHashMap
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
try
{
catIDtoDis
=
DBconnector_mu
.
catIDtoDisease
();
catIDtoCatName
=
DBconnector_mu
.
catIDtocatName
();
diseaseToIDdis
=
DBconnector_mu
.
diseaseToIDdisease
();
}
catch
(
SQLException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
result
)
{
// TODO Auto-generated method stub
super
.
onPostExecute
(
result
);
for
(
int
i
=
0
;
i
<
catIDtoCatName
.
size
();
i
++)
{
CheckBox
checkTitle
=
new
CheckBox
(
ContextApp
.
getContext
());
checkTitle
.
setText
(
catIDtoCatName
.
get
(
i
+
1
));
checkTitle
.
setEnabled
(
false
);
checkTitle
.
setTextColor
(
Color
.
RED
);
catObject
.
addView
(
checkTitle
);
int
sizeLinkedList
=
catIDtoDis
.
get
(
i
+
1
).
size
();
for
(
int
j
=
0
;
j
<
sizeLinkedList
;
j
++)
{
disCheck
=
new
CheckBox
(
ContextApp
.
getContext
());
disCheck
.
setText
(
catIDtoDis
.
get
(
i
+
1
).
get
(
j
));
disCheck
.
setTextColor
(
Color
.
BLACK
);
catObject
.
addView
(
disCheck
);
}
}
}
}
}
Event Timeline
Log In to Comment