-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2074 : Unify RESTful API for Patient Management services for own…
… and external archives
- Loading branch information
1 parent
c7bd005
commit e374091
Showing
3 changed files
with
89 additions
and
39 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -65,12 +65,14 @@ | |
import javax.json.stream.JsonGenerator; | ||
import javax.json.stream.JsonParsingException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.validation.constraints.Pattern; | ||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.StreamingOutput; | ||
import java.io.*; | ||
import java.net.ConnectException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* @author Vrinda Nayak <[email protected]> | ||
|
@@ -112,9 +114,31 @@ public Response createPatient(InputStream in) { | |
} | ||
|
||
@PUT | ||
@Path("/{priorPatientID}") | ||
@Consumes({"application/dicom+json,application/json"}) | ||
@Produces("application/json") | ||
public Response updatePatient(InputStream in) { | ||
public Response updatePatient( | ||
@PathParam("priorPatientID") IDWithIssuer priorPatientID, | ||
@QueryParam("merge") @Pattern(regexp = "true|false") @DefaultValue("false") String merge, | ||
InputStream in) { | ||
logRequest(); | ||
String msgType = "ADT^A31^ADT_A05"; | ||
PatientMgtContext ctx = toPatientMgtContext(toAttributes(in)); | ||
IDWithIssuer patientID = ctx.getPatientID(); | ||
boolean mergePatients = Boolean.parseBoolean(merge); | ||
if (!patientID.equals(priorPatientID)) { | ||
ctx.setPreviousAttributes(priorPatientID.exportPatientIDWithIssuer(null)); | ||
msgType = mergePatients ? "ADT^A40^ADT_A39" : "ADT^A47^ADT_A30"; | ||
} else if (mergePatients) | ||
return errResponse("Circular merge of patients not allowed.", Response.Status.BAD_REQUEST); | ||
|
||
return scheduleOrSendHL7(msgType, ctx); | ||
} | ||
|
||
@PUT | ||
@Consumes({"application/dicom+json,application/json"}) | ||
@Produces("application/json") | ||
public Response updatePatient1(InputStream in) { | ||
logRequest(); | ||
return scheduleOrSendHL7("ADT^A31^ADT_A05", toPatientMgtContext(toAttributes(in))); | ||
} | ||
|
@@ -128,7 +152,7 @@ private PatientMgtContext toPatientMgtContext(Attributes attrs) { | |
|
||
private Attributes toAttributes(InputStream in) { | ||
try { | ||
return new JSONReader(Json.createParser(new InputStreamReader(in, "UTF-8"))) | ||
return new JSONReader(Json.createParser(new InputStreamReader(in, StandardCharsets.UTF_8))) | ||
.readDataset(null); | ||
} catch (JsonParsingException e) { | ||
throw new WebApplicationException(errResponse( | ||
|
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
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