4646 |
14 Dec 17 |
nicklas |
1 |
package net.sf.basedb.reggie.vcf; |
4646 |
14 Dec 17 |
nicklas |
2 |
|
4794 |
07 May 18 |
nicklas |
3 |
import org.json.simple.JSONObject; |
4794 |
07 May 18 |
nicklas |
4 |
|
6588 |
18 Feb 22 |
nicklas |
5 |
import net.sf.basedb.core.BioMaterial; |
4646 |
14 Dec 17 |
nicklas |
6 |
import net.sf.basedb.core.Sample; |
4646 |
14 Dec 17 |
nicklas |
7 |
|
4646 |
14 Dec 17 |
nicklas |
8 |
/** |
4646 |
14 Dec 17 |
nicklas |
Holds information about a specimen and the |
4646 |
14 Dec 17 |
nicklas |
patient it belongs to. |
4646 |
14 Dec 17 |
nicklas |
11 |
|
4646 |
14 Dec 17 |
nicklas |
@author nicklas |
4646 |
14 Dec 17 |
nicklas |
@since 4.14 |
4646 |
14 Dec 17 |
nicklas |
14 |
*/ |
4646 |
14 Dec 17 |
nicklas |
15 |
public class SpecimenData |
4646 |
14 Dec 17 |
nicklas |
16 |
{ |
4646 |
14 Dec 17 |
nicklas |
17 |
|
6588 |
18 Feb 22 |
nicklas |
18 |
|
6588 |
18 Feb 22 |
nicklas |
19 |
private final SpecimenType type; |
6588 |
18 Feb 22 |
nicklas |
20 |
|
4646 |
14 Dec 17 |
nicklas |
21 |
private final int specimenId; |
4646 |
14 Dec 17 |
nicklas |
22 |
private final String specimenName; |
4646 |
14 Dec 17 |
nicklas |
23 |
|
4646 |
14 Dec 17 |
nicklas |
24 |
private final int caseId; |
6451 |
22 Oct 21 |
nicklas |
25 |
private final String caseName; |
4646 |
14 Dec 17 |
nicklas |
26 |
|
4646 |
14 Dec 17 |
nicklas |
27 |
private final int patId; |
4646 |
14 Dec 17 |
nicklas |
28 |
private final String patName; |
4646 |
14 Dec 17 |
nicklas |
29 |
|
6588 |
18 Feb 22 |
nicklas |
30 |
public SpecimenData(SpecimenType type, Sample specimen) |
4646 |
14 Dec 17 |
nicklas |
31 |
{ |
6588 |
18 Feb 22 |
nicklas |
32 |
this.type = type; |
4646 |
14 Dec 17 |
nicklas |
33 |
this.specimenId = specimen.getId(); |
4646 |
14 Dec 17 |
nicklas |
34 |
this.specimenName = specimen.getName(); |
4646 |
14 Dec 17 |
nicklas |
35 |
|
6588 |
18 Feb 22 |
nicklas |
36 |
BioMaterial parent = specimen.getParent(); |
6588 |
18 Feb 22 |
nicklas |
37 |
if (type == SpecimenType.SPECIMEN) |
6588 |
18 Feb 22 |
nicklas |
38 |
{ |
6588 |
18 Feb 22 |
nicklas |
39 |
this.caseId = parent.getId(); |
6588 |
18 Feb 22 |
nicklas |
40 |
this.caseName = parent.getName(); |
6588 |
18 Feb 22 |
nicklas |
41 |
parent = ((Sample)parent).getParent(); |
6588 |
18 Feb 22 |
nicklas |
42 |
} |
6588 |
18 Feb 22 |
nicklas |
43 |
else |
6588 |
18 Feb 22 |
nicklas |
44 |
{ |
6588 |
18 Feb 22 |
nicklas |
45 |
this.caseId = 0; |
6588 |
18 Feb 22 |
nicklas |
46 |
this.caseName = null; |
6588 |
18 Feb 22 |
nicklas |
47 |
} |
6588 |
18 Feb 22 |
nicklas |
48 |
this.patId = parent.getId(); |
6588 |
18 Feb 22 |
nicklas |
49 |
this.patName = parent.getName(); |
4646 |
14 Dec 17 |
nicklas |
50 |
} |
4646 |
14 Dec 17 |
nicklas |
51 |
|
6588 |
18 Feb 22 |
nicklas |
52 |
/** |
6595 |
22 Feb 22 |
nicklas |
Get the specimen type. |
6595 |
22 Feb 22 |
nicklas |
@since 4.37 |
6595 |
22 Feb 22 |
nicklas |
55 |
*/ |
6595 |
22 Feb 22 |
nicklas |
56 |
public SpecimenType getSpecimenType() |
6595 |
22 Feb 22 |
nicklas |
57 |
{ |
6595 |
22 Feb 22 |
nicklas |
58 |
return type; |
6595 |
22 Feb 22 |
nicklas |
59 |
} |
6595 |
22 Feb 22 |
nicklas |
60 |
|
6595 |
22 Feb 22 |
nicklas |
61 |
/** |
6588 |
18 Feb 22 |
nicklas |
Get the name of the specimen. |
6588 |
18 Feb 22 |
nicklas |
63 |
*/ |
4646 |
14 Dec 17 |
nicklas |
64 |
public String getSpecimenName() |
4646 |
14 Dec 17 |
nicklas |
65 |
{ |
4646 |
14 Dec 17 |
nicklas |
66 |
return specimenName; |
4646 |
14 Dec 17 |
nicklas |
67 |
} |
4646 |
14 Dec 17 |
nicklas |
68 |
|
6588 |
18 Feb 22 |
nicklas |
69 |
/** |
6588 |
18 Feb 22 |
nicklas |
Get the name of the patient. |
6588 |
18 Feb 22 |
nicklas |
71 |
*/ |
4646 |
14 Dec 17 |
nicklas |
72 |
public String getPatientName() |
4646 |
14 Dec 17 |
nicklas |
73 |
{ |
4646 |
14 Dec 17 |
nicklas |
74 |
return patName; |
4646 |
14 Dec 17 |
nicklas |
75 |
} |
4646 |
14 Dec 17 |
nicklas |
76 |
|
6588 |
18 Feb 22 |
nicklas |
77 |
/** |
6588 |
18 Feb 22 |
nicklas |
Get the id of the patient. |
6588 |
18 Feb 22 |
nicklas |
79 |
*/ |
6451 |
22 Oct 21 |
nicklas |
80 |
public int getPatientId() |
6451 |
22 Oct 21 |
nicklas |
81 |
{ |
6451 |
22 Oct 21 |
nicklas |
82 |
return patId; |
6451 |
22 Oct 21 |
nicklas |
83 |
} |
6451 |
22 Oct 21 |
nicklas |
84 |
|
4646 |
14 Dec 17 |
nicklas |
85 |
/** |
4646 |
14 Dec 17 |
nicklas |
Is this specimen from the same patient as the |
4646 |
14 Dec 17 |
nicklas |
other specimen? |
4646 |
14 Dec 17 |
nicklas |
88 |
*/ |
4646 |
14 Dec 17 |
nicklas |
89 |
public boolean hasSamePatient(SpecimenData other) |
4646 |
14 Dec 17 |
nicklas |
90 |
{ |
4646 |
14 Dec 17 |
nicklas |
91 |
return this.patId == other.patId; |
4646 |
14 Dec 17 |
nicklas |
92 |
} |
4646 |
14 Dec 17 |
nicklas |
93 |
|
4712 |
22 Mar 18 |
nicklas |
94 |
/** |
4712 |
22 Mar 18 |
nicklas |
Is this specimen the same as the other specimen? |
4712 |
22 Mar 18 |
nicklas |
@since 4.16 |
4712 |
22 Mar 18 |
nicklas |
97 |
*/ |
4712 |
22 Mar 18 |
nicklas |
98 |
public boolean hasSameSpecimen(SpecimenData other) |
4712 |
22 Mar 18 |
nicklas |
99 |
{ |
4712 |
22 Mar 18 |
nicklas |
100 |
return this.specimenId == other.specimenId; |
4712 |
22 Mar 18 |
nicklas |
101 |
} |
4712 |
22 Mar 18 |
nicklas |
102 |
|
4794 |
07 May 18 |
nicklas |
103 |
public JSONObject asJSONObject() |
4794 |
07 May 18 |
nicklas |
104 |
{ |
4794 |
07 May 18 |
nicklas |
105 |
JSONObject json = new JSONObject(); |
4794 |
07 May 18 |
nicklas |
106 |
json.put("id", specimenId); |
4794 |
07 May 18 |
nicklas |
107 |
json.put("name", specimenName); |
6588 |
18 Feb 22 |
nicklas |
108 |
json.put("type", type.name()); |
6451 |
22 Oct 21 |
nicklas |
109 |
json.put("caseId", caseId); |
6451 |
22 Oct 21 |
nicklas |
110 |
json.put("caseName", caseName); |
6451 |
22 Oct 21 |
nicklas |
111 |
json.put("patientId", patId); |
4794 |
07 May 18 |
nicklas |
112 |
json.put("patientName", patName); |
4794 |
07 May 18 |
nicklas |
113 |
return json; |
4794 |
07 May 18 |
nicklas |
114 |
} |
4794 |
07 May 18 |
nicklas |
115 |
|
6588 |
18 Feb 22 |
nicklas |
116 |
|
6588 |
18 Feb 22 |
nicklas |
117 |
public static enum SpecimenType |
6588 |
18 Feb 22 |
nicklas |
118 |
{ |
6588 |
18 Feb 22 |
nicklas |
119 |
SPECIMEN, BLOOD; |
6588 |
18 Feb 22 |
nicklas |
120 |
} |
4646 |
14 Dec 17 |
nicklas |
121 |
} |