Skip to content

Commit

Permalink
RM-88: PC patients with free text in diagnoses are not correctly sent…
Browse files Browse the repository at this point in the history
… over MME API

Fixed
  • Loading branch information
allasm committed Jan 16, 2018
1 parent 2452121 commit c52b163
Showing 1 changed file with 18 additions and 9 deletions.
Expand Up @@ -43,6 +43,11 @@
import org.json.JSONObject;
import org.slf4j.Logger;

/**
* Patient to MME JSON represenation conveter.
*
* See https://github.com/ga4gh/mme-apis/blob/master/search-api.md
*/
public class DefaultPatientToJSONConverter implements PatientToJSONConverter
{
private final static String PATIENTMATCHING_JSON_FEATUREMATCHES = "featureMatches";
Expand Down Expand Up @@ -298,9 +303,11 @@ private static JSONArray disorders(Patient patient)
{
JSONArray disorders = new JSONArray();
for (Disorder disease : patient.getDisorders()) {
JSONObject disorderJson = new JSONObject();
disorderJson.put(ApiConfiguration.JSON_DISORDER_ID, disease.getId());
disorders.put(disorderJson);
if (!StringUtils.isBlank(disease.getId())) {
JSONObject disorderJson = new JSONObject();
disorderJson.put(ApiConfiguration.JSON_DISORDER_ID, disease.getId());
disorders.put(disorderJson);
}
}
return disorders;
}
Expand All @@ -313,9 +320,11 @@ private static JSONArray clinicalDisorders(Patient patient)
Iterator<Disorder> iterator = data.iterator();
while (iterator.hasNext()) {
Disorder disorder = iterator.next();
JSONObject disorderJson = new JSONObject();
disorderJson.put(ApiConfiguration.JSON_DISORDER_ID, disorder.getId());
disorders.put(disorderJson);
if (!StringUtils.isBlank(disorder.getId())) {
JSONObject disorderJson = new JSONObject();
disorderJson.put(ApiConfiguration.JSON_DISORDER_ID, disorder.getId());
disorders.put(disorderJson);
}
}
}
return disorders;
Expand Down Expand Up @@ -348,10 +357,10 @@ private static JSONArray genes(Patient patient, int includedTopGenes, Logger log
JSONObject gene = new JSONObject();
gene.put(ApiConfiguration.JSON_GENES_GENE_ID, geneName);

JSONObject nextGene = new JSONObject();
nextGene.put(ApiConfiguration.JSON_GENES_GENE, gene);
JSONObject nextGenomicFeature = new JSONObject();
nextGenomicFeature.put(ApiConfiguration.JSON_GENES_GENE, gene);

genes.put(nextGene);
genes.put(nextGenomicFeature);
}
} catch (Exception ex) {
logger.error("Error getting genes for patient [{}]: [{}]", patient.getId(), ex);
Expand Down

0 comments on commit c52b163

Please sign in to comment.