Search in sources :

Example 11 with RelationshipConstraint

use of org.hisp.dhis.relationship.RelationshipConstraint in project dhis2-core by dhis2.

the class DhisConvenienceTest method createTeiToEnrollmentRelationshipType.

public static RelationshipType createTeiToEnrollmentRelationshipType(char uniqueCharacter, Program program, TrackedEntityType trackedEntityType, boolean isBidirectional) {
    RelationshipConstraint teiConstraintA = new RelationshipConstraint();
    teiConstraintA.setProgram(program);
    teiConstraintA.setTrackedEntityType(trackedEntityType);
    teiConstraintA.setRelationshipEntity(RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    RelationshipConstraint teiConstraintB = new RelationshipConstraint();
    teiConstraintB.setProgram(program);
    teiConstraintB.setTrackedEntityType(trackedEntityType);
    teiConstraintB.setRelationshipEntity(RelationshipEntity.PROGRAM_INSTANCE);
    RelationshipType relationshipType = createRelationshipType(uniqueCharacter);
    relationshipType.setName("Tei_to_enrollment_" + uniqueCharacter);
    relationshipType.setBidirectional(isBidirectional);
    relationshipType.setFromConstraint(teiConstraintA);
    relationshipType.setToConstraint(teiConstraintB);
    return relationshipType;
}
Also used : RelationshipConstraint(org.hisp.dhis.relationship.RelationshipConstraint) RelationshipType(org.hisp.dhis.relationship.RelationshipType)

Example 12 with RelationshipConstraint

use of org.hisp.dhis.relationship.RelationshipConstraint in project dhis2-core by dhis2.

the class DhisConvenienceTest method createMalariaCaseLinkedToPersonRelationshipType.

public static RelationshipType createMalariaCaseLinkedToPersonRelationshipType(char uniqueCharacter, Program program, TrackedEntityType trackedEntityType) {
    RelationshipConstraint psiConstraint = new RelationshipConstraint();
    psiConstraint.setProgram(program);
    psiConstraint.setTrackedEntityType(trackedEntityType);
    psiConstraint.setRelationshipEntity(RelationshipEntity.PROGRAM_STAGE_INSTANCE);
    RelationshipConstraint teiConstraint = new RelationshipConstraint();
    teiConstraint.setProgram(program);
    teiConstraint.setTrackedEntityType(trackedEntityType);
    teiConstraint.setRelationshipEntity(RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    RelationshipType relationshipType = createRelationshipType(uniqueCharacter);
    relationshipType.setName("Malaria case linked to person");
    relationshipType.setBidirectional(true);
    relationshipType.setFromConstraint(psiConstraint);
    relationshipType.setToConstraint(teiConstraint);
    return relationshipType;
}
Also used : RelationshipConstraint(org.hisp.dhis.relationship.RelationshipConstraint) RelationshipType(org.hisp.dhis.relationship.RelationshipType)

Example 13 with RelationshipConstraint

use of org.hisp.dhis.relationship.RelationshipConstraint in project dhis2-core by dhis2.

the class DhisConvenienceTest method createPersonToPersonRelationshipType.

public static RelationshipType createPersonToPersonRelationshipType(char uniqueCharacter, Program program, TrackedEntityType trackedEntityType, boolean isBidirectional) {
    RelationshipConstraint teiConstraintA = new RelationshipConstraint();
    teiConstraintA.setProgram(program);
    teiConstraintA.setTrackedEntityType(trackedEntityType);
    teiConstraintA.setRelationshipEntity(RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    RelationshipConstraint teiConstraintB = new RelationshipConstraint();
    teiConstraintB.setProgram(program);
    teiConstraintB.setTrackedEntityType(trackedEntityType);
    teiConstraintB.setRelationshipEntity(RelationshipEntity.TRACKED_ENTITY_INSTANCE);
    RelationshipType relationshipType = createRelationshipType(uniqueCharacter);
    relationshipType.setName("Person_to_person_" + uniqueCharacter);
    relationshipType.setBidirectional(isBidirectional);
    relationshipType.setFromConstraint(teiConstraintA);
    relationshipType.setToConstraint(teiConstraintB);
    return relationshipType;
}
Also used : RelationshipConstraint(org.hisp.dhis.relationship.RelationshipConstraint) RelationshipType(org.hisp.dhis.relationship.RelationshipType)

Aggregations

RelationshipConstraint (org.hisp.dhis.relationship.RelationshipConstraint)13 RelationshipType (org.hisp.dhis.relationship.RelationshipType)13 Relationship (org.hisp.dhis.tracker.domain.Relationship)3 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)3 Test (org.junit.jupiter.api.Test)3 ProgramInstance (org.hisp.dhis.program.ProgramInstance)1 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)1