### Question:
Dstu3FhirResourceDhisToFhirTransformerUtils extends AbstractFhirResourceDhisToFhirTransformerUtils { @Nonnull @Override public IBaseReference createReference( @Nonnull IBaseResource resource ) { if ( resource.getIdElement().isEmpty() || resource.getIdElement().isLocal() ) { return new Reference( (Resource) resource ); } return new Reference( resource.getIdElement().toUnqualifiedVersionless() ); } Dstu3FhirResourceDhisToFhirTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext ); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Nonnull @Override IBaseResource createResource( @Nonnull String resourceType ); @Nonnull @Override IBaseElement createType( @Nonnull String fhirType ); @Nonnull @Override IBaseBundle createBundle( @Nonnull List<IBaseResource> result ); @Nonnull @Override ICompositeType createCodeableConcept(); @Nonnull @Override IBaseReference createReference( @Nonnull IBaseResource resource ); @Override boolean containsString( @Nonnull List<? extends IPrimitiveType<String>> stringList, @Nullable String value ); @Override boolean equalsDeep( @Nonnull IBase base1, @Nonnull IBase base2 );  }### Answer:
@Test public void createLocalReference() { final Resource resource = new Patient(); resource.setIdElement( new IdType( "#1234" ) ); final Reference result = (Reference) utils.createReference( resource ); Assert.assertSame( result.getResource(), resource ); }
@Test public void createEmptyReference() { final Resource resource = new Patient(); final Reference result = (Reference) utils.createReference( resource ); Assert.assertSame( result.getResource(), resource ); }
@Test public void createReference() { final Resource resource = new Patient(); resource.setIdElement( (IdType) new IdType().setParts( "http: final Reference result = (Reference) utils.createReference( resource ); Assert.assertNull( result.getResource() ); Assert.assertEquals( "Patient/4711", resource.getIdElement().toUnqualifiedVersionless().toString() ); }