Skip to content

Commit

Permalink
retrieve slightly different list of patients (based on the reports), …
Browse files Browse the repository at this point in the history
…instead of the Doe family
  • Loading branch information
Laurens Rietveld committed Oct 31, 2012
1 parent 5531939 commit 7400e68
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 56 deletions.
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,25 @@
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-war-plugin
</artifactId>
<versionRange>
[2.1.1,)
</versionRange>
<goals>
<goal>exploded</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static ArrayList<String> getSparqlPrefixes(String prefixTypes) {
namespaceList.add("PREFIX ns1: <http://purl.org/cpr/0.75#>");
namespaceList.add("PREFIX : <http://aers.data2semantics.org/vocab/>");
namespaceList.add("PREFIX patient: <http://www.data2semantics.org/ontology/patient/>");
namespaceList.add("PREFIX aers: <http://aers.data2semantics.org/>");
namespaceList.add("PREFIX aersv: <http://aers.data2semantics.org/vocab/>");
} else if (prefixTypes.equals("annotations")) {
namespaceList.add("PREFIX ao: <http://purl.org/ao/core#>");
namespaceList.add("PREFIX aot: <http://purl.org/ao/types#>");
Expand All @@ -50,7 +52,6 @@ public static ArrayList<String> getSparqlPrefixes(String prefixTypes) {
namespaceList.add("PREFIX cnt: <http://www.w3.org/2011/content#>");
namespaceList.add("PREFIX dc: <http://purl.org/dc/elements/1.1/>");
namespaceList.add("PREFIX dcterms: <http://purl.org/dc/terms/>");
namespaceList.add("PREFIX aers: <http://aers.data2semantics.org/>");
namespaceList.add("PREFIX swanrel: <http://purl.org/swan/2.0/discourse-relationships/>");
namespaceList.add("PREFIX d2sa: <http://aers.data2semantics.org/vocab/annotation/>");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.data2semantics.hubble.shared.models.Indication;
import com.data2semantics.hubble.shared.models.Measurement;
import com.data2semantics.hubble.shared.models.Patient;
import com.data2semantics.hubble.shared.models.Treatment;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Alignment;
Expand Down Expand Up @@ -220,13 +219,23 @@ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int col
private void drawInfoIntoTable(Patient patientInfo) {
rows = new ArrayList<PatientInfoRecord>();
rows.add(new PatientInfoRecord("Patient ID", patientInfo.getPatientID()));
rows.add(new PatientInfoRecord("Comment", patientInfo.getComment()));
rows.add(new PatientInfoRecord("Age", Integer.toString(patientInfo.getAge())));
String comment = patientInfo.getComment();
if (comment != null) {
rows.add(new PatientInfoRecord("Comment", patientInfo.getComment()));
}
int age = patientInfo.getAge();
if (age != 0) {
rows.add(new PatientInfoRecord("Age", Integer.toString(patientInfo.getAge())));
}
String weight = patientInfo.getWeight();
if (weight != null) {
rows.add(new PatientInfoRecord("Weight", weight));
}
drawIndications(patientInfo);
drawPreviousIndications(patientInfo);
//drawPreviousIndications(patientInfo);
drawDrugs(patientInfo);
drawMeasurements(patientInfo);
drawRecentTreatments(patientInfo);
//drawRecentTreatments(patientInfo);

PatientInfoRecord[] rowsArray = new PatientInfoRecord[rows.size()];
rows.toArray(rowsArray);
Expand All @@ -242,14 +251,14 @@ private void drawIndications(Patient patientInfo) {
rows.add(row);
}
}
private void drawPreviousIndications(Patient patientInfo) {
for (Map.Entry<String, Indication> entry : patientInfo.getPreviousIndications().entrySet()) {
final Indication indication = entry.getValue();
PatientInfoRecord row = new PatientInfoRecord(RowHeaders.PREV_INDICATION, indication.getLabel(), indication.getDefinition());
row.setUri(entry.getKey());
rows.add(row);
}
}
// private void drawPreviousIndications(Patient patientInfo) {
// for (Map.Entry<String, Indication> entry : patientInfo.getPreviousIndications().entrySet()) {
// final Indication indication = entry.getValue();
// PatientInfoRecord row = new PatientInfoRecord(RowHeaders.PREV_INDICATION, indication.getLabel(), indication.getDefinition());
// row.setUri(entry.getKey());
// rows.add(row);
// }
// }
private void drawMeasurements(Patient patientInfo) {
for (Map.Entry<String, Measurement> entry : patientInfo.getMeasurements().entrySet()) {
final Measurement measurement = entry.getValue();
Expand All @@ -261,14 +270,14 @@ private void drawMeasurements(Patient patientInfo) {
}

}
private void drawRecentTreatments(Patient patientInfo) {
for (Map.Entry<String, Treatment> entry : patientInfo.getRecentTreatments().entrySet()) {
final Treatment treatment = entry.getValue();
PatientInfoRecord row = new PatientInfoRecord(RowHeaders.TREATMENT, treatment.getLabel());
row.setUri(entry.getKey());
rows.add(row);
}
}
// private void drawRecentTreatments(Patient patientInfo) {
// for (Map.Entry<String, Treatment> entry : patientInfo.getRecentTreatments().entrySet()) {
// final Treatment treatment = entry.getValue();
// PatientInfoRecord row = new PatientInfoRecord(RowHeaders.TREATMENT, treatment.getLabel());
// row.setUri(entry.getKey());
// rows.add(row);
// }
// }

private void drawDrugs(Patient patientInfo) {
for (Map.Entry<String, Drug> entry : patientInfo.getDrugs().entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public PatientListing(final View view) {
setSelectionType(SelectionStyle.SINGLE);
ListGridField nameField = new ListGridField("patientId", "Patient");
setFields(nameField);

setLeaveScrollbarGap(false);
addSelectionChangedHandler(new SelectionChangedHandler() {
public void onSelectionChanged(SelectionEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ public static int getInt(RDFNode node) {
return node.asLiteral().getInt();
}

public static double getDouble(RDFNode node) {
return node.asLiteral().getDouble();
}

// public static BigDecimal getBigDecimal(RDFNode node) {
// return node.asLiteral().getString();
// }
public static String getString(QuerySolution solution, String variable) {
return getString(solution.get(variable));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void parseValue(String varName, QuerySolution solution) {
* These are values (not uri's). Set them in the patient object
*/
if (varName.equals("age")) {
patientObject.setAge(RdfNodeHelper.getInt(rdfNode));
patientObject.setAge(RdfNodeHelper.getDurationYears(rdfNode));
} else if (varName.equals("comment")) {
patientObject.setComment(RdfNodeHelper.getString(rdfNode));
} else if (varName.equals("status")) {
Expand Down Expand Up @@ -126,6 +126,8 @@ private void parseValue(String varName, QuerySolution solution) {
String drugbankID = sameAs.substring(Drug.DRUGBANK_PREFIX.length());
String imageLocation = Drug.IMGLOCATION_PREFIX + drugbankID + Drug.IMGLOCATION_POSTFIX;
patientObject.getDrug(uri).setImgLocation(imageLocation);
} else if (varName.equals("weight")) {
patientObject.setWeight(RdfNodeHelper.getString(rdfNode));
}
} catch (NullPointerException e) {
System.out.println("Nullpointer exception for var " + varName + " and rdfNode " + solution.get(varName).toString());
Expand All @@ -136,47 +138,46 @@ private void parseValue(String varName, QuerySolution solution) {

private ResultSet queryPatientData() throws IllegalArgumentException, SparqlException {
String queryString = Helper.getSparqlPrefixesAsString("aers") + "\n" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
"SELECT DISTINCT " +
"?age \n" +
"?comment \n" +
"?status \n" +
"?measurement \n" +
// "?comment \n" +
// "?status \n" +
// "?measurement \n" +
"?indication \n" +
"?indication_label \n" +
"?recentTreatment \n" +
"?recentTreatment_label \n" +
"?previousIndication \n" +
// "?recentTreatment \n" +
// "?recentTreatment_label \n" +
// "?previousIndication \n" +
"?drug \n" +
"?drug_label \n" +
"?drug_sameAs \n" +
"?weight\n" +
"{\n" +
"?patient rdf:type patient:Patient.\n" +
"?patient rdfs:label '" + patientId + "'@en.\n" +
"?patient patient:hasAge ?age.\n" +
"?patient rdfs:comment ?comment.\n" +
"OPTIONAL{?patient patient:usesMedication ?drug.\n" +
"?drug rdfs:label ?drug_label;\n" +
"skos:exactMatch ?drug_sameAs.\n" +
"?drug_sameAs <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/primaryAccessionNo> ?pan .\n" +
// "FILTER regex(str(?drug_sameAs), \"^http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugs/DB\", \"i\")\n" +
"}.\n" +
"OPTIONAL{?patient patient:hasStatus ?status}.\n" +
"OPTIONAL{?patient patient:hasMeasurement ?measurement}.\n" +
"OPTIONAL{\n" +
"?patient patient:hasDiagnosis ?indication.\n" +
"OPTIONAL{\n" +
"?indication rdfs:label ?indication_label.\n" +
"}\n" +
"}.\n" +

//Workaround to get 'hadRecentTreatment' from our own 4store. This SHOULD BE in the lld rdf, but isnt :(
"OPTIONAL{\n" +
"?patient patient:hadRecentTreatment ?recentTreatment.\n" +
"?recentTreatment rdfs:label ?recentTreatment_label.\n" +
"}.\n" +
"OPTIONAL{?patient patient:hadPreviousIndication ?previousIndication}.\n" +
"}\n" +
"?patient rdf:type patient:Patient;\n" +
" rdfs:label '" + patientId + "'^^xsd:string;\n" +
" patient:hasDiagnosis ?indication.\n" +
"OPTIONAL {\n" +
" ?patient aersv:age ?age.\n" +
"}\n" +
" OPTIONAL {\n" +
" ?patient aersv:weight ?weight\n" +
"}\n" +
" OPTIONAL {\n" +
" ?indication rdfs:label ?indication_label\n" +
" }\n" +
" OPTIONAL {\n" +
" ?patient patient:usesMedication ?medication.\n" +
" ?medication aersv:drug ?drug.\n" +
" ?drug rdfs:label ?drug_label;\n" +
" skos:exactMatch ?drug_sameAs.\n" +
" ?drug_sameAs <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/primaryAccessionNo> ?pan.\n" +
" FILTER regex(str(?drug_sameAs), \"^http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugs/DB\", \"i\")\n" +
" }\n" +
" \n" +
"} " +
"";
System.out.println(queryString);
return Endpoint.query(Endpoint.ECULTURE2, queryString);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public class Patient implements Serializable {
private static final long serialVersionUID = 1L;

private String patientID;
private int age;
private int age = 0;
private String comment;
private String status;
private String weight;

/**
* For these hashmaps, use URI as key
Expand Down Expand Up @@ -142,5 +143,11 @@ public Drug getDrug(String uri) {
}
return drug;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}

}

0 comments on commit 7400e68

Please sign in to comment.