Skip to content

Commit

Permalink
Merge pull request #67 from rkboyce/master
Browse files Browse the repository at this point in the history
Some minor but useful extensions to the WebAPI Evidence service
  • Loading branch information
anthonysena committed Oct 23, 2015
2 parents 642fbb1 + e5b9eaf commit 88bdb94
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/main/java/org/ohdsi/webapi/evidence/DrugEvidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*/
@JsonInclude(Include.NON_NULL)
public class DrugEvidence {
@JsonProperty("EVIDENCE")

@JsonProperty("EVIDENCE")
public String evidence;

@JsonProperty("MODALITY")
Expand All @@ -28,6 +29,9 @@ public class DrugEvidence {
@JsonProperty("HOI")
public String hoi;

@JsonProperty("HOI-NAME")
public String hoiName;

@JsonProperty("COUNT")
public Integer count;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/ohdsi/webapi/evidence/HoiEvidence.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class HoiEvidence {
@JsonProperty("DRUG")
public String drug;

@JsonProperty("DRUG-NAME")
public String drugName;

@JsonProperty("COUNT")
public Integer count;

Expand Down
23 changes: 19 additions & 4 deletions src/main/java/org/ohdsi/webapi/service/EvidenceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,41 @@ public Collection<DrugEvidence> getDrugEvidence(@PathParam("sourceKey") String s
// log.debug(String.format("Request for conceptId=%s resulted in 0 results", id));
// throw new WebApplicationException(Response.Status.RESET_CONTENT); // http 205
//}

String tempDrugHoi = "";
String tempEvidenceType = "";
Boolean tempModality = false;
for (Map rs : rows) {

String evi_type = (String) rs.get("EV_TYPE");
boolean modality = (boolean) rs.get("EV_MODALITY");
Boolean modality = (Boolean) rs.get("EV_MODALITY");
String linkout = (String) rs.get("EV_LINKOUT");
String hoi = String.valueOf((Integer) rs.get("EV_HOI"));
String hoiName = (String)rs.get("EV_SNOMED_HOI");
String statType = (String) rs.get("EV_STAT_TYPE");
BigDecimal statVal = (BigDecimal) rs.get("EV_STAT_VAL");

String drugHoi = (String)rs.get("EV_DRUGHOI");

if((!drugHoi.equalsIgnoreCase(tempDrugHoi))||(!evi_type.equalsIgnoreCase(tempEvidenceType))||(!modality.equals(tempModality)))
{
DrugEvidence evidence = new DrugEvidence();
tempDrugHoi = drugHoi;
tempEvidenceType = evi_type;
tempModality = modality;
//evidence.drughoi = drugHoi;
evidence.evidence = evi_type;
evidence.modality = modality;
evidence.linkout = linkout;
evidence.hoi = hoi;
evidence.hoiName = hoiName;
evidence.statisticType = statType;
if (statType.equals("COUNT")) {
evidence.count = statVal.intValue();
} else {
evidence.value = statVal;
}

drugEvidences.add(evidence);
}
}
return drugEvidences;
}
Expand Down Expand Up @@ -179,6 +192,7 @@ public Collection<HoiEvidence> getHoiEvidence(@PathParam("sourceKey") String sou
boolean modality = (boolean) rs.get("EV_MODALITY");
String linkout = (String) rs.get("EV_LINKOUT");
String drug = String.valueOf((Integer) rs.get("EV_DRUG"));
String drugName = (String) rs.get("EV_RXNORM_DRUG");
String statType = (String) rs.get("EV_STAT_TYPE");
BigDecimal statVal = (BigDecimal) rs.get("EV_STAT_VAL");

Expand All @@ -187,6 +201,7 @@ public Collection<HoiEvidence> getHoiEvidence(@PathParam("sourceKey") String sou
evidence.modality = modality;
evidence.linkout = linkout;
evidence.drug = drug;
evidence.drugName = drugName;
evidence.statisticType = statType;
if (statType.equals("COUNT")) {
evidence.count = statVal.intValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SELECT EV.EVIDENCE_TYPE EV_TYPE, EV.MODALITY EV_MODALITY, EV.EVIDENCE_LINKOUT EV_LINKOUT, REL.HOI EV_HOI, EV.STATISTIC_VALUE EV_STAT_VAL, EV.STATISTIC_TYPE EV_STAT_TYPE
SELECT EV.DRUG_HOI_RELATIONSHIP EV_DRUGHOI, EV.EVIDENCE_TYPE EV_TYPE, EV.MODALITY EV_MODALITY, EV.EVIDENCE_LINKOUT EV_LINKOUT, REL.HOI EV_HOI, REL.SNOMED_HOI EV_SNOMED_HOI, EV.STATISTIC_VALUE EV_STAT_VAL, EV.STATISTIC_TYPE EV_STAT_TYPE
FROM @OHDSI_schema.DRUG_HOI_RELATIONSHIP AS REL INNER JOIN @OHDSI_schema.DRUG_HOI_EVIDENCE AS EV
ON REL.ID = EV.DRUG_HOI_RELATIONSHIP
WHERE REL.DRUG = @id
ORDER BY 1,2,3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT EV.EVIDENCE_TYPE EV_TYPE, EV.MODALITY EV_MODALITY, EV.EVIDENCE_LINKOUT EV_LINKOUT, REL.DRUG EV_DRUG, EV.STATISTIC_VALUE EV_STAT_VAL, EV.STATISTIC_TYPE EV_STAT_TYPE
SELECT EV.EVIDENCE_TYPE EV_TYPE, EV.MODALITY EV_MODALITY, EV.EVIDENCE_LINKOUT EV_LINKOUT, REL.DRUG EV_DRUG, REL.RXNORM_DRUG EV_RXNORM_DRUG, EV.STATISTIC_VALUE EV_STAT_VAL, EV.STATISTIC_TYPE EV_STAT_TYPE
FROM @OHDSI_schema.DRUG_HOI_RELATIONSHIP AS REL INNER JOIN @OHDSI_schema.DRUG_HOI_EVIDENCE AS EV
ON REL.ID = EV.DRUG_HOI_RELATIONSHIP
WHERE REL.HOI = @id

0 comments on commit 88bdb94

Please sign in to comment.