Package org.openmrs

Examples of org.openmrs.Encounter


    public ModelAndView handleRequest(@RequestParam("encounterId") Integer encounterId,
                      @RequestParam("htmlFormId") Integer htmlFormId,
                                      @RequestParam(value="reason", required=false) String reason,
                                      @RequestParam(value="returnUrl", required=false) String returnUrl,
                                      HttpServletRequest request) throws Exception {
        Encounter enc = Context.getEncounterService().getEncounter(encounterId);
        Integer ptId = enc.getPatientId();
        HtmlFormEntryService hfes = Context.getService(HtmlFormEntryService.class);
        HtmlForm form = hfes.getHtmlForm(htmlFormId);
        HtmlFormEntryUtil.voidEncounter(enc, form, reason);
        Context.getEncounterService().saveEncounter(enc);
        if (!StringUtils.hasText(returnUrl)) {
View Full Code Here


        //discontinue date
        request.setParameter("w15", dateAsString(date));
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(
View Full Code Here

        //frequency
        request.setParameter("w13", "1");
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, containsInAnyOrder(
View Full Code Here

        //discontinue date
        request.setParameter("w15", dateAsString(newDiscontinueDate));
      }
     
      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();
       
        List<Order> orders = getOrderedOrders(editedEncounter);
       
        Drug drug = Context.getConceptService().getDrug(2);
        assertThat(orders, contains(
View Full Code Here

        //care setting
        request.setParameter("w15", "2");
      }

      public void testEditedResults(SubmissionResults results) {
        Encounter editedEncounter = results.getEncounterCreated();

        Drug drug2 = Context.getConceptService().getDrug(2);
        Drug drug3 = Context.getConceptService().getDrug(3);

        Set<Order> orders = new HashSet<Order>(editedEncounter.getOrders());
        for (Iterator<Order> it = orders.iterator(); it.hasNext();) {
          Order order = it.next();
          if (order.isVoided()) {
            it.remove();
          }
View Full Code Here

    else if ("edit".equalsIgnoreCase(modeParam)) {
            mode = Mode.EDIT;           
    }

        Patient patient = null;
      Encounter encounter = null;
      Form form = null;
      HtmlForm htmlForm = null;

      if (StringUtils.hasText(request.getParameter("encounterId"))) {
       
        Integer encounterId = Integer.valueOf(request.getParameter("encounterId"));
        encounter = Context.getEncounterService().getEncounter(encounterId);
        if (encounter == null)
          throw new IllegalArgumentException("No encounter with id=" + encounterId);
        patient = encounter.getPatient();
        patientId = patient.getPatientId();
            personId = patient.getPersonId();
           
            if (formId != null) { // I think formId is allowed to differ from encounter.form.id because of HtmlFormFlowsheet
                form = Context.getFormService().getForm(formId);
                htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(form);
                if (htmlForm == null)
                throw new IllegalArgumentException("No HtmlForm associated with formId " + formId);
            } else {
              form = encounter.getForm();
                htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(encounter.getForm());
                if (htmlForm == null)
                throw new IllegalArgumentException("The form for the specified encounter (" + encounter.getForm() + ") does not have an HtmlForm associated with it");
            }

      } else { // no encounter specified

        // get person from patientId/personId (register module uses patientId, htmlformentry uses personId)
View Full Code Here

  @ResponseBody
  public Object createNewEncounter(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response)
          throws ResponseException {
    initEncounterController();
    validatePost(post);
    Encounter encounter = createEncounterFromPost(post);
    return RestUtil.created(response, getEncounterAsSimpleObject(encounter));
  }
View Full Code Here

   * Creates an encounter based on fields in the post object
   * @param post
   * @return
   */
  private Encounter createEncounterFromPost(SimpleObject post) throws ResponseException {
    Encounter encounter = new Encounter();
    encounter.setPatient(Context.getPatientService().getPatientByUuid(post.get("patient").toString()));
    for (int i = 0; i < DATE_FORMATS.length; i++) {
      try {
        Date date = new SimpleDateFormat(DATE_FORMATS[i]).parse(post.get("encounterDatetime").toString());
        //Openmrs doesn't allow future encounters
        if (date.after(new Date())) {
          encounter.setEncounterDatetime(new Date());
          break;
        } else {
          encounter.setEncounterDatetime(date);
          break;
        }
      }
      catch (Exception ex) {}
    }
    encounter.setEncounterType(service.getEncounterTypeByUuid(post.get("encounterType").toString()));
    if (post.get("location") != null) {
      encounter.setLocation(Context.getLocationService().getLocationByUuid(post.get("location").toString()));
    }
    if (post.get("provider") != null) {
      encounter.setProvider(Context.getPersonService().getPersonByUuid(post.get("provider").toString()));
    }
    //if no provider is given in the post, set as the current user
    else {
      encounter.setProvider(Context.getAuthenticatedUser().getPerson());
    }
    Encounter newEncounter = service.saveEncounter(encounter);
    if (post.get("obs") != null) {
      createObsFromPost(post, newEncounter);
    }
    if (post.get("orders") != null) {
      createOrdersFromPost(post, newEncounter);
View Full Code Here

  @WSDoc("Gets Full representation of Encounter for the uuid path")
  @ResponseBody()
  public String getEncounterByUuidFull(@PathVariable("uuid") String uuid, HttpServletRequest request)
          throws ResponseException {
    initEncounterController();
    Encounter encounter = service.getEncounterByUuid(uuid);
    SimpleObject obj = getEncounterAsSimpleObject(encounter);
    return gson.toJson(obj);
  }
View Full Code Here

            @Override
            public void testEditedResults(SubmissionResults results) {

                results.assertNoErrors();
                Encounter encounter = results.getEncounterCreated();

                assertThat(encounter.getAllObs(false).size(), is(2));   // should be two non-voided obs of value 1002 & 1003
                assertThat(encounter.getAllObs(true).size(), is(3));   // should be three obs included the voided obs for 1001

                Set<Integer> valueCoded = new HashSet<Integer>();


                for (Obs obs : encounter.getAllObs(true)) {
                    if (obs.isVoided()) {
                        assertThat(obs.getValueCoded().getId(), is(1001));
                    }
                    else {
                        valueCoded.add(obs.getValueCoded().getId());
View Full Code Here

TOP

Related Classes of org.openmrs.Encounter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.