예제 #1
0
  public Result updateVitalsPost(int id) {

    CurrentUser currentUser = sessionService.getCurrentUserSession();

    ServiceResponse<IPatientEncounter> currentEncounterByPatientId =
        searchService.findCurrentEncounterByPatientId(id);

    UpdateVitalsModel updateVitalsModel = updateVitalsModelForm.bindFromRequest().get();

    List<? extends IPatientEncounterVital> patientEncounterVitals =
        medicalHelper.populatePatientVitals(
            updateVitalsModel,
            currentUser.getId(),
            currentEncounterByPatientId.getResponseObject().getId());
    ServiceResponse<IPatientEncounterVital> patientEncounterVitalServiceResponse;
    for (int i = 0; i < patientEncounterVitals.size(); i++) {
      if (patientEncounterVitals.get(i).getVitalValue() > 0) {
        patientEncounterVitalServiceResponse =
            triageService.createPatientEncounterVital(patientEncounterVitals.get(i));
        if (patientEncounterVitalServiceResponse.hasErrors()) {
          return internalServerError();
        }
      }
    }
    return ok("true");
  }
예제 #2
0
  public Result indexGet(Integer patientId, String message) {

    CurrentUser currentUserSession = sessionService.getCurrentUserSession();

    return ok(index.render(currentUserSession, message, patientId));
  }
예제 #3
0
  public Result editPost(int patientId) {

    CurrentUser currentUserSession = sessionService.getCurrentUserSession();

    CreateViewModelPost viewModelPost = createViewModelPostForm.bindFromRequest().get();

    ServiceResponse<IPatientEncounter> patientEncounterServiceResponse =
        searchService.findCurrentEncounterByPatientId(patientId);
    if (patientEncounterServiceResponse.hasErrors()) {
      return internalServerError();
    }
    IPatientEncounter patientEncounter = patientEncounterServiceResponse.getResponseObject();

    // HPI Data
    List<IPatientEncounterHpiField> patientEncounterHpiFields =
        medicalHelper.populateHpiFields(viewModelPost, patientEncounter, currentUserSession);
    ServiceResponse<IPatientEncounterHpiField> patientEncounterHpiFieldServiceResponse;
    for (int j = 0; j < patientEncounterHpiFields.size(); j++) {
      if (StringUtils.isNullOrWhiteSpace(patientEncounterHpiFields.get(j).getHpiFieldValue())) {
        continue;
      } else {
        patientEncounterHpiFieldServiceResponse =
            medicalService.createPatientEncounterHpiField(patientEncounterHpiFields.get(j));
        if (patientEncounterHpiFieldServiceResponse.hasErrors()) {
          return internalServerError();
        }
      }
    }
    // Treatment Data
    List<IPatientEncounterTreatmentField> patientEncounterTreatmentFields =
        medicalHelper.populateTreatmentFields(viewModelPost, patientEncounter, currentUserSession);
    ServiceResponse<IPatientEncounterTreatmentField> patientEncounterTreatmentFieldServiceResponse;
    for (int i = 0; i < patientEncounterTreatmentFields.size(); i++) {
      if (StringUtils.isNullOrWhiteSpace(
          patientEncounterTreatmentFields.get(i).getTreatmentFieldValue())) {
        continue;
      } else {
        patientEncounterTreatmentFieldServiceResponse =
            medicalService.createPatientEncounterTreatmentField(
                patientEncounterTreatmentFields.get(i));
        if (patientEncounterTreatmentFieldServiceResponse.hasErrors()) {
          return internalServerError();
        }
      }
    }
    // prescriptions
    List<IPatientPrescription> patientPrescriptions =
        medicalHelper.populatePatientPrescriptions(
            viewModelPost, patientEncounter, currentUserSession);
    ServiceResponse<IPatientPrescription> patientPrescriptionServiceResponse;
    for (int k = 0; k < patientPrescriptions.size(); k++) {
      if (StringUtils.isNullOrWhiteSpace(patientPrescriptions.get(k).getMedicationName())) {
        continue;
      } else {
        patientPrescriptionServiceResponse =
            medicalService.createPatientPrescription(patientPrescriptions.get(k));
        if (patientPrescriptionServiceResponse.hasErrors()) {
          return internalServerError();
        }
      }
    }
    return redirect(routes.MedicalController.indexGet(0, null));
  }
예제 #4
0
  public Result editGet(int patientId) {

    CurrentUser currentUserSession = sessionService.getCurrentUserSession();

    // current Patient info for view model
    ServiceResponse<IPatient> patientServiceResponse = searchService.findPatientById(patientId);
    if (patientServiceResponse.hasErrors()) {
      // this error should have been caught by searchPost
      return internalServerError();
    }
    IPatient patient = patientServiceResponse.getResponseObject();

    // current Encounter info for view model
    ServiceResponse<IPatientEncounter> patientEncounterServiceResponse =
        searchService.findCurrentEncounterByPatientId(patientId);
    if (patientEncounterServiceResponse.hasErrors()) {
      return internalServerError();
    }
    IPatientEncounter patientEncounter = patientEncounterServiceResponse.getResponseObject();

    // current vitals for view model
    List<IPatientEncounterVital> patientEncounterVitals = new ArrayList<>();
    ServiceResponse<IPatientEncounterVital> patientEncounterVitalServiceResponse;
    int TOTAL_VITALS = 9;
    for (int vital = 1; vital <= TOTAL_VITALS; vital++) {
      patientEncounterVitalServiceResponse =
          searchService.findPatientEncounterVitalByVitalIdAndEncounterId(
              vital, patientEncounter.getId());
      if (patientEncounterVitalServiceResponse.hasErrors()) {
        patientEncounterVitals.add(null);
      } else {
        patientEncounterVitals.add(patientEncounterVitalServiceResponse.getResponseObject());
      }
    }

    // viewModelPost is populated with editable fields
    ServiceResponse<List<? extends IPatientPrescription>> patientPrescriptionsServiceResponse =
        searchService.findPrescriptionsByEncounterId(patientEncounter.getId());
    List<? extends IPatientPrescription> patientPrescriptions = new ArrayList<>();
    if (patientPrescriptionsServiceResponse.hasErrors()) {
      // do nothing, there might not always be available prescriptions
    } else {
      patientPrescriptions = patientPrescriptionsServiceResponse.getResponseObject();
    }

    ServiceResponse<Map<Integer, List<? extends IPatientEncounterTreatmentField>>>
        patientTreatmentFieldsServiceResponse =
            searchService.findTreatmentFieldsByEncounterId(patientEncounter.getId());
    Map<Integer, List<? extends IPatientEncounterTreatmentField>> patientEncounterTreatmentMap =
        new LinkedHashMap<>();
    if (patientTreatmentFieldsServiceResponse.hasErrors()) {
      // do nothing, there might not always be available treatments
    } else {
      patientEncounterTreatmentMap = patientTreatmentFieldsServiceResponse.getResponseObject();
    }

    ServiceResponse<Map<Integer, List<? extends IPatientEncounterHpiField>>>
        patientHpiFieldsServiceResponse =
            searchService.findHpiFieldsByEncounterId(patientEncounter.getId());
    Map<Integer, List<? extends IPatientEncounterHpiField>> patientEncounterHpiMap =
        new LinkedHashMap<>();
    if (patientHpiFieldsServiceResponse.hasErrors()) {
      // do nothing, there might not always be available hpi fields
    } else {
      patientEncounterHpiMap = patientHpiFieldsServiceResponse.getResponseObject();
    }
    CreateViewModelPost viewModelPost =
        medicalHelper.populateViewModelPost(
            patientPrescriptions, patientEncounterTreatmentMap, patientEncounterHpiMap);
    CreateViewModelGet viewModelGet =
        medicalHelper.populateViewModelGet(
            patient, patientEncounter, patientEncounterVitals, viewModelPost);
    return ok(edit.render(currentUserSession, viewModelGet));
  }