@Test public void addSubjectResourceTypeWithoutRules() { Mockito.doReturn( Optional.of( new WritableTrackedEntityType( "a1234567890", "Test", Collections.emptyList() ) ) ) .when( trackedEntityMetadataService ).findTypeByReference( Mockito.eq( new Reference( "a1234567890", ReferenceType.ID ) ) ); Mockito.doReturn( Collections.emptyList() ) .when( trackedEntityRuleRepository ).findByTypeRefs( Mockito.eq( new HashSet<>( Arrays.asList( new Reference( "a1234567890", ReferenceType.ID ), new Reference( "Test", ReferenceType.NAME ) ) ) ) ); final WritableProgram program = new WritableProgram(); program.setName( "Test Program" ); program.setDescription( "Test Description" ); program.setWithoutRegistration( false ); program.setTrackedEntityTypeId( "a1234567890" ); program.setStages( new ArrayList<>() ); final PlanDefinition planDefinition = new PlanDefinition(); Assert.assertFalse( transformer.addSubjectResourceType( program, planDefinition ) ); }
protected boolean addSubjectResourceType( @Nonnull Program program, @Nonnull IBaseHasExtensions resource ) { final FhirResourceType fhirResourceType = ProgramTrackedEntityTypeUtils.getTrackedEntityFhirResourceType( trackedEntityMetadataService, trackedEntityRuleRepository, program ); ResourceTypeExtensionUtils.setValue( resource, fhirResourceType, getTypeFactory() ); return program.getTrackedEntityTypeId() == null || fhirResourceType != null; }
AbstractProgramMetadataToFhirPlanDefinitionTransformer extends AbstractReadOnlyDhisMetadataToTypedFhirTransformer<AccessibleScriptedDhisMetadata, F, ProgramMetadataRule> { protected boolean addSubjectResourceType( @Nonnull Program program, @Nonnull IBaseHasExtensions resource ) { final FhirResourceType fhirResourceType = ProgramTrackedEntityTypeUtils.getTrackedEntityFhirResourceType( trackedEntityMetadataService, trackedEntityRuleRepository, program ); ResourceTypeExtensionUtils.setValue( resource, fhirResourceType, getTypeFactory() ); return program.getTrackedEntityTypeId() == null || fhirResourceType != null; } }
AbstractProgramMetadataToFhirPlanDefinitionTransformer extends AbstractReadOnlyDhisMetadataToTypedFhirTransformer<AccessibleScriptedDhisMetadata, F, ProgramMetadataRule> { protected boolean addSubjectResourceType( @Nonnull Program program, @Nonnull IBaseHasExtensions resource ) { final FhirResourceType fhirResourceType = ProgramTrackedEntityTypeUtils.getTrackedEntityFhirResourceType( trackedEntityMetadataService, trackedEntityRuleRepository, program ); ResourceTypeExtensionUtils.setValue( resource, fhirResourceType, getTypeFactory() ); return program.getTrackedEntityTypeId() == null || fhirResourceType != null; } AbstractProgramMetadataToFhirPlanDefinitionTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull OrganizationUnitService organizationUnitService,
        @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository ); }
AbstractProgramMetadataToFhirPlanDefinitionTransformer extends AbstractReadOnlyDhisMetadataToTypedFhirTransformer<AccessibleScriptedDhisMetadata, F, ProgramMetadataRule> { protected boolean addSubjectResourceType( @Nonnull Program program, @Nonnull IBaseHasExtensions resource ) { final FhirResourceType fhirResourceType = ProgramTrackedEntityTypeUtils.getTrackedEntityFhirResourceType( trackedEntityMetadataService, trackedEntityRuleRepository, program ); ResourceTypeExtensionUtils.setValue( resource, fhirResourceType, getTypeFactory() ); return program.getTrackedEntityTypeId() == null || fhirResourceType != null; } AbstractProgramMetadataToFhirPlanDefinitionTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull OrganizationUnitService organizationUnitService,
        @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository ); @Nonnull @Override DhisResourceType getDhisResourceType(); @Nonnull @Override Class<AccessibleScriptedDhisMetadata> getDhisResourceClass(); @Nonnull @Override Class<ProgramMetadataRule> getRuleClass(); }
AbstractProgramMetadataToFhirPlanDefinitionTransformer extends AbstractReadOnlyDhisMetadataToTypedFhirTransformer<AccessibleScriptedDhisMetadata, F, ProgramMetadataRule> { protected boolean addSubjectResourceType( @Nonnull Program program, @Nonnull IBaseHasExtensions resource ) { final FhirResourceType fhirResourceType = ProgramTrackedEntityTypeUtils.getTrackedEntityFhirResourceType( trackedEntityMetadataService, trackedEntityRuleRepository, program ); ResourceTypeExtensionUtils.setValue( resource, fhirResourceType, getTypeFactory() ); return program.getTrackedEntityTypeId() == null || fhirResourceType != null; } AbstractProgramMetadataToFhirPlanDefinitionTransformer( @Nonnull ScriptExecutor scriptExecutor, @Nonnull LockManager lockManager, @Nonnull SystemRepository systemRepository, @Nonnull FhirResourceRepository fhirResourceRepository,
        @Nonnull FhirDhisAssignmentRepository fhirDhisAssignmentRepository, @Nonnull OrganizationUnitService organizationUnitService,
        @Nonnull TrackedEntityMetadataService trackedEntityMetadataService, @Nonnull TrackedEntityRuleRepository trackedEntityRuleRepository ); @Nonnull @Override DhisResourceType getDhisResourceType(); @Nonnull @Override Class<AccessibleScriptedDhisMetadata> getDhisResourceClass(); @Nonnull @Override Class<ProgramMetadataRule> getRuleClass(); static final FhirResourceType DEFAULT_SUBJECT_RESOURCE_TYPE; }