/** * Updates the {@code patient} with provided {@code patientJson JSON data}. * * @param patient the {@link Patient} to update * @param eid the external identifier for the patient * @param patientJson the patient data as {@link JSONObject} * @return a response with no content if patient update is successful, an error code otherwise */ private Response updatePatientWithJsonData(final Patient patient, final String eid, final JSONObject patientJson) { // Check that internal ids are not conflicting. if (hasInternalIdConflict(patientJson, patient)) { return Response.status(Status.CONFLICT).build(); } // Since we're creating a new patient, if eid is not provided in patientJson, use the eid that was passed in if (!patientJson.has(EID_LABEL)) { patientJson.put(EID_LABEL, eid); } patient.updateFromJSON(patientJson); return Response.noContent().build(); }
/** * Import a new patient from its JSON representation. * * @param json the JSON representation of the new patient * @return the location of the newly created patient, if successful * @throws WebApplicationException if a {@link JSONObject} cannot be created * @throws NullPointerException if the patient was not created */ private Response addPatient(final String json) { JSONObject jsonObject; try { jsonObject = new JSONObject(json); } catch (Exception ex) { throw new WebApplicationException(Status.BAD_REQUEST); } final Patient patient = this.repository.create(); patient.updateFromJSON(jsonObject); return buildCreatedResponse(patient); }
patient.updateFromJSON(jsonObject); createdPatientUri.put(UriBuilder.fromUri(this.uriInfo.getBaseUri()) .path(PatientResource.class)
patient.updateFromJSON(jsonInput, policy); } catch (Exception ex) { this.logger.warn("Failed to update patient [{}] from JSON: {}. Source JSON was: {}", patient.getId(),
patient.updateFromJSON(jsonInput, policy); } catch (Exception ex) { this.slf4Jlogger.warn("Failed to update patient [{}] from JSON: {}. Source JSON was: {}", patient.getId(),
patient.updateFromJSON(jsonInput, policy); } catch (Exception ex) { this.slf4Jlogger.warn("Failed to update patient [{}] from JSON: {}. Source JSON was: {}", patient.getId(),
private void updatePatientsFromJson(Pedigree pedigree, User updatingUser) { String idKey = "id"; try { List<JSONObject> patientsJson = this.pedigreeConverter.convert(pedigree); for (JSONObject singlePatient : patientsJson) { if (singlePatient.has(idKey)) { Patient patient = this.patientRepository.get(singlePatient.getString(idKey)); if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocument())) { // skip patients the current user does not have edit rights for continue; } patient.updateFromJSON(singlePatient); } } } catch (Exception ex) { throw new PTInternalErrorException(); } }
private void updatePatientsFromJson(Pedigree pedigree, User updatingUser) { String idKey = "id"; try { List<JSONObject> patientsJson = this.pedigreeConverter.convert(pedigree); for (JSONObject singlePatient : patientsJson) { if (singlePatient.has(idKey)) { Patient patient = this.patientRepository.get(singlePatient.getString(idKey)); if (!this.authorizationService.hasAccess( updatingUser, Right.EDIT, patient.getDocumentReference())) { // skip patients the current user does not have edit rights for continue; } patient.updateFromJSON(singlePatient); } } } catch (Exception ex) { throw new PTInternalErrorException(); } }
affectedPatient.updateFromJSON(patientData);
affectedPatient.updateFromJSON(patientData);