Package org.openmrs

Examples of org.openmrs.Person


   * @param post
   * @return
   */
  private Relationship createRelationshipFromPost(SimpleObject post) throws ResponseException {
    Relationship relationship = new Relationship();
    Person a, b;
    try {
      Method method = service.getClass().getMethod("getPersonByUuidSafeSearch", String.class);
      a = (Person) method.invoke(service, post.get("fromPerson").toString());
      b = (Person) method.invoke(service, post.get("toPerson").toString());
    }
View Full Code Here


  @WSDoc("Gets Full representation of Relationships for the given parameters")
  @ResponseBody()
  public String getRelationships(@RequestParam Map<String, String> params, HttpServletRequest request)
          throws ResponseException {
    initRelationshipController();
    Person fromPerson = Context.getPersonService().getPersonByUuid(params.get("fromPerson"));
    Person toPerson = Context.getPersonService().getPersonByUuid(params.get("toPerson"));
    RelationshipType rType = Context.getPersonService().getRelationshipTypeByName(params.get("relationshipType"));
    List<Relationship> relationships = service.getRelationships(fromPerson, toPerson, rType);
    ArrayList results = new ArrayList();
    for (Relationship relationship : relationships) {
      results.add(getRelationshipAsSimpleObject(relationship));
View Full Code Here

        // as a sanity check, make sure this relationship hasn't already been created
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
        Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return parent;
      };
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Date:"), dateAsString(date));
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        // hack because person widget is a hidden input with no label 
        request.addParameter("w7", "6");
      }
     
      @Override
      public void testResults(SubmissionResults results) {
       
        // check the basics
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(2);
        Person child = Context.getPersonService().getPerson(6);
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
      }
    }.run();
  }
View Full Code Here

      public Patient getPatient() {
        // as a sanity check, make sure this relationship hasn't already been created
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(6);
        Patient child = Context.getPatientService().getPatient(2);
        Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return child;
      };
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Date:"), dateAsString(date));
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        // hack because person widget is a hidden input with no label 
        request.addParameter("w7", "6");
      }
     
      @Override
      public void testResults(SubmissionResults results) {
       
        // check the basics
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(6);
        Person child = Context.getPersonService().getPerson(2);
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
      }
    }.run();
  }
View Full Code Here

        results.assertObsCreated(8, "Bee stings");
        results.assertObsCreated(1119, date);
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(2);
        Person child = Context.getPersonService().getPerson(6);
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
      }
    }.run();
  }
View Full Code Here

       
        // now make sure all three relationships have been created
        RelationshipType type1 = Context.getPersonService().getRelationshipType(1);
        RelationshipType type2 = Context.getPersonService().getRelationshipType(4);
       
        Person person1 = Context.getPersonService().getPerson(2);
        Person person2 = Context.getPersonService().getPerson(6);
        Person person3 = Context.getPersonService().getPerson(7);
       
        Assert.assertEquals(1, Context.getPersonService().getRelationships(person1, person2, type1).size());
        Assert.assertEquals(1, Context.getPersonService().getRelationships(person2, person1, type2).size());
        Assert.assertEquals(1, Context.getPersonService().getRelationships(person1, person3, type1).size());
       
View Full Code Here

       
        // now make sure all three relationships have been created
        RelationshipType type1 = Context.getPersonService().getRelationshipType(1);
        RelationshipType type2 = Context.getPersonService().getRelationshipType(4);
       
        Person person1 = Context.getPersonService().getPerson(2);
        Person person2 = Context.getPersonService().getPerson(6);
        Person person3 = Context.getPersonService().getPerson(7);
       
        Assert.assertEquals(0, Context.getPersonService().getRelationships(person1, person2, type1).size());
        Assert.assertEquals(1, Context.getPersonService().getRelationships(person2, person1, type2).size());
        Assert.assertEquals(0, Context.getPersonService().getRelationships(person1, person3, type1).size());
       
View Full Code Here

      @Override
      public Patient getPatient() {
        // preemptively create a relationship
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
       
        Relationship rel = new Relationship(parent, child, type);
        Context.getPersonService().saveRelationship(rel);
       
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return parent;
      };
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Date:"), dateAsString(date));
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        // hack because person widget is a hidden input with no label 
        request.addParameter("w7", "6");
      }
     
      @Override
      public void testResults(SubmissionResults results) {
       
        // check the basics
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // now make sure the relationship has not been created twice
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(2);
        Person child = Context.getPersonService().getPerson(6);
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
      }
    }.run();
  }
View Full Code Here

      @Override
      public Patient getPatient() {
        // preemptively create a relationship
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
       
        Relationship rel = new Relationship(parent, child, type);
        Context.getPersonService().saveRelationship(rel);
       
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return parent;
      };
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Date:"), dateAsString(date));
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        // hack because person widget is a hidden input with no label 
        request.addParameter("w7", "7");
      }
     
      @Override
      public void testResults(SubmissionResults results) {
       
        // check the basics
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // now make sure both relationships have been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(2);
        Person child1 = Context.getPersonService().getPerson(6);
        Person child2 = Context.getPersonService().getPerson(7);
       
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child1, type).size());
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child2, type).size());
       
      }
View Full Code Here

      @Override
      public Patient getPatient() {
        // preemptively create a relationship
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
       
        Relationship rel = new Relationship(parent, child, type);
        Context.getPersonService().saveRelationship(rel);
       
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return parent;
      };
     
      @Override
      public String[] widgetLabels() {
        return new String[] { "Date:", "Location:", "Provider:", "Relationship:" };
      }
     
      @Override
      public void setupRequest(MockHttpServletRequest request, Map<String, String> widgets) {
        request.addParameter(widgets.get("Date:"), dateAsString(date));
        request.addParameter(widgets.get("Location:"), "2");
        request.addParameter(widgets.get("Provider:"), "502");
        // hack because person widget is a hidden input with no label 
        request.addParameter("w7", "7");
      }
     
      @Override
      public void testResults(SubmissionResults results) {
       
        // check the basics
        results.assertNoErrors();
        results.assertEncounterCreated();
        results.assertProvider(502);
        results.assertLocation(2);
       
        // now make sure the old the relationship is gone and the new one has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(2);
        Person child1 = Context.getPersonService().getPerson(6);
        Person child2 = Context.getPersonService().getPerson(7);
       
        Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child1, type).size());
        Assert.assertEquals(1, Context.getPersonService().getRelationships(parent, child2, type).size());
       
      }
View Full Code Here

TOP

Related Classes of org.openmrs.Person

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.