@Test public void getMappedDhisIdSync() { Assert.assertEquals( "hajdhcjsu89", utils.getMappedDhisId( transformerContext, new EnrollmentRule(), new IdDt( "PlanDefinition/hajdhcjsu89" ) ) ); }
@Nullable public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ) { if ( fhirId == null || !fhirId.hasIdPart() ) { return null; } if ( fhirId.getResourceType() == null ) { throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() ); } final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() ); if ( fhirResourceType == null ) { throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() ); } if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() ) { return fhirId.getIdPart(); } final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() ) .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) ); return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId ); }
AssignmentFhirToDhisTransformerUtils extends AbstractFhirToDhisTransformerUtils { @Nullable public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ) { if ( fhirId == null || !fhirId.hasIdPart() ) { return null; } if ( fhirId.getResourceType() == null ) { throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() ); } final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() ); if ( fhirResourceType == null ) { throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() ); } if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() ) { return fhirId.getIdPart(); } final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() ) .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) ); return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId ); } }
AssignmentFhirToDhisTransformerUtils extends AbstractFhirToDhisTransformerUtils { @Nullable public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ) { if ( fhirId == null || !fhirId.hasIdPart() ) { return null; } if ( fhirId.getResourceType() == null ) { throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() ); } final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() ); if ( fhirResourceType == null ) { throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() ); } if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() ) { return fhirId.getIdPart(); } final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() ) .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) ); return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId ); } protected  AssignmentFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext,
        @Nonnull FhirDhisAssignmentRepository assignmentRepository, @Nonnull FhirClientRepository fhirClientRepository ); }
AssignmentFhirToDhisTransformerUtils extends AbstractFhirToDhisTransformerUtils { @Nullable public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ) { if ( fhirId == null || !fhirId.hasIdPart() ) { return null; } if ( fhirId.getResourceType() == null ) { throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() ); } final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() ); if ( fhirResourceType == null ) { throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() ); } if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() ) { return fhirId.getIdPart(); } final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() ) .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) ); return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId ); } protected  AssignmentFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext,
        @Nonnull FhirDhisAssignmentRepository assignmentRepository, @Nonnull FhirClientRepository fhirClientRepository ); @Nonnull @Override final String getScriptAttrName(); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Nullable String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ); }
AssignmentFhirToDhisTransformerUtils extends AbstractFhirToDhisTransformerUtils { @Nullable public String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ) { if ( fhirId == null || !fhirId.hasIdPart() ) { return null; } if ( fhirId.getResourceType() == null ) { throw new IllegalArgumentException( "FHIR resource type is not included: " + fhirId.getValue() ); } final FhirResourceType fhirResourceType = FhirResourceType.getByResourceTypeName( fhirId.getResourceType() ); if ( fhirResourceType == null ) { throw new TransformerMappingException( "FHIR ID contains unsupported resource type: " + fhirId.getResourceType() ); } if ( fhirResourceType.isSyncDhisId() || context.getFhirRequest().isDhisFhirId() ) { return fhirId.getIdPart(); } final FhirClient fhirClient = fhirClientRepository.findOneByIdCached( context.getFhirRequest().getFhirClientId() ) .orElseThrow( () -> new FatalTransformerException( "FHIR Client with ID " + context.getFhirRequest().getFhirClientId() + " could not be found." ) ); return assignmentRepository.findFirstDhisResourceId( fhirClient, fhirId ); } protected  AssignmentFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext,
        @Nonnull FhirDhisAssignmentRepository assignmentRepository, @Nonnull FhirClientRepository fhirClientRepository ); @Nonnull @Override final String getScriptAttrName(); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Nullable String getMappedDhisId( @Nonnull FhirToDhisTransformerContext context, @Nonnull AbstractRule rule, @Nullable IIdType fhirId ); static final String SCRIPT_ATTR_NAME; }