Package org.openmrs

Examples of org.openmrs.Relationship


  @ResponseBody
  public Object createNewRelationship(@RequestBody SimpleObject post, HttpServletRequest request,
          HttpServletResponse response) throws ResponseException {
    initRelationshipController();
    validatePost(post);
    Relationship relationship = createRelationshipFromPost(post);
    relationship = service.saveRelationship(relationship);
    return RestUtil.created(response, getRelationshipAsSimpleObject(relationship));
  }
View Full Code Here


   * Creates an relationship based on fields in the post object
   * @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());
    }
    catch (Exception e) {
      a = Context.getPersonService().getPersonByUuid(post.get("fromPerson").toString());
      b = Context.getPersonService().getPersonByUuid(post.get("toPerson").toString());
    }
    relationship.setPersonA(a);
    relationship.setPersonB(b);
    relationship.setRelationshipType(Context.getPersonService().getRelationshipTypeByName(
        post.get("relationshipType").toString()));
    return relationship;
  }
View Full Code Here

  @WSDoc("Gets Relationship for the uuid path")
  @ResponseBody()
  public String getRelationshipByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request)
          throws ResponseException {
    initRelationshipController();
    Relationship relationship = service.getRelationshipByUuid(uuid);
    return gson.toJson(getRelationshipAsSimpleObject(relationship));
  }
View Full Code Here

        // 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;
View Full Code Here

        // 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;
View Full Code Here

        // 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;
View Full Code Here

        // 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;
View Full Code Here

                                }
                            }
                        }
                    }
                    if (create) {
                        Relationship rel = new Relationship();
                        if (side.equals("A")) {
                            rel.setPersonA(session.getSubmissionActions().getCurrentPerson());
                            rel.setPersonB(relatedPerson);
                        }
                        if (side.equals("B")) {
                            rel.setPersonB(session.getSubmissionActions().getCurrentPerson());
                            rel.setPersonA(relatedPerson);
                        }
                        rel.setRelationshipType(r);

                        Context.getPersonService().saveRelationship(rel);
                        //session.getSubmissionActions().getRelationshipsToCreate().add(rel);
                    }
                }
View Full Code Here

TOP

Related Classes of org.openmrs.Relationship

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.