コード例 #1
0
  static void setPatient(RcopiaUser user, RequestParameters params) throws IOException {
    long patientID = params.getInt(PATIENT_ID);
    Patient patient = null;

    if (patientID != 0) {
      // patient = user.getPatient(patientID);
      patient = Patient.create(user, user.getDb(PATIENT).getByID(patientID));
      if (patient == null)
        throw new PatientNotFoundException("Patient " + patientID + " is not in your list.");

      user.getCache().put(patient);
    } else {
      patient = getExternalPatient(user, params);
    }

    user.setPatient(patient);

    if (patient == null) {
      if (patientID == 0) {
        String externalID = params.getString(EXTERNAL_PATIENT_ID);
        throw new PatientNotFoundException("Patient " + externalID + " is not in your list.");
      } else {
        throw new PatientNotFoundException("Patient " + patientID + " is not in your list.");
      }
    }

    long linkedID = patient.getInt(LINKED_ID);
    if (linkedID != 0) {
      Patient alias = user.getPatient(linkedID);
      if (alias != null) user.setPatient(alias);
    }
  }
コード例 #2
0
  private static Patient getExternalPatient(RcopiaUser user, RequestParameters params)
      throws IOException {
    String externalID = params.getString(EXTERNAL_PATIENT_ID);
    if (Str.isEmpty(externalID)) throw new PatientNotFoundException("No patient was specified.");

    String systemName = params.getString(SYSTEM_NAME);

    PatientLocator locator = new PatientLocator(user, systemName);
    Patient patient = locator.getByXref(externalID);
    return patient;
  }