@Test public void prepareResourceNonMatchingWithDhisId() { Patient patient = new Patient(); patient = repository.prepareResource( patient, "a0123456789" ); Assert.assertTrue( patient.getIdElement().isEmpty() ); }
@Nonnull protected <T extends IBaseResource> T prepareResource( @Nonnull T resource, @Nullable String dhisResourceId ) { final FhirResourceType fhirResourceType = FhirResourceType.getByResource( resource ); if ( fhirResourceType == null ) { throw new FhirResourceTransformationException( "Could not determine FHIR resource type for " + resource.getClass().getSimpleName() ); } if ( fhirResourceType.isSyncDhisId() && dhisResourceId != null && !resource.getIdElement().hasIdPart() ) { resource.setId( dhisResourceId ); } return resource; }
FhirResourceRepositoryImpl implements FhirResourceRepository { @Nonnull protected <T extends IBaseResource> T prepareResource( @Nonnull T resource, @Nullable String dhisResourceId ) { final FhirResourceType fhirResourceType = FhirResourceType.getByResource( resource ); if ( fhirResourceType == null ) { throw new FhirResourceTransformationException( "Could not determine FHIR resource type for " + resource.getClass().getSimpleName() ); } if ( fhirResourceType.isSyncDhisId() && dhisResourceId != null && !resource.getIdElement().hasIdPart() ) { resource.setId( dhisResourceId ); } return resource; } }
FhirResourceRepositoryImpl implements FhirResourceRepository { @Nonnull protected <T extends IBaseResource> T prepareResource( @Nonnull T resource, @Nullable String dhisResourceId ) { final FhirResourceType fhirResourceType = FhirResourceType.getByResource( resource ); if ( fhirResourceType == null ) { throw new FhirResourceTransformationException( "Could not determine FHIR resource type for " + resource.getClass().getSimpleName() ); } if ( fhirResourceType.isSyncDhisId() && dhisResourceId != null && !resource.getIdElement().hasIdPart() ) { resource.setId( dhisResourceId ); } return resource; } FhirResourceRepositoryImpl( @Nonnull ScriptExecutor scriptExecutor, @Nonnull StoredFhirResourceService storedItemService, @Nonnull FhirClientResourceRepository fhirClientResourceRepository,
        @Nonnull ObjectProvider<List<FhirContext>> fhirContexts, @Nonnull ObjectProvider<List<AbstractFhirResourceRepositorySupport>> supports ); }
FhirResourceRepositoryImpl implements FhirResourceRepository { @Nonnull protected <T extends IBaseResource> T prepareResource( @Nonnull T resource, @Nullable String dhisResourceId ) { final FhirResourceType fhirResourceType = FhirResourceType.getByResource( resource ); if ( fhirResourceType == null ) { throw new FhirResourceTransformationException( "Could not determine FHIR resource type for " + resource.getClass().getSimpleName() ); } if ( fhirResourceType.isSyncDhisId() && dhisResourceId != null && !resource.getIdElement().hasIdPart() ) { resource.setId( dhisResourceId ); } return resource; } FhirResourceRepositoryImpl( @Nonnull ScriptExecutor scriptExecutor, @Nonnull StoredFhirResourceService storedItemService, @Nonnull FhirClientResourceRepository fhirClientResourceRepository,
        @Nonnull ObjectProvider<List<FhirContext>> fhirContexts, @Nonnull ObjectProvider<List<AbstractFhirResourceRepositorySupport>> supports ); @Nonnull @Override Optional<FhirContext> findFhirContext( @Nonnull FhirVersion fhirVersion ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, #transform}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshed( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId, boolean transform ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, true}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshed( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, true}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> find( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{'findByIdentifier', #fhirClientId, #fhirVersion, #resourceType, #identifier.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshedByIdentifier( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue identifier ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{'findByIdentifier', #fhirClientId, #fhirVersion, #resourceType, #identifier.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findByIdentifier( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue identifier ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{'findByCode', #fhirClientId, #fhirVersion, #resourceType, #code.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshedByCode( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue code ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{'findByCode', #fhirClientId, #fhirVersion, #resourceType, #code.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findByCode( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue code ); @Nullable @Override IBaseResource transform( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nullable IBaseResource resource ); @HystrixCommand @CacheEvict( key = "{#fhirClient.id, #fhirClient.fhirVersion, " + "T(org.dhis2.fhir.adapter.fhir.metadata.model.FhirResourceType).getByResource(#resource).getResourceTypeName(), #resource.getIdElement().getIdPart(), true}" ) @Override boolean delete( @Nonnull FhirClient fhirClient, @Nonnull IBaseResource resource ); @HystrixCommand @CacheEvict( key = "{#fhirClient.id, #fhirClient.fhirVersion, " + "T(org.dhis2.fhir.adapter.fhir.metadata.model.FhirResourceType).getByResource(#resource).getResourceTypeName(), #resource.getIdElement().getIdPart(), true}" ) @Nonnull @Override IBaseResource save( @Nonnull FhirClient fhirClient, @Nonnull IBaseResource resource, @Nullable String dhisResourceId ); @TransactionalEventListener( phase = TransactionPhase.BEFORE_COMMIT, classes = AutoCreatedFhirClientResourceEvent.class ) void autoCreatedSubscriptionResource( @Nonnull AutoCreatedFhirClientResourceEvent event ); }
FhirResourceRepositoryImpl implements FhirResourceRepository { @Nonnull protected <T extends IBaseResource> T prepareResource( @Nonnull T resource, @Nullable String dhisResourceId ) { final FhirResourceType fhirResourceType = FhirResourceType.getByResource( resource ); if ( fhirResourceType == null ) { throw new FhirResourceTransformationException( "Could not determine FHIR resource type for " + resource.getClass().getSimpleName() ); } if ( fhirResourceType.isSyncDhisId() && dhisResourceId != null && !resource.getIdElement().hasIdPart() ) { resource.setId( dhisResourceId ); } return resource; } FhirResourceRepositoryImpl( @Nonnull ScriptExecutor scriptExecutor, @Nonnull StoredFhirResourceService storedItemService, @Nonnull FhirClientResourceRepository fhirClientResourceRepository,
        @Nonnull ObjectProvider<List<FhirContext>> fhirContexts, @Nonnull ObjectProvider<List<AbstractFhirResourceRepositorySupport>> supports ); @Nonnull @Override Optional<FhirContext> findFhirContext( @Nonnull FhirVersion fhirVersion ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, #transform}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshed( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId, boolean transform ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, true}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshed( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{#fhirClientId, #fhirVersion, #resourceType, #resourceId, true}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> find( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull String resourceId ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{'findByIdentifier', #fhirClientId, #fhirVersion, #resourceType, #identifier.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshedByIdentifier( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue identifier ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{'findByIdentifier', #fhirClientId, #fhirVersion, #resourceType, #identifier.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findByIdentifier( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue identifier ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @CachePut( key = "{'findByCode', #fhirClientId, #fhirVersion, #resourceType, #code.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findRefreshedByCode( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue code ); @HystrixCommand( ignoreExceptions = FhirResourceTransformationException.class ) @Cacheable( key = "{'findByCode', #fhirClientId, #fhirVersion, #resourceType, #code.toString()}", unless = "#result==null" ) @Nonnull @Override Optional<IBaseResource> findByCode( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nonnull ClientFhirEndpoint fhirEndpoint, @Nonnull String resourceType, @Nonnull SystemCodeValue code ); @Nullable @Override IBaseResource transform( @Nonnull UUID fhirClientId, @Nonnull FhirVersion fhirVersion, @Nullable IBaseResource resource ); @HystrixCommand @CacheEvict( key = "{#fhirClient.id, #fhirClient.fhirVersion, " + "T(org.dhis2.fhir.adapter.fhir.metadata.model.FhirResourceType).getByResource(#resource).getResourceTypeName(), #resource.getIdElement().getIdPart(), true}" ) @Override boolean delete( @Nonnull FhirClient fhirClient, @Nonnull IBaseResource resource ); @HystrixCommand @CacheEvict( key = "{#fhirClient.id, #fhirClient.fhirVersion, " + "T(org.dhis2.fhir.adapter.fhir.metadata.model.FhirResourceType).getByResource(#resource).getResourceTypeName(), #resource.getIdElement().getIdPart(), true}" ) @Nonnull @Override IBaseResource save( @Nonnull FhirClient fhirClient, @Nonnull IBaseResource resource, @Nullable String dhisResourceId ); @TransactionalEventListener( phase = TransactionPhase.BEFORE_COMMIT, classes = AutoCreatedFhirClientResourceEvent.class ) void autoCreatedSubscriptionResource( @Nonnull AutoCreatedFhirClientResourceEvent event );  }