Package org.openmrs

Examples of org.openmrs.Patient


    e.setEncounterDatetime(date);
    e.setLocation(Context.getLocationService().getLocation(2));
    e.setProvider(Context.getPersonService().getPerson(502));
   
    //And, add some drugOrders
    Patient p = Context.getPatientService().getPatient(2);
    Set<Order> dos = RegimenUtil.standardRegimenToDrugOrders(regList.get(0), new Date(), p);
    Assert.assertTrue(dos.size() == 2);
    for (Order o : dos)
      e.addOrder(o);
   
View Full Code Here


    e.setEncounterDatetime(date);
    e.setLocation(Context.getLocationService().getLocation(2));
    e.setProvider(Context.getPersonService().getPerson(502));
   
    //And, add some drugOrders
    Patient p = Context.getPatientService().getPatient(2);
    Set<Order> dos = RegimenUtil.standardRegimenToDrugOrders(RegimenUtil.getStandardRegimenByCode(regList, code), new Date(), p);
    for (Order o : dos)
      e.addOrder(o);
   
    //save the encounter
View Full Code Here

  public void testFormEditSessionAttribute(FormEntrySession formEntrySession) {
  }

  public void run() throws Exception {
    // setup the blank form for the specified patient
    Patient patient = getPatient();
    FormEntrySession session = setupFormEntrySession(patient, getFormName());
    testFormEntrySessionAttribute(session);
    String html = session.getHtmlToDisplay();
    testBlankFormHtml(html);

    // submit some initial data and test it
    Map<String, String> labeledWidgets = getLabeledWidgets(html, widgetLabels());
    MockHttpServletRequest request = new MockHttpServletRequest();
        request.setSession(session.getHttpSession());
    setupRequest(request, labeledWidgets);
    Patient patientToView = null;
    Encounter encounterToView = null;
    if (request.getParameterMap().size() > 0) {
      SubmissionResults results = doSubmission(session, request);
      testResults(results);
      patientToView = results.getPatient();
      encounterToView = results.getEncounterCreated();
    }

    // view that patient and run tests on it
    Patient overridePatient = getPatientToView();
    boolean doViewPatient = overridePatient != null || doViewPatient();
    if (doViewPatient) {
      if (overridePatient != null)
        patientToView = overridePatient;
      session = setupFormViewSession(patientToView, null, getFormName());
      testFormViewSessionAttribute(session);
      html = session.getHtmlToDisplay();
      testViewingPatient(patientToView, html);
    }

    // view that encounter and run tests on that
    Encounter override = getEncounterToView();
    boolean doViewEncounter = override != null || doViewEncounter();
    if (doViewEncounter) {
      if (override != null)
        encounterToView = override;

      session = setupFormViewSession(patientToView, encounterToView, getFormName());
      testFormViewSessionAttribute(session);
      html = session.getHtmlToDisplay();
      testViewingEncounter(encounterToView, html);
    }

    // edit the encounter, and run tests on that
    override = getEncounterToEdit();
    boolean doEditEncounter = override != null || doEditEncounter();

    overridePatient = getPatientToEdit();
    boolean doEditPatient = overridePatient != null || doEditPatient();

    if (doEditEncounter || doEditPatient) {
      Encounter toEdit = encounterToView;
      if (override != null)
        toEdit = override;

      Patient patientToEdit = patientToView;
      if (overridePatient != null)
        patientToEdit = overridePatient;

      session = setupFormEditSession(patientToEdit, toEdit, getFormName());
      testFormEditSessionAttribute(session);
View Full Code Here

   * Creates a non-persistent "Fake" Person (used when previewing or validating an HTML Form)
   *
   * @return the "fake" person
   */
  public static Patient getFakePerson() {
    Patient demo = new Patient(12345);
    demo.addName(new PersonName("Demo", "The", "Person"));
    Location l = Context.getLocationService().getAllLocations().iterator().next();
    for (PatientIdentifierType pit : Context.getPatientService().getAllPatientIdentifierTypes()) {
      if (StringUtils.isEmpty(pit.getValidator())) {
        demo.addIdentifier(new PatientIdentifier("Testing" + pit.getName() + "123", pit, l));
      }
    }
    demo.setGender("F");
    demo.setUuid("testing-html-form-entry");
    {
      Calendar cal = Calendar.getInstance();
      cal.add(Calendar.YEAR, -31);
      demo.setBirthdate(cal.getTime());
    }
   
    for (PersonAttributeType type : Context.getPersonService().getAllPersonAttributeTypes()) {
      if (type.getFormat() != null && type.getFormat().equals("java.lang.String")) {
        demo.addAttribute(new PersonAttribute(type, "Test " + type.getName() + " Attribute"));
      }
    }
    PersonAddress addr = new PersonAddress();
    addr.setCityVillage("Rwinkwavu");
    addr.setCountyDistrict("Kayonza District");
    addr.setStateProvince("Eastern Province");
    addr.setCountry("Rwanda");
    demo.addAddress(addr);
    return demo;
  }
View Full Code Here

        // TODO wrap this in a transaction
        if (submissionActions.getPersonsToCreate() != null) {
            for (Person p : submissionActions.getPersonsToCreate()) {
                if (p instanceof Patient) {
                    Patient patient = (Patient) p;
                    PatientIdentifier patientIdentifier = patient.getPatientIdentifier();
                    if (!StringUtils.hasText(patient.getGivenName()) || !StringUtils.hasText(patient.getFamilyName())
                            || !StringUtils.hasText(patient.getGender()) || patient.getBirthdate() == null
                            || patientIdentifier == null || !StringUtils.hasText(patientIdentifier.getIdentifier())
                            || patientIdentifier.getIdentifierType() == null || patientIdentifier.getLocation() == null) {
                        throw new BadFormDesignException(
                                "Please check the design of your form to make sure the following fields are mandatory to create a patient: <br/><b>&lt;personName/&gt;</b>, <b>&lt;birthDateOrAge/&gt;</b>, <b>&lt;gender/&gt;</b>, <b>&lt;identifierType/&gt;</b>, <b>&lt;identifier/&gt;</b>, and <b>&lt;identifierLocation/&gt;</b>");
                    }
View Full Code Here

   */
    public void enrollInProgram(Program program, Date enrollmentDate, List<ProgramWorkflowState> states) {
    if (program == null)
      throw new IllegalArgumentException("Cannot enroll in a blank program");
   
    Patient patient = highestOnStack(Patient.class);
    if (patient == null)
      throw new IllegalArgumentException("Cannot enroll in a program outside of a Patient");
    Encounter encounter = highestOnStack(Encounter.class);
   
    // if an enrollment date has not been specified, enrollment date is the encounter date
View Full Code Here

   */
  public void completeProgram(Program program) {
    if (program == null)
      throw new IllegalArgumentException("Cannot end a blank program");
   
    Patient patient = highestOnStack(Patient.class);
    if (patient == null)
      throw new IllegalArgumentException("Cannot find program without a patient");
    Encounter encounter = highestOnStack(Encounter.class);
    if (encounter == null)
      throw new IllegalArgumentException("Cannot end enrollment in a program outside of an Encounter");
View Full Code Here

 
  public void transitionToState(ProgramWorkflowState state) {
    if (state == null)
      throw new IllegalArgumentException("Cannot change to a blank state");
   
    Patient patient = highestOnStack(Patient.class);
    if (patient == null)
      throw new IllegalArgumentException("Cannot change state without a patient");
    Encounter encounter = highestOnStack(Encounter.class);
    if (encounter == null)
      throw new IllegalArgumentException("Cannot change state without an Encounter");
View Full Code Here

 
  @Test
  public void enrollInProgram_shouldNotEnrollAPatientIfAlreadyEnrolledOnTheSelectedDate() throws Exception {
    final Integer patientId = 6;
    final Integer programId = 10;
    final Patient patient = Context.getPatientService().getPatient(patientId);
    Assert.assertEquals(0, pws.getPatientPrograms(patient, pws.getProgram(programId), null, null, null, null, false)
            .size());
    //enroll the patient in a test program
    PatientProgram pp = new PatientProgram();
    pp.setPatient(patient);
View Full Code Here

      }
     
      @Override
      public Encounter getEncounterToView(){
        Encounter e = new Encounter();
        Patient p = Context.getPatientService().getPatient(2);
        e.setPatient(p);
        e.setEncounterDatetime(date);
        e.setProvider(Context.getPersonService().getPerson(502));
        e.setEncounterType(Context.getEncounterService().getEncounterType(1));
        e.setLocation(Context.getLocationService().getLocation(2));
View Full Code Here

TOP

Related Classes of org.openmrs.Patient

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.