Unverified Commit 94e60bf9 authored by Niklas Reimer's avatar Niklas Reimer Committed by GitHub
Browse files

Merge pull request #192 from nr23730/regexId

Regex
parents 78c10584 d522b9a0
......@@ -89,6 +89,7 @@ public class JsonFhirMapper {
private static String patientUri;
private static String therapyRecommendationUri;
private static String mtbUri;
private static List<Regex> regex;
private FhirContext ctx = FhirContext.forR4();
private IGenericClient client;
......@@ -113,6 +114,7 @@ public class JsonFhirMapper {
patientUri = settings.getPatientSystem();
mtbUri = settings.getDiagnosticReportSystem();
therapyRecommendationUri = settings.getObservationSystem();
regex = settings.getRegex();
}
/**
......@@ -171,7 +173,8 @@ public class JsonFhirMapper {
// REBIOPSY HERE
mtb.getSamples().clear();
for (Reference specimen : diagnosticReport.getSpecimen()) {
mtb.getSamples().add(((Specimen) specimen.getResource()).getIdentifierFirstRep().getValue());
mtb.getSamples().add(
applyRegexToCbioportal(((Specimen) specimen.getResource()).getIdentifierFirstRep().getValue()));
}
for (Reference reference : diagnosticReport.getResult()) {
......@@ -204,7 +207,7 @@ public class JsonFhirMapper {
ClinicalDatum cd = new ClinicalDatum().withAttributeName(attr[0]).withValue(attr[1]);
if (obs.getSpecimen().getResource() != null) {
Specimen specimen = (Specimen) obs.getSpecimen().getResource();
cd.setSampleId(specimen.getIdentifierFirstRep().getValue());
cd.setSampleId(applyRegexToCbioportal(specimen.getIdentifierFirstRep().getValue()));
}
therapyRecommendation.getReasoning().getClinicalData()
.add(cd);
......@@ -417,10 +420,11 @@ public class JsonFhirMapper {
}
mtb.getSamples().forEach(sample -> {
Specimen s = specimenAdapter.process(fhirPatient, sample);
String sampleId = applyRegexFromCbioportal(sample);
Specimen s = specimenAdapter.process(fhirPatient, sampleId);
bundle.addEntry().setFullUrl(s.getIdElement().getValue()).setResource(s)
.getRequest().setUrl("Specimen?identifier=https://cbioportal.org/specimen/|" + sample)
.setIfNoneExist("identifier=identifier=https://cbioportal.org/specimen/|" + sample)
.getRequest().setUrl("Specimen?identifier=https://cbioportal.org/specimen/|" + sampleId)
.setIfNoneExist("identifier=identifier=https://cbioportal.org/specimen/|" + sampleId)
.setMethod(Bundle.HTTPVerb.PUT);
diagnosticReport.addSpecimen(new Reference(s));
});
......@@ -461,12 +465,13 @@ public class JsonFhirMapper {
therapyRecommendation.getReasoning().getClinicalData().forEach(clinical -> {
Specimen s = null;
if (clinical.getSampleId() != null && clinical.getSampleId().length() > 0) {
s = specimenAdapter.process(fhirPatient, clinical.getSampleId());
String sampleId = applyRegexFromCbioportal(clinical.getSampleId());
s = specimenAdapter.process(fhirPatient, sampleId);
bundle.addEntry().setFullUrl(s.getIdElement().getValue()).setResource(s)
.getRequest().setUrl("Specimen?identifier=https://cbioportal.org/specimen/|"
+ clinical.getSampleId())
+ sampleId)
.setIfNoneExist("identifier=identifier=https://cbioportal.org/specimen/|"
+ clinical.getSampleId()).setMethod(Bundle.HTTPVerb.PUT);
+ sampleId).setMethod(Bundle.HTTPVerb.PUT);
}
try {
Method m = Class.forName("fhirspark.adapter.clinicaldata." + clinical.getAttributeId())
......@@ -643,6 +648,22 @@ public class JsonFhirMapper {
}
}
private String applyRegexToCbioportal(String input) {
String output = input;
for (Regex r : regex) {
output = output.replaceAll(r.getHis(), r.getCbio());
}
return output;
}
private String applyRegexFromCbioportal(String input) {
String output = input;
for (Regex r : regex) {
output = output.replaceAll(r.getCbio(), r.getHis());
}
return output;
}
/**
* Fetched Pubmed IDs that have been previously associated with the same alteration.
*
......
package fhirspark;
/**
* Regular expressions to convert cBioPortal IDs to HIS IDs.
*/
public class Regex {
private String cbio;
private String his;
public String getCbio() {
return cbio;
}
public void setCbio(String cbio) {
this.cbio = cbio;
}
public String getHis() {
return his;
}
public void setHis(String his) {
this.his = his;
}
}
......@@ -21,7 +21,8 @@ import java.util.List;
"portalUrl",
"loginRequired",
"oncokbPath",
"hl7v2config"
"hl7v2config",
"regex"
})
public final class Settings {
......@@ -47,6 +48,8 @@ public final class Settings {
private String oncokbPath;
@JsonProperty("hl7v2config")
private List<Hl7v2config> hl7v2config;
@JsonProperty("regex")
private List<Regex> regex;
@JsonProperty("port")
public Integer getPort() {
......@@ -158,4 +161,14 @@ public final class Settings {
this.hl7v2config = hl7v2config;
}
@JsonProperty("regex")
public List<Regex> getRegex() {
return regex;
}
@JsonProperty("regex")
public void setRegex(List<Regex> newRegex) {
regex = newRegex;
}
}
......@@ -4,11 +4,15 @@ specimenSystem: ${FHIRSPARK_SPECIMENSYSTEM:-https://cbioportal.org/specimen/}
diagnosticReportSystem: ${FHIRSPARK_DIAGNOSTICREPORTSYSTEM:-https://cbioportal.org/mtb/}
observationSystem: ${FHIRSPARK_OBSERVATIONSYSTEM:-https://cbioportal.org/therapyrecommendation/}
patientSystem: ${FHIRSPARK_PATIENTSYSTEM:-https://cbioportal.org/patient/}
portalUrl: ${FHIRSPARK_PORTALURL:-http://cbioportal/}
loginRequired: ${FHIRSPARK_LOGINREQUIRED:-true}
portalUrl: ${FHIRSPARK_PORTALURL:-http://localhost:8080/}
loginRequired: ${FHIRSPARK_LOGINREQUIRED:-false}
hgncPath: ${FHIRSPARK_HGNCPATH:-hgnc.csv}
oncokbPath: ${FHIRSPARK_ONCOKBPATH:-drugs.json}
hl7v2config:
- sendv2: ${FHIRSPARK_SENDHL7V2:-false}
server: ${FHIRSPARK_HL7V2SERVER:-localhost}
port: ${FHIRSPARK_HL7V2PORT:-1011}
regex:
-
cbio: ${FHIRSPARK_REGEX_CBIO:-/}
his: ${FHIRSPARK_REGEX_HIS:-/}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment