-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for mrn to cmo/dmp patient id mapping
- Loading branch information
Showing
5 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
model/src/main/java/org/mskcc/smile/model/web/CrdbCrosswalkTriplet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.mskcc.smile.model.web; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import org.apache.commons.lang.builder.ToStringBuilder; | ||
|
||
@Entity | ||
public class CrdbCrosswalkTriplet implements Serializable { | ||
@Id | ||
private String dmpId; | ||
private String cmoId; | ||
private String ptMrn; | ||
|
||
public CrdbCrosswalkTriplet() {} | ||
|
||
/** | ||
* CrdbCrosswalkTriplet constructor | ||
* @param crdbValues | ||
* @throws JsonProcessingException | ||
*/ | ||
public CrdbCrosswalkTriplet(ArrayList<Object> crdbValues) throws Exception { | ||
this.dmpId = crdbValues.get(1).toString(); | ||
this.cmoId = crdbValues.get(0).toString(); | ||
this.ptMrn = crdbValues.get(2).toString(); | ||
} | ||
|
||
public String getDmpId() { | ||
return dmpId; | ||
} | ||
|
||
public void setDmpId(String dmpId) { | ||
this.dmpId = dmpId; | ||
} | ||
|
||
public String getCmoId() { | ||
return cmoId; | ||
} | ||
|
||
public void setCmoId(String cmoId) { | ||
this.cmoId = cmoId; | ||
} | ||
|
||
public String getPtMrn() { | ||
return ptMrn; | ||
} | ||
|
||
public void setPtMrn(String ptMrn) { | ||
this.ptMrn = ptMrn; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
service/src/main/java/org/mskcc/smile/service/CrdbMappingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package org.mskcc.smile.service; | ||
|
||
import org.mskcc.smile.model.internal.CrdbMappingModel; | ||
import org.mskcc.smile.model.web.CrdbCrosswalkTriplet; | ||
|
||
public interface CrdbMappingService { | ||
String getCmoPatientIdbyDmpId(String dmpId); | ||
String getCmoPatientIdByInputId(String inputId); | ||
CrdbMappingModel getCrdbMappingModelByInputId(String inputId) throws Exception; | ||
CrdbCrosswalkTriplet getCrdbCrosswalkTripletByInputId(String inputId) throws Exception; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
web/src/main/java/org/mskcc/smile/web/CrosswalkController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.mskcc.smile.web; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.mskcc.smile.model.web.CrdbCrosswalkTriplet; | ||
import org.mskcc.smile.service.CrdbMappingService; | ||
import org.mskcc.smile.service.exception.SmileWebServiceException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@CrossOrigin(origins = "*") | ||
@RequestMapping(value = "/") | ||
@Api(tags = "crosswalk-controller", description = "Crosswalk Controller") | ||
@PropertySource("classpath:/maven.properties") | ||
public class CrosswalkController { | ||
|
||
@Value("${smile.schema_version}") | ||
private String smileSchemaVersion; | ||
|
||
@Autowired | ||
private CrdbMappingService crdbMappingService; | ||
|
||
@Autowired | ||
public CrosswalkController(CrdbMappingService crdbMappingService) { | ||
this.crdbMappingService = crdbMappingService; | ||
} | ||
|
||
/** | ||
* Returns a list of mrn-dmp-cmo patient id triplets given a list of MRNs. | ||
* Only triplets that exist in the crdb crosswalk table are returned. | ||
* @param mrns | ||
* @return ResponseEntity | ||
* @throws Exception | ||
*/ | ||
@ApiOperation(value = "Returns a list of mrn-dmp-cmo patient id triplets given a list of MRNs.", | ||
nickname = "fetchIDTripletListPOST") | ||
@RequestMapping(value = "/crosswalk", | ||
method = RequestMethod.POST, | ||
produces = "application/json") | ||
public ResponseEntity<List<CrdbCrosswalkTriplet>> fetchIDTripletListPOST(@ApiParam(value = | ||
"List of MRNs", required = true, allowMultiple = true) | ||
@RequestBody List<String> mrns) throws Exception { | ||
List<CrdbCrosswalkTriplet> tripletList = new ArrayList<>(); | ||
for (String mrn: mrns) { | ||
CrdbCrosswalkTriplet triplet = crdbMappingService.getCrdbCrosswalkTripletByInputId(mrn); | ||
if (triplet != null) { | ||
tripletList.add(triplet); | ||
} | ||
} | ||
return ResponseEntity.ok() | ||
.headers(responseHeaders()) | ||
.body(tripletList); | ||
} | ||
|
||
private HttpHeaders responseHeaders() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.set("smile-schema-version", smileSchemaVersion); | ||
return headers; | ||
} | ||
} |